Monday, August 31, 2015

Perkun. The Prolog generators.

You have identified an optimization problem that Perkun ( could solve for you? Excellent. Then you need to write a Perkun code yourself. When you look at the files like dorban_general.perkun you probably wonder how I created them. I did not write all this manually. Instead I used a Prolog generator.  Do you know Prolog? It would be very helpful to learn it. This is the file I started with:

    value false, true; # logical values
    value place_Wyzima,place_Shadizar,place_Novigrad;
    value do_nothing,escape,fight,goto_Wyzima,goto_Shadizar,goto_Novigrad;


    input variable where_is_Dorban:{place_Wyzima,place_Shadizar,place_Novigrad}; # where am I
    input variable do_I_see_vampire:{false, true};
    output variable action:{do_nothing,goto_Wyzima,goto_Shadizar,goto_Novigrad}; # actions
    hidden variable where_is_vampire:{place_Wyzima,place_Shadizar,place_Novigrad};

payoff {}
model {}

cout << prolog generator << eol;

As you can see the model section is followed by a new instruction:

cout << prolog generator << eol;

It produces a program in Prolog. You can download the result - dorban_general.prolog. If you look at the code you will find the comments:

% PLEASE INSERT YOUR CODE HERE-write_model_impossible_if_necessary
% PLEASE INSERT YOUR CODE HERE-write_model_action_illegal_if_necessary

If you execute dorban_general.prolog directly (for example with SWI Prolog) you will get a Perkun code with zeros in the model. Instead you should write the Prolog code, insert it in the locations indicated by the comments and make something like the file dorban_general_final.prolog. That is it! When you execute dorban_general_final.prolog with Prolog you will get dorban_final.perkun.

What Prolog code has been added? I think I will discuss it in the next post.

No comments:

Post a Comment