So you want to learn finally what Perkun (http://sourceforge.net/projects/perkun/) can do for you? As you remember the four sections in the Perkun code may be followed by instructions, and now is the time to learn another one: loop. It takes one argument - an integer constant, which denotes how deep Perkun should look into the game tree. Try the following code:
values
{
value false, true, do_nothing, switch;
}
variables
{
input variable alpha:{false, true};
output variable beta:{do_nothing, switch};
}
payoff
{
set({alpha=>false},0.0);
set({alpha=>true},100.0);
}
model
{
set({alpha=>false},{beta=>do_nothing},{alpha=>false},1.0);
set({alpha=>false},{beta=>do_nothing},{alpha=>true},0.0);
set({alpha=>true},{beta=>do_nothing},{alpha=>false},0.0);
set({alpha=>true},{beta=>do_nothing},{alpha=>true},1.0);
set({alpha=>false},{beta=>switch},{alpha=>false},0.0);
set({alpha=>false},{beta=>switch},{alpha=>true},1.0);
set({alpha=>true},{beta=>switch},{alpha=>false},1.0);
set({alpha=>true},{beta=>switch},{alpha=>true},0.0);
}
loop(1);
As you see we used the model from the former post. The Perkun will respond with the message and a prompt:
loop with depth 1
I expect the values of the variables: alpha
perkun>
Now it is your turn. You can enter one of the two values that the input variable alpha may have, i.e. false or true. Let us first try false:
perkun> false
belief:
alpha=false 1
optimal action:
beta=switch
perkun>
As the optimal action the beta=switch was chosen! Why? Because Perkun can see alpha=false, it does not like it (see the payoff) and knows that if it uses switch the alpha will change its value to not alpha. How does it know it? From the model (see the previous post). That is it, this is how Perkun works. OK. Let us continue. Let us now enter true:
perkun> true
belief:
alpha=true 1
optimal action:
beta=do_nothing
perkun>
Again Perkun chooses an optimal action, but this time it is beta=do_nothing! Why? Because it can see alpha=true, it likes it (see the payoff) and knows that do_nothing will keep the value of alpha unmodified. The last fact, again, is known from the model.
Just for fun let us lie to Perkun and enter now "false". This is impossible, because the model says that alpha after beta=do_nothing is unmodified. But let us do it:
perkun> false
result
alpha=false its probability was 0
exception caught
line 28 at T_INT_LITERAL: syntax error
error
What happened? Perkun has thrown an exception and stated that alpha=false was impossible! Quite correct. The bad news is that it terminated the session. But if you use Perkun as a library there is a way to overcome it and continue the session, so that you do not have to worry that using Perkun would break your programs.
No comments:
Post a Comment