Exemplo n.º 1
0
class Environment:
  def __init__(self, rom_file, args):
    self.game = Game()

    #if args.display_screen:

      # DO SOME VISUALISATION

    #if args.random_seed:
      #self.ale.setInt('random_seed', args.random_seed)

    self.actions = self.game.getActionSet()
    logger.info("Using full action set with size %d" % len(self.actions))

    logger.debug("Actions: " + str(self.actions))

    self.dims = (args.screen_height, args.screen_width)

  def numActions(self):
    return len(self.actions)

  def restart(self):
    self.game.reset()

  def act(self, action):
    reward = self.game.move(self.actions[action])

    return reward

  def getScreen(self):
    return self.game.getCellsLog2()

  def isTerminal(self):
    if(self.game.canMove()):
        return False
    else:
        #print "Game ended!"
        #print "Score:"
        #print self.game.score
        #print "Number of moves: "
        #print self.game.nomove
        #print "Cells"
        #print self.game.cellsToString(self.game.getCells())
        return True
Exemplo n.º 2
0
def log2(cells):
    return [[transform(x) for x in line] for line in cells]

game = Game()

print cellsToString(game.getCells())

while game.canMove():
    #move = raw_input("Enter move [0-3]: ")
    move = random.choice([0,1,2,3])
    print "-------"
    print "Move: " + str(move)
    reward = game.move(int(move))
    print "Reward: " + str(reward)
    print ""
    print cellsToString(game.getCells())
    print ""
    print cellsToString(game.getCellsLog2())
    print ""
    print "Score: " + str(game.score)

print "Game ended"
print game.score
print cellsToString(game.getCells())

print "Test Reset"
game.reset()
print game.score
print cellsToString(game.getCells())