Tuesday, September 1, 2015

Perkun. Payoff generated in Prolog.

Let us begin with an easy example. In Perkun (http://sourceforge.net/projects/perkun/) you have to provide the payoff section and model section. The payoff in dorban_general.perkun looks as follows:

payoff
{
set({where_is_Dorban=>place_Wyzima, do_I_see_vampire=>false}, 0.0);
set({where_is_Dorban=>place_Wyzima, do_I_see_vampire=>true}, 100.0);
set({where_is_Dorban=>place_Shadizar, do_I_see_vampire=>false}, 0.0);
set({where_is_Dorban=>place_Shadizar, do_I_see_vampire=>true}, 100.0);
set({where_is_Dorban=>place_Novigrad, do_I_see_vampire=>false}, 0.0);
set({where_is_Dorban=>place_Novigrad, do_I_see_vampire=>true}, 100.0);
}


Do we notice any rule, any regularity here? Of course no matter where we are the payoff depends on the variable do_I_see_vampire only. In dorban_general_final.prolog we needed to add the fact:

% get_payoff(INPUT_where_is_Dorban,INPUT_do_I_see_vampire, PAYOFF).
 

get_payoff(_,true, 100.0). % Dorban is hunting the vampires



The comment above the fact was generated by Perkun. That is it! The payoff for do_I_see_vampire=false will be provided by the fallback rule (also generated by Perkun):

get_payoff(_,_, 0.0).

By the way, I did not mention yet, that in order to use Prolog generators it is better to avoid in Perkun the identifiers beginning with a capital letter. Lower case letters are better. Needless to say, the underscore character ("_") is also a bad candidate for an identifier.

No comments:

Post a Comment