Esempio n. 1
0
    def update_distributions(self, distributions):
        """Draw an agent's belief distributions."""
        # copy all distributions so we don't change their state
        distributions = [x.copy() for x in distributions]
        if self.distribution_images is None:
            self.draw_distributions(self.previous_state)
        for x in range(len(self.distribution_images)):
            for y in range(len(self.distribution_images[0])):
                image = self.distribution_images[x][y]
                weights = [dist[(x, y)] for dist in distributions]

                if sum(weights) != 0:
                    pass
                # Fog of war
                color = [0.0, 0.0, 0.0]
                colors = GHOST_VEC_COLORS[1:]  # With Pacman
                if self.capture:
                    colors = GHOST_VEC_COLORS
                for weight, gcolor in zip(weights, colors):
                    color = [
                        min(1.0, c + 0.95 * g * weight**.3)
                        for c, g in zip(color, gcolor)
                    ]
                gu.change_color(image, gu.format_color(*color))
        gu.refresh()
 def draw_expanded_cells(self, cells):
     """Draw an overlay of expanded grid positions for search agents."""
     n = float(len(cells))
     base_color = [1.0, 0.0, 0.0]
     self.clear_expanded_cells()
     self.expanded_cells = []
     for k, cell in enumerate(cells):
         screen_pos = self.to_screen(cell)
         cell_color = gu.format_color(*[(n - k) * c * .5 / n + .25
                                        for c in base_color])
         block = gu.square(screen_pos, 0.5 * self.grid_size,
                           color=cell_color, filled=1, behind=2)
         self.expanded_cells.append(block)
         if self.frame_time < 0:
             gu.refresh()
    def debug_draw(self, cells, color=[1.0, 0.0, 0.0], clear=False):
        """Draw debug information to screen."""
        if clear:
            self.clear_debug()
            self.expanded_cells = []

        for k, cell in enumerate(cells):
            screen_pos = self.to_screen(cell)
            cell_color = gu.format_color(*color)
            block = gu.square(screen_pos,
                              0.5 * self.grid_size,
                              color=cell_color,
                              filled=1,
                              behind=2)
            self.expanded_cells.append(block)
            if self.frame_time < 0:
                gu.refresh()
Esempio n. 4
0
Pieter Abbeel ([email protected]).

Most code by Dan Klein and John Denero written or rewritten for cs188,
UC Berkeley.  Some code from a Pacman implementation by LiveWires,
and used / modified with permission.
"""

import graphics_utils as gu
import math
from game import Directions
import os
import time

DEFAULT_GRID_SIZE = 30.0
INFO_PANE_HEIGHT = 35
BACKGROUND_COLOR = gu.format_color(0, 0, 0)
WALL_COLOR = gu.format_color(0.0 / 255.0, 51.0 / 255.0, 255.0 / 255.0)
INFO_PANE_COLOR = gu.format_color(.4, .4, 0)
SCORE_COLOR = gu.format_color(.9, .9, .9)
PACMAN_OUTLINE_WIDTH = 2
PACMAN_CAPTURE_OUTLINE_WIDTH = 4

GHOST_COLORS = []
GHOST_COLORS.append(gu.format_color(.9, 0, 0))  # Red
GHOST_COLORS.append(gu.format_color(0, .3, .9))  # Blue
GHOST_COLORS.append(gu.format_color(.98, .41, .07))  # Orange
GHOST_COLORS.append(gu.format_color(.1, .75, .7))  # Green
GHOST_COLORS.append(gu.format_color(1.0, 0.6, 0.0))  # Yellow
GHOST_COLORS.append(gu.format_color(.4, 0.13, 0.91))  # Purple

TEAM_COLORS = GHOST_COLORS[:2]