Tuesday, May 25, 2021

svarog-0.0.8 and dorban-0.0.2

There is a new Svarog and a new Dorban out there. In Svarog I found the way to handle the situations when there were too many possible states to discretize the space of beliefs. It is much faster now. The new Dorban uses it and is, consequently, much faster.



The current intelligence level is 4, in spite of that the response time on my computer is below 1s.

Thursday, May 6, 2021

svarog-0.0.6 - Perl scripts to parallelize the precalculations.

If you have a multiple core machine you would like to parallelize the precalculations. The new svarog (0.0.6) contains four Perl scripts that help to do it. While you are free to write your own scripts using the svarog-merge tool (created in 0.0.5) it is more convenient to use these scripts:

  • svarog_generate_precalculate_tasks.pl
  • svarog_generate_precalculate_shell.pl
  • svarog_generate_control_shell.pl
  • svarog_generate_merge_shell.pl

In order to use them do the following steps:

  1. create a new directory and enter it
  2. copy a valid Svarog specification (without any commands) into it, for example as specification.svarog 
  3. copy specification.svarog into create_visible_states.svarog and append "cout << visible states << eol;" to it.
  4. execute: svarog create_visible_states.svarog > visible_states.txt
  5. check the amount of lines in visible_states.txt, in dorban's case it was 360
  6. execute: svarog_generate_precalculate_tasks.pl 4 2 specification.svarog visible_states.txt
  7. execute: svarog_generate_precalculate_shell.pl 360 > precalculate.sh
  8. execute: bash precalculate.sh

This will start the precalculations on all your processors, in parallel. In order to check whether they terminated you can use a control shell:

  1. execute: svarog_generate_control_shell.pl 360 > control.sh
  2. execute: bash control.sh 

If there are any errors this probably means that some precalculations did not terminate yet. You can use the ps shell command to check whether any svarogs are still running. When the control.sh reports no errors you will want to merge the Svarog specifications created by your tasks in the directory KNOWLEDGE:

  1. execute: svarog_generate_merge_shell.pl 360 > merge.sh
  2. execute: bash merge.sh

The result Svarog specification containing the precalculated knowledge will be the file result.svarog.

You should of course replace 360 in the above examples with the actual amount of visible states in your case.

Replace 4 (the first argument for svarog_generate_precalculate_tasks.pl) with the depth you want for the precalculations. It will affect the time required for the precalculations, but not the result size.

Wednesday, May 5, 2021

svarog-merge and a new precalculate command

svarog 0.0.5 has been released. It contains two enhancements:

  • a svarog-merge tool
  • enhanced command cout << precalculate() << eol


The enhanced command cout << precalculate() << eol allows precalculating knowledge for a specific visible state. The syntax is:

cout << precalculate(<depth>,<granularity>,<query>) << eol;

For example:

cout << precalculate(3,2,{has_dorban_won_a_fight=>none ,where_is_dorban=>place_Poznan ,can_dorban_see_pregor=>true ,can_dorban_see_pregor_is_alive=>true ,can_dorban_see_vampire=>true ,is_pregor_following_dorban=>true }) << eol;

The result is a valid Svarog specification with the knowledge precalculated merely for this visible state.

The tool svarog-merge requires two files:

svarog-merge <file1> <file2>

It adds all missing precalculated visible states from file2 to the file1 specification. The precalculated knowledge section must exist in the file1 (even if the section is empty) and the precalculated knowledge in both files must have the same depth and granularity.

Using the new "precalculate" command along with the svarog-merge tool allows running the precalculations on multiple core machines effectively (so that all processors have work to do).