简体   繁体   中英

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 = ???

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)))}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM