from cmptman import * import random # create the game cmpt = CMPTman(testboard=0) n_ghosts = len(cmpt.ghostPositions()) # play turns until the game is over while cmpt.playing(): directions = [] for g in range(n_ghosts): # decide on a direction for ghost g d = random.choice( [N,S,E,W,None] ) # random direction: probably bad directions.append(d) # a little look at the world for debugging: print "CMPTman is at:", cmpt.currentPosition() print "Dots left:", cmpt.dotsLeft() print "Moving ghosts:", directions # move the ghosts and wait for CMPTman to play cmpt.moveGhosts(directions)