Friday, August 28, 2015

Perkun. Illegal actions.

You may be wondering how to prevent some actions to be chosen by Perkun ( in some situations. Download the file dorban_general.perkun. Take a look at the beginning. There are two input variables:

input variable where_is_Dorban:{place_Wyzima,place_Shadizar,place_Novigrad};
input variable do_I_see_vampire:{false,true};

There are three places (Shadizar, Wyzima and Novigrad). I have borrowed the names from the fantasy literature, two from Sapkowski and one from Howard. There are also three corresponding actions plus do_nothing:

output variable action:{do_nothing,goto_Wyzima,goto_Shadizar,goto_Novigrad};

How do we tell Perkun that while being in Wyzima it is no point to use the action goto_Wyzima? There is a special instruction for that used in the model section. It is called "illegal". Grep the file dorban_general.perkun for it:

$ grep "illegal" dorban_general.perkun
illegal({where_is_Dorban=>place_Wyzima, do_I_see_vampire=>false},{action=>goto_Wyzima});
illegal({where_is_Dorban=>place_Wyzima, do_I_see_vampire=>true},{action=>goto_Wyzima});
illegal({where_is_Dorban=>place_Shadizar, do_I_see_vampire=>false},{action=>goto_Shadizar});
illegal({where_is_Dorban=>place_Shadizar, do_I_see_vampire=>true},{action=>goto_Shadizar});
illegal({where_is_Dorban=>place_Novigrad, do_I_see_vampire=>false},{action=>goto_Novigrad});
illegal({where_is_Dorban=>place_Novigrad, do_I_see_vampire=>true},{action=>goto_Novigrad});

The syntax is:

The VISIBLE_STATE_QUERY contains the input variable values, while the ACTION_QUERY contains the output variable values. That is it, Perkun won't try to use these actions when these situations occur!

No comments:

Post a Comment