0

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 = ???
Cravan PZ
  • 84
  • 1
  • 11
  • 1
    There are many answers to this questions. For instance, you could simply use the coordinates as your state. If you want an integer, you can use `y * GRIDWIDTH + x`. – Thomas Schillaci Jun 26 '20 at 13:49
  • @ThomasSchillaci sorry I think I confused myself, it should be state space, not state. If so, how should i go about doing it then? – Cravan PZ Jun 26 '20 at 13:52
  • 1
    If you're using tuples it would be [|0; GRIDWIDTH - 1|] x [|0; GRIDHEIGHT - 1|]. For integers it would be [|0; GRIDWIDTH * GRIDHEIGHT - 1|] – Thomas Schillaci Jun 26 '20 at 19:12
  • Erm @ThomasSchillaci sorry for disturbing you again but my IDE (atom) doesnt seem to recognise ; as valid syntax, and I had to replace the modulus with the function abs(). Could you advice me as to how to change it? I plan on using tuples, but x is invalid as well. Should I use * instead? But it tells me i cant multiply sequence by non-int of type 'list' – Cravan PZ Jun 27 '20 at 01:46
  • I wrote the mathematical representation of your state space, not the python implementation – Thomas Schillaci Jun 29 '20 at 07:29
  • Oh, I see. Thanks anyways! – Cravan PZ Jun 29 '20 at 09:40

1 Answers1

0

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)))}
Cravan PZ
  • 84
  • 1
  • 11