pythonmachine-learningcoordinatesq-learningstate-space

How to set coordinates as a state space (range) for use in Q-table?


Suppose I have a class Player that i want to use as my agent.I want all the coordinates possible in my environment to be my state space In my environment, I want to use the coordinates of the player as my state.How should I go about setting my "stateSpace/ range" then?

self.stateSpaceX = a for a in range(int(GRIDWIDTH)))
self.stateSpaceY = b for b in range(int(GRIDHEIGHT)))
self.stateSpace = ???

Solution

  • OK, I've found the solution:

    from itertools import product
    
    initstate = 0
    StateSpace = {coord: initstate for coord in product(range(int(GRIDWIDTH)), range(int(GRIDHEIGHT)))}