The below Perkun code represents a very simple example. There are two state variables - a (input variable) and b (hidden variable). There is also an output variable c. All the variables have boolean values.

The output variable values combinations are actions. In this example there are two actions: c=>false and c=>true. For each action we can represent the model as a directed graph, for example:

c=>false:

Every edge has the label 1.0, which corresponds with the transition probability.

And c=>true:

We can see that in each of the graphs the states are containing the state variables, i.e. a and b. The last graph can be formed into:

The two subgraphs labeled "a=>false" and "a=>true" are called in Perkun the "visible states". Each of them contains two states with fixed input variable values differing only by the hidden variable values.

And here is the Perkun code:

#!perkun

values

{

value false, true;

}

variables

{

input variable a:{false, true};

hidden variable b:{false, true};

output variable c:{false, true};

}

payoff

{

set({a=>false}, 0.0);

set({a=>true}, 100.0);

}

model

{

# model

# {c=>false}

set({a=>false ,b=>false },{c=>false },{a=>false ,b=>false },1.00000);

set({a=>false ,b=>false },{c=>false },{a=>false ,b=>true },0.00000);

set({a=>false ,b=>false },{c=>false },{a=>true ,b=>false },0.00000);

set({a=>false ,b=>false },{c=>false },{a=>true ,b=>true },0.00000);

# {c=>true}

set({a=>false ,b=>false },{c=>true },{a=>false ,b=>false },0.00000);

set({a=>false ,b=>false },{c=>true },{a=>false ,b=>true },1.00000);

set({a=>false ,b=>false },{c=>true },{a=>true ,b=>false },0.00000);

set({a=>false ,b=>false },{c=>true },{a=>true ,b=>true },0.00000);

# {c=>false}

set({a=>false ,b=>true },{c=>false },{a=>false ,b=>false },0.00000);

set({a=>false ,b=>true },{c=>false },{a=>false ,b=>true },1.00000);

set({a=>false ,b=>true },{c=>false },{a=>true ,b=>false },0.00000);

set({a=>false ,b=>true },{c=>false },{a=>true ,b=>true },0.00000);

# {c=>true}

set({a=>false ,b=>true },{c=>true },{a=>false ,b=>false },0.00000);

set({a=>false ,b=>true },{c=>true },{a=>false ,b=>true },0.00000);

set({a=>false ,b=>true },{c=>true },{a=>true ,b=>false },1.00000);

set({a=>false ,b=>true },{c=>true },{a=>true ,b=>true },0.00000);

# {c=>false}

set({a=>true ,b=>false },{c=>false },{a=>false ,b=>false },0.00000);

set({a=>true ,b=>false },{c=>false },{a=>false ,b=>true },0.00000);

set({a=>true ,b=>false },{c=>false },{a=>true ,b=>false },1.00000);

set({a=>true ,b=>false },{c=>false },{a=>true ,b=>true },0.00000);

# {c=>true}

set({a=>true ,b=>false },{c=>true },{a=>false ,b=>false },0.00000);

set({a=>true ,b=>false },{c=>true },{a=>false ,b=>true },0.00000);

set({a=>true ,b=>false },{c=>true },{a=>true ,b=>false },0.00000);

set({a=>true ,b=>false },{c=>true },{a=>true ,b=>true },1.00000);

# {c=>false}

set({a=>true ,b=>true },{c=>false },{a=>false ,b=>false },0.00000);

set({a=>true ,b=>true },{c=>false },{a=>false ,b=>true },0.00000);

set({a=>true ,b=>true },{c=>false },{a=>true ,b=>false },0.00000);

set({a=>true ,b=>true },{c=>false },{a=>true ,b=>true },1.00000);

# {c=>true}

set({a=>true ,b=>true },{c=>true },{a=>false ,b=>false },1.00000);

set({a=>true ,b=>true },{c=>true },{a=>false ,b=>true },0.00000);

set({a=>true ,b=>true },{c=>true },{a=>true ,b=>false },0.00000);

set({a=>true ,b=>true },{c=>true },{a=>true ,b=>true },0.00000);

}

loop(1);

When we execute the code with perkun we enter the interactive mode:

loop with depth 1

I expect the values of the variables: a

perkun>

Let's type "false":

belief:

b=false a=false 0.500000

b=true a=false 0.500000

optimal action:

c=true

perkun>

We can see that Perkun is not sure whether we are in the state "a=>false,b=>false" or "a=>false,b=>true" - they both have 50% belief probability. Let's type "false" again:

belief:

b=false a=false 0.00000

b=true a=false 1.00000

optimal action:

c=true

perkun>

Now it knows we are in the state "a=>false,b=>true" and wants as to "move" i.e. to execute the action "c=>true". Let us type "true":

belief:

b=false a=true 1.00000

b=true a=true 0.00000

optimal action:

c=false

perkun>

Now finally it has got what it likes - "a=>true" (see the payoff). Therefore it asks us to stay in the state (perform the action c=>false).

