## Tutorial - General Game Playing

This tutorial will ask you step-by-step to understand the following single-player game as a planning problem -- and then to solve it.
```  (role you)

(opposite left right)
(opposite right left)

(init (you left))
(init (at c left))
(init (at g left))
(init (at w left))

(<= (legal you (take ?x))
(true (you ?side))
(true (at ?x ?side)))

(legal you (take nothing))

(<= (next (you ?new))
(true (you ?old))
(opposite ?new ?old))

(<= (next (at ?x ?new))
(does you (take ?x))
(true (at ?x ?old))
(opposite ?new ?old))

(<= (next (at ?x ?old))
(true (at ?x ?old))
(not (does you (take ?x))))

(<= terminal
good)
(<= terminal

(<= (goal you 100)
good)
(<= (goal you 0)

(<= good
(true (at c right))
(true (at g right))
(true (at w right)))

(true (at c ?side))
(true (at g ?side))
(not (true (you ?side))))
(true (at g ?side))
(true (at w ?side))
(not (true (you ?side))))
```

1. Initial state and Action Preconditions

1. According to the rules for  (init ?f), what are the state features  ?f  that hold in the initial state of this game?

2. According to the rules for  (legal you ?a), what are the legal moves  ?a  that you can take in the initial state?

Hint: There are 4 possible moves.

2. Action Effects

1. Select one of the 4 moves that are legal in the initial state and use the rules for  (next ?f)  to infer wich state features  ?f  are true after that action is taken in the initial state.

Hint: No matter which move you take, the resulting state again contains 4 features.

2. According to the game rules, which moves are legal in this resulting state? What are their effects?

3. State Transition System

Use the knowledge you gained from the previous two tasks to draw the entire state transition system for the game.

4. Planning

1. Use the rules for  terminal  to determine which states in the transition system are defined to be terminal, and then use the rules for  (goal you ?v)  to determine the goal value  ?v  for each of the terminal states.
2. Find a plan that solves the game (i.e., that leads to a terminal state with goal value 100).