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

• Perhaps you could edit the question to define the "toy vacuum cleaner problem". I'm not sure there is any "supposed to"; there might be many ways to approach the problem, and some might be more effective than others. Is there some context behind the question? Is it based on something you're reading in a textbook or elsewhere, for instance?
– D.W.
Jan 19, 2021 at 23:49
• I have added the diagram from the book "AI: A modern approach", and some text that hopefully demonstrates what the problem is, it is very simple and I am stuck on the state and transitioning between states. Jan 20, 2021 at 6:43

• The diagram is show the 8 potential states and they are numbered 1-8 which is why I am unsure if they are 'discovered' dynamically, or whether they would be pre coded, as an example in the diagram, if we are in state 1 and apply the suck action then it transitions to state 3 where the vacuum is still in the same space physically but the dirt is now gone. Jan 20, 2021 at 7:47