Skip to content

Deterministic Instructions

Victor Mataré edited this page Oct 26, 2023 · 3 revisions

All imperative code is either executable (possible) or not, and once it has started executing, it may fail.

Block of code

{
    IMPERATIVE_STATEMENT
    [IMPERATIVE_STATEMENT ...]
}

Execute each IMPERATIVE_STATEMENT in succession.

Fails: When one of its elements fails.

Possible: Iff the first element is possible.

While loop

while (BOOLEAN_EXPRESSION)
    IMPERATIVE_STATEMENT

Fails: When IMPERATIVE_STATEMENT fails.

Possible: Iff BOOLEAN_EXPRESSION is false or IMPERATIVE_STATEMENT is possible.

Conditional branching

if (BOOLEAN_EXPRESSION)
    IMPERATIVE_STATEMENT
[ else
    IMPERATIVE_STATEMENT ]

Fails: When the executed IMPERATIVE_STATEMENT fails.

Possible: Iff according to the BOOLEAN_EXPRESSION the respective IMPERATIVE_STATEMENT is possible.

Testing for a boolean condition

test(BOOLEAN_EXPRESSION);

Block until some condition holds.

Fails: Never.

Possible: Iff BOOLEAN_EXPRESSION evaluates to true in the current situation.

Concurrent execution

concurrent {
    IMPERATIVE_STATEMENT
    [ IMPERATIVE_STATEMENT ... ]
}

Execute multiple imperative branches in parallel.

Caution: Concurrent execution is currently undefined during planning. Thus it should not be placed anywhere under a solve statement.

Fails: When all of the IMPERATIVE_STATEMENTs have failed.

Possible: Iff at least one IMPERATIVE_STATEMENT is possible.

Planning with reward function

solve (HORIZON, REWARD_FUNC)
    IMPERATIVE_CODE

Find the executable (possible) choice for all nondeterminisms within IMPERATIVE_CODE that results in the highest cumulative reward from REWARD_FUNC. The search depth is limited to HORIZON primitive actions. Caution: Note that both the start and the end of a durative action count as one primitive action.

Action call

See Action execution.