Sunday, August 30, 2015

Perkun. Pregor.

I have one more example for Perkun (http://sourceforge.net/projects/perkun/) coming from Perkun Wars (a simple Perkun based fantasy game). The hero's name is Pregor. Download the file pregor_general.perkun. The variables are similar to those known from dorban_general.perkun:

input variable where_is_Pregor:{place_Wyzima,place_Shadizar,place_Novigrad};
input variable do_I_see_vampire:{false,true};
output variable action:{do_nothing,goto_Wyzima,goto_Shadizar,goto_Novigrad};
hidden variable where_is_vampire:{place_Wyzima,place_Shadizar,place_Novigrad};


But the payoff function is different. Pregor does not want to see the vampire:

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


Let us begin a perkun session:
$ perkun pregor_general.perkun
loop with depth 3
I expect the values of the variables: where_is_Pregor do_I_see_vampire
perkun> 


Let us begin in Novigrad and assume we do see the vampire.
perkun> place_Novigrad true
belief:
where_is_vampire=place_Wyzima where_is_Pregor=place_Novigrad do_I_see_vampire=true 0
where_is_vampire=place_Shadizar where_is_Pregor=place_Novigrad do_I_see_vampire=true 0
where_is_vampire=place_Novigrad where_is_Pregor=place_Novigrad do_I_see_vampire=true 1
optimal action:
action=goto_Wyzima
perkun> 


Of course, the belief is that the vampire is in Novigrad. And the decision is to escape, to go to Wyzima. Let us do it:

perkun> place_Wyzima false
belief:
where_is_vampire=place_Wyzima where_is_Pregor=place_Wyzima do_I_see_vampire=false 0
where_is_vampire=place_Shadizar where_is_Pregor=place_Wyzima do_I_see_vampire=false 0
where_is_vampire=place_Novigrad where_is_Pregor=place_Wyzima do_I_see_vampire=false 1
optimal action:
action=do_nothing
perkun>


Now Pregor still thinks the vampire is in Novigrad, but he cannot see him, so he is satisfied. The decision is to do nothing!

No comments:

Post a Comment