getting right starter files
This commit is contained in:
+12
-8
@@ -4,7 +4,7 @@
|
||||
# educational purposes provided that (1) you do not distribute or publish
|
||||
# solutions, (2) you retain this notice, and (3) you provide clear
|
||||
# attribution to UC Berkeley, including a link to http://ai.berkeley.edu.
|
||||
#
|
||||
#
|
||||
# Attribution Information: The Pacman AI projects were developed at UC Berkeley.
|
||||
# The core projects and autograders were primarily created by John DeNero
|
||||
# ([email protected]) and Dan Klein ([email protected]).
|
||||
@@ -13,18 +13,19 @@
|
||||
|
||||
|
||||
import time
|
||||
try:
|
||||
try:
|
||||
import pacman
|
||||
except:
|
||||
pass
|
||||
|
||||
DRAW_EVERY = 1
|
||||
SLEEP_TIME = 0 # This can be overwritten by __init__
|
||||
SLEEP_TIME = 0 # This can be overwritten by __init__
|
||||
DISPLAY_MOVES = False
|
||||
QUIET = False # Supresses output
|
||||
QUIET = False # Supresses output
|
||||
|
||||
|
||||
class NullGraphics:
|
||||
def initialize(self, state, isBlue = False):
|
||||
def initialize(self, state, isBlue=False):
|
||||
pass
|
||||
|
||||
def update(self, state):
|
||||
@@ -45,13 +46,14 @@ class NullGraphics:
|
||||
def finish(self):
|
||||
pass
|
||||
|
||||
|
||||
class PacmanGraphics:
|
||||
def __init__(self, speed=None):
|
||||
if speed != None:
|
||||
global SLEEP_TIME
|
||||
SLEEP_TIME = speed
|
||||
|
||||
def initialize(self, state, isBlue = False):
|
||||
def initialize(self, state, isBlue=False):
|
||||
self.draw(state)
|
||||
self.pause()
|
||||
self.turn = 0
|
||||
@@ -63,8 +65,10 @@ class PacmanGraphics:
|
||||
if self.agentCounter == 0:
|
||||
self.turn += 1
|
||||
if DISPLAY_MOVES:
|
||||
ghosts = [pacman.nearestPoint(state.getGhostPosition(i)) for i in range(1, numAgents)]
|
||||
print("%4d) P: %-8s" % (self.turn, str(pacman.nearestPoint(state.getPacmanPosition()))),'| Score: %-5d' % state.score,'| Ghosts:', ghosts)
|
||||
ghosts = [pacman.nearestPoint(
|
||||
state.getGhostPosition(i)) for i in range(1, numAgents)]
|
||||
print("%4d) P: %-8s" % (self.turn, str(pacman.nearestPoint(state.getPacmanPosition()))),
|
||||
'| Score: %-5d' % state.score, '| Ghosts:', ghosts)
|
||||
if self.turn % DRAW_EVERY == 0:
|
||||
self.draw(state)
|
||||
self.pause()
|
||||
|
||||
Reference in New Issue
Block a user