Friday, October 28, 2016

What is so special about thragos?

When you install the game thragos-0.0.0 you can simply walk around (control with the arrow keys), and occasionally you hit the NPCs, which causes the game to stop and allows you to make decision. The NPC chooses one of the ten actions. Sometimes it attacks you, sometimes it practices or makes a weapon. It happens that the NPC asks whether you are a wizard or whether you have a weapon. Why?

Well - that is what thragos is all about. The Wlodkowic specification executed by the game is in the unpacked tarball, the file wlodkowic/thragos.wlodkowic. Please enter the directory wlodkowic and grep the file thragos.wlodkowic for "estimate" and "set":

grep "estimate" thragos.wlodkowic | grep "set"

It responds with 1480 lines similar to this one:
set({he_is_a_wizard=>{false},
he_has_a_weapon=>{false},he_is_stronger_than_me=>{false},
reward=>{false},test_result=>{false,true,none},
i_am_a_wizard=>{false,true},i_have_a_weapon=>{false,true},i_can_see_him=>{false,true},he_has_used_a_weapon=>{false,true},he_has_used_magic=>{false,true}},{action=>{estimate_whether_he_is_a_wizard}},{he_is_a_wizard=>{false},he_has_a_weapon=>{false},he_is_stronger_than_me=>{false},reward=>{none},test_result=>{false},i
_am_a_wizard=>{false},i_have_a_weapon=>{true},i_can_see_him=>{false},he_has_used_a_weapon=>{false},he_has_used_magic=>{false}},1.0);


Let's highlight the initial state query (color blue) and terminal state query (color green):
set({he_is_a_wizard=>{false},
he_has_a_weapon=>{false},he_is_stronger_than_me=>{false},
reward=>{false},test_result=>{false,true,none},
i_am_a_wizard=>{false,true},i_have_a_weapon=>{false,true},i_can_see_him=>{false,true},he_has_used_a_weapon=>{false,true},he_has_used_magic=>{false,true}}
,{action=>{estimate_whether_he_is_a_wizard}},
{he_is_a_wizard=>{false},he_has_a_weapon=>{false},he_is_stronger_than_me=>{false},reward=>{none},test_result=>{false},i_am_a_wizard=>{false},i_have_a_weapon=>{true},i_can_see_him=>{false},he_has_used_a_weapon=>{false},he_has_used_magic=>{false}},1.0);

I can assure you that the green part (terminal state query) always contains reward=>{none}. What does it mean? It means that just asking the question gives no direct benefit to the agent. In spite of that the agent sometimes chooses to LEARN something about the hidden variables. Now this is what I call real Machine Learning. It is implied by the algorithm itself. The NPC will not only perform the actions like making a weapon or practising, he will also question its environment for hidden variables. Not always, of course. But sometimes.

Tuesday, October 25, 2016

thragos-0.0.0 released!

Download it from https://sourceforge.net/projects/thragos/. It has status alpha.

It requires:

Friday, October 21, 2016

THRAGOS - screenshot

Today I was rewriting my old 3d objects dumper, which was necessary since the Blender folks have changed quite a lot in their API. Thragos works more or less, but I still need to add many things.

What is the most important is the AI - it works between the NPCs and the player, but the NPCs do not meet each other yet. I will change this.

Sunday, October 9, 2016

THRAGOS - 0 errors

Finally I eliminated all the errors reported by Wlodkowic for my model. The diagram looks as follows:

I want to write a game demonstrating how to use Wlodkowic in your own projects (just like PerkunWars for Perkun). I imagine I would run a child process for each pair of characters.


Saturday, October 8, 2016

THRAGOS - 647 errors

The amount of remaining errors dropped to 647.
Currently I have 77 Prolog rules generated by my Perl script.

Once I finish with the errors I will need to add the "illegal" and "impossible" commands to the model, and then start the implementation in C++. I thought about using gtkglextmm library, it looks nice, I could reuse the 3D models I created for chrzaszcz2.

Friday, October 7, 2016

A fantasy game THRAGOS - still 1120 errors

I found a way to generate the Prolog rules I need with Perl. First I made a draft Wlodkowic specification for a simple fantasy game ("Thragos"). There are following actions there:
  • escape
  • attack_with_bare_hands
  • attack_with_weapon
  • attack_with_magic
  • learn_magic
  • practice_to_become_stronger
  • make_a_weapon
  • estimate_whether_he_is_a_wizard
  • estimate_whether_he_has_a_weapon
  • estimate_whether_he_is_stronger
After putting all the "unimportant" rules into the specification there are 444 states. This (along with the 10 actions) makes the "test();" command to produce 4440 errors (444*10). The amount of set instructions in the model should be 1971360 (444*10*444), but some (most) of them will contain zeros.

I will show you the diagram I produced for the current rules generated by my Perl script:



You can see that still about 25% errors are remaining (precisely 1120 errors). Initially I tried to write the Prolog rules manually, but I gave it up.

I imagine I would write a simple game based on Wlodkowic where the characters would try to optimize their situation fighting against each other, learning magic, producing weapons and so on. They would also communicate with each other for example to estimate whether someone is a wizard or whether he has a weapon.

The Wlodkowic variables for this project are:

variables
{
    input variable reward:{none,false,true};
    input variable test_result:{none,false,true};
    input variable i_am_a_wizard:{false,true};
    input variable i_have_a_weapon:{false,true};
    input variable i_can_see_him:{false,true};
    input variable he_has_used_a_weapon:{false,true};
    input variable he_has_used_magic:{false,true};

    hidden variable he_is_a_wizard:{false,true};
    hidden variable he_has_a_weapon:{false,true};
    hidden variable he_is_stronger_than_me:{false,true};
   
    output variable action:{escape,attack_with_bare_hands, attack_with_weapon, attack_with_magic,
        learn_magic, practice_to_become_stronger, make_a_weapon,
        estimate_whether_he_is_a_wizard,
        estimate_whether_he_has_a_weapon,
        estimate_whether_he_is_stronger};
}