예제 #1
0
 def do_step(self, state):
     """ Do an agent step """
     state = list(state)
     
     # Get the matchbox for this state
     matchbox = self.get_matchbox(state)
     
     # Play
     marble, new_state = self.play(matchbox)
     
     # Store this move for learning
     self.moves.append((marble, matchbox))
     
     # Some debugging output
     print_state([state, new_state])
     print
     
     # Return new state to environment
     action = Action()
     action.intArray = new_state
     
     return action
예제 #2
0
    def do_step(self, state):
        """ Do an agent step """
        state = list(state)

        # Get the matchbox for this state
        matchbox = self.get_matchbox(state)

        # Play
        marble, new_state = self.play(matchbox)

        # Store this move for learning
        self.moves.append((marble, matchbox))

        # Some debugging output
        print_state([state, new_state])
        print

        # Return new state to environment
        action = Action()
        action.intArray = new_state

        return action
예제 #3
0
 def print_moves(self):
     """ Print the agent's moves so far """
     marbles = [("(%d)" % (m[0])).center(5) for m in self.moves]
     print "      ".join(marbles)
     
     print_state([m[1].state for m in self.moves])
예제 #4
0
    def print_moves(self):
        """ Print the agent's moves so far """
        marbles = [("(%d)" % (m[0])).center(5) for m in self.moves]
        print "      ".join(marbles)

        print_state([m[1].state for m in self.moves])