Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix readme file typos and code formatting issues #1

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ In this library a situation is a list of fluents that hold in that state.
This list is what is passed around your application.

To change this list, you *should* only do so through actions, which
extend the action class:
extend the action prototype:

```logtalk
:- object(drop(_Item_),
Expand All @@ -25,15 +25,16 @@ extend the action class:
poss(Situation) :-
holding(_Item_)::holds(Situation).

retracts_fluents([holding(_Item_)]).
asserts_fluents([]).
retracts_fluents([holding(_Item_)]).

asserts_fluents([]).

:- end_object.
```

This describes a drop action that is only possible when holding the
item. All actions must have possible conditions, even if they're just
always possible: `poss(_).`
item. All actions must have possible conditions, even if they're
always possible by defining the predicate `poss/1` as `poss(_).`

An action is done like so:

Expand All @@ -42,7 +43,7 @@ An action is done like so:
?- Sit = [holding(ball)], drop(ball)::do(Sit, NextSit).
```

The values that change in the application are called fluents (because
The values that change in the application are called *fluents* (because
of the situation calculus influence). We need to define in what situations they
hold with what values. Most of the time, this will just be if that
fluent is a member of the situation list. In these cases you only need
Expand All @@ -52,6 +53,7 @@ their functors.
```logtalk
:- object(holding(_Item_),
extends(fluent)).

:- end_object.
```

Expand All @@ -61,10 +63,10 @@ Should the fluent be derived from others, this can be declared like so:
:- object(net_profit(_Profit_),
extends(fluent)).

holds(S) :-
gross_profit(P)::holds(S),
total_costs(C)::holds(S),
_Profit_ is P - C.
holds(S) :-
gross_profit(P)::holds(S),
total_costs(C)::holds(S),
_Profit_ is P - C.

:- end_object.
```
Expand Down Expand Up @@ -104,13 +106,13 @@ for actions:
:- object(boil_kettle,
extends(action)).

poss(S) :-
situation::holds(power(kettle, on) and not kettle_water(empty), S).
poss(S) :-
situation::holds(power(kettle, on) and not kettle_water(empty), S).

:- end_object.
```

As we're in Prolog, `not` has the same meaning as `\+`.
As we're in Logtalk, `not/1` has the same meaning as `\+/1`.

Finally, to persist a situation between sessions, persist the list of
fluents and reload. This method of state handling clobbers it's history
Expand Down