O OBHMA TOY BOOY 1 transitionState 1 State
ΤO ΠΡOBΛHMA TOY BOΣΚOY (1) • transition(State 1, State 2} – Ορίζει τις επιτρεπτές αλλαγές καταστάσεων από State 1 σε State 2 – Αν ισχύει η transition(initial_state, final_state) τότε υπάρχει διαδρομή – σχέδιο • transition(state{f, f, f, f), state(f, f, f, f)). • transition(X, Z): move(X, Y), safe_state(Y), transition(Y, Z). • safe_state (state(X, _, X, _)). • safe_state (X, X, _, X)).
ΤO ΠΡOBΛHMA TOY BOΣΚOY (1) • move (state (B, X, Y, Z), state (B 1, X, Y, Z)) : other _side(B, B 1). • move (state (B, B, Y, Z), state(B 1 , Y, Z)) : other_side(B, B 1 ). • move (state (B, X, B, Z), state(B 1 , X, B 1 , Z)) : other_side(B, 81 ). • move (state (B, X, Y, B), state(B 1, X, Y, B 1)) : other_side(B, B 1 ). • other_side(i, f). • other_side(f, i).
TO ΠPOBΛHMA TOY BOΣKOY (2) • % transition{State 1, State 2, Accummulator, Plan) • transition{state{f, f, f, f), X, X). • transition{X, Z, A, P) : move{X, Υ), safe_state{Y), new_state{Y, A), transition{Y, Z, [Y IA], P). • new_state(State, List) : not member(State, List). • ? transition(stat_(i, i, i, i), state(f, f, f, f), [state(i, i, i, i)], X).
ΕΙΣΟΔΟΣ ΕΞΟΔΟΣ • %generate_plan (lnitia. IState, Final. State, Plan) • generate_plan (l, F, P) : transition (l, F, [I], X), reverse (X, P), display (P). • display ([state(X, V, Z, W) I Rest]) : write ('Voskos: '), write(X), write(' Likos: '), write{V), write(' Provato: '), write(Z), write(' Xorta: '), write{W), nl, display(Rest). display([]).
Ο πίθηκος και η μπανάνα move(State 1, Move. Type, State 2) • • move( state( middle, onbox, middle, hasnot), grasp, state( middle, onbox, middle, has) ). % Grasp banana move( state(P, onfloor, P, H), climb, state( P, onbox, P, H) ). % Climb box move( state( PI, onfloor, PI, H), push( PI, P 2), state( P 2, onfloor, P 2, H) ). move( state( PI, onfloor, B, H), walk PI, P 2), state( P 2, onfloor, B, H) ). % Push box from PI to P 2 % Walk from PI to P 2
Ο πίθηκος και η μπανάνα canget(State) ο πίθηκος μπορεί να πιάσει τη μπανάνα από την κατάσταση State • canget( state( _, _, _, has) ). canget( State 1) : move( Statel, Move, State 2), canget( State 2). • ? canget(state(atdoor, onfloor, atwindow, hasnot))
- Slides: 12