AI Search - State in the toy vacuum problem I have been reading about AI search, specifically the toy vacuum cleaner problem and I would like to code an example of this but I am finding the description of the state hard to get my head around.
The problem states that the AI needs to be able to move between squares, either left or right and if there is dirt in the square it can clean it (suck).

Is the state something you are supposed to hard code in advance in AI search? This seems unlikely due to the possible number of potential states for a larger problem, so I am not sure how I can represent the state in a problem like this, or any other really.
In the vacuum problem the states are 'dirt left', 'dirt right' and 'vacuum position' and an action such as 'move left', 'move right' or 'suck' will leave the problem in a new state but how do you represent these changes?
Would state be an object with boolean properties for the dirt and an int value for the vacuum position of either 0 or 1 depending on which array element it is looking at?
In the context of a map program trying to get to somewhere I do understand the state might be In(New York) but I what I am struggling with is how I would represent something like that in code, or perhaps a maze where the current state might be the x, y coordinate of the square the agent is currently in, again would an object be the right thing to use to model state?
&quot;State&quot; is the sum of all information that describes the current situation of the robot, and everything about that past that might be relevant.  I don't understand your diagram so I can't tell you what it is specifically in your particular example, but it appears that the state includes the current location of the vacuum and which locations currently have dirt.  So, you might have one variable that defines where the robot is located, one variable that indicates whether there is dirt in the left room, and one variable that indicates whether there is dirt in the right room.
In AI search, we often assume that we know the set of all possible states and all ways to transition between them.  We give that information as input to the search algorithm, and it finds a way to reach a desired state from where we currently are.