## Saturday, February 2, 2019

## Wednesday, December 19, 2018

### Perkun Wars optimal strategy

In the Perkun Wars there are three NPCs: Dorban, Pregor and Thragos. Dorban is a witcher, he is continuously hunting the vampire. Pregor and Thragos are humans - they are avoiding the vampire. You can attack the vampire whenever you see him, but it is the best idea to attack him when the NPCs are around.

There are two strategies: either you will hunt the vampire just like Dorban does (and thus you will mainly cooperate with Dorban) or you will wait with the humans till the vampire comes himself. The latter strategy is better - because the help of Pregor and Thragos is better than the help of Dorban. Very rarely you will be lucky enough to meet the vampire with all the three NPCs. This is your opportunity - attack him!

There are two strategies: either you will hunt the vampire just like Dorban does (and thus you will mainly cooperate with Dorban) or you will wait with the humans till the vampire comes himself. The latter strategy is better - because the help of Pregor and Thragos is better than the help of Dorban. Very rarely you will be lucky enough to meet the vampire with all the three NPCs. This is your opportunity - attack him!

## Tuesday, December 18, 2018

### Perkun Wars

I have added a website for my game - Perkun Wars:

http://www.pawelbiernacki.net/software/perkun_wars/index_pl.jsp

This game is intended mainly for the developers willing to use Perkun AI library in their own projects.

http://www.pawelbiernacki.net/software/perkun_wars/index_pl.jsp

This game is intended mainly for the developers willing to use Perkun AI library in their own projects.

## Wednesday, December 12, 2018

### Borsuk

I have published my new project - Borsuk. Not finished yet. You can download it from www.pawelbiernacki.net/borsuk-0.0.0.tar.gz

It requires SWI Prolog (devel packages), flex and bison. Just like Perkun it is also a library - libborsuk.

Take a look at examples/example2_fantasy.borsuk. It begins with declarations of classes and objects belonging to them, for example dorban is a person.

object dorban:person;

Then the variables (including hidden variables) can be generated with the templates like this one:

hidden variable has_(A:person)_(X:activity)_(B:person):boolean;

For each tuple (A,X,B) such that A is a person, X is an activity and B is a person it will generate the corresponding hidden variable. For example:

hidden variable has_dorban_attacked_pregor:{none,false,true};

As stated before borsuk will assume that the hidden variables are independent (or at least most of them are independent). This should allow Borsuk to support thousands of hidden variables, which was impossible for Perkun.

It requires SWI Prolog (devel packages), flex and bison. Just like Perkun it is also a library - libborsuk.

Take a look at examples/example2_fantasy.borsuk. It begins with declarations of classes and objects belonging to them, for example dorban is a person.

object dorban:person;

Then the variables (including hidden variables) can be generated with the templates like this one:

hidden variable has_(A:person)_(X:activity)_(B:person):boolean;

For each tuple (A,X,B) such that A is a person, X is an activity and B is a person it will generate the corresponding hidden variable. For example:

hidden variable has_dorban_attacked_pregor:{none,false,true};

As stated before borsuk will assume that the hidden variables are independent (or at least most of them are independent). This should allow Borsuk to support thousands of hidden variables, which was impossible for Perkun.

## Wednesday, August 22, 2018

### Independent hidden variables

I have an idea. Currently the problem is that the amount of hidden variables grows so that the amount of states becomes unacceptably large. I thought of decreasing the amount of states, or to be precise - I thought of assuming that the hidden variables are independent. It is not clear to me how this would work, but I started a project based on this idea.

## Monday, June 25, 2018

### A failure - "wydra"

I thought I would notify you about a project based on "bobr" called "wydra" (Polish for "otter"). The project was based on Prolog (to be precise - SWI Prolog) and looked very promising. Its purpose was to make optimal decisions just like Perkun does, but in the environment with very many hidden variables. I modified slightly the Perkun algorithm so that it only takes into account two hidden variables.

Unfortunately the project was a failure. I did not publish "wydra". It does not behave in the way I want it to. I thought you might wish to know.

Unfortunately the project was a failure. I did not publish "wydra". It does not behave in the way I want it to. I thought you might wish to know.

## Monday, February 26, 2018

### aidreams.co.uk

I discovered a new AI forum. I have written about Perkun there: http://aidreams.co.uk/forum/index.php?topic=12889.0

One post is particularly interesting - it is about Perkun application for programming. You can download http://www.pawelbiernacki.net/programmer.zip. Then run:

perkun programmer_final.perkun

This message describes how to use it: http://aidreams.co.uk/forum/index.php?topic=12889.msg50969#msg50969.

One post is particularly interesting - it is about Perkun application for programming. You can download http://www.pawelbiernacki.net/programmer.zip. Then run:

perkun programmer_final.perkun

This message describes how to use it: http://aidreams.co.uk/forum/index.php?topic=12889.msg50969#msg50969.

Subscribe to:
Posts (Atom)