Previous: , Up: Multinode Model   [Contents][Index]


4.20 Example of Working in Large-scale Mode

The large-scale mode of working with a multinode model is the one when an environment state identification engine and an instruction emitting engine that correspond to the model are represented by large actors. The use of large actors is controlled by the fields is_large_env and is_large_opt of structure qsmm_desc_s passed to the function qsmm_create when creating the multinode model.

The large scalability consists in the possibility to support large numbers of signals and states by utilizing relatively slow processing units and memory, which in principle could be distributed ones. When using a default uniform probability profile, the large-scale mode does not require possibly time-consuming initialization of working memory only if a single-node model (special case of multinode model) is used. To speed up program operation, if there is a need to work with many nodes, they can be emulated by creating multiple single-node models.

In the example, an agent has to find the gold in a labyrinth represented in Figure 4.4 and then exit from the labyrinth. The agent does not know its precise location in the labyrinth. The agent receives only limited amount of information about current location, as when a person walking in a labyrinth sees only some signs that got into his eyes and has to reconstruct parts of the labyrinth in his memory without assistance.

The labyrinth is represented by a set of sites connected in various ways. The agent can move from a site in four possible directions. The moves are performed by instructions ‘move north’, ‘move east’, ‘move south’, and ‘move west’. At specific sites only subsets of those moves are allowed, and when the agent tries to perform a disallowed move, that action will be ignored.

After an attempt to perform a move, the agent receives one of the following items of information:

No other information on the configuration of the labyrinth is received by the agent.

To learn the configuration of the labyrinth, the agent visits the labyrinth the number of times defined by the macro NVISIT. A visit is considered finished when the agent moves to the labyrinth exit site.

A test labyrinth

Figure 4.4: A test labyrinth

At the end of its run, the sample program prints information on the last path of visiting the labyrinth. Every element of the path contains either letter ‘x’, which indicates that a move was not performed because of an obstacle, or the index of a site (the agent is unaware of that index) and a combination of letters ‘N’, ‘E’, ‘S’, and ‘W’ that specify whether a move in the corresponding direction is possible from the site. If the site had contained the gold and the gold was taken, then ‘(***)’ is printed after that combination of letters.

After the last visiting path there are printed the total number of visits of the labyrinth for which the gold was found, the total length of all traversed visiting paths, and the average amount of gold found per one successful move in the labyrinth. File mat_goto with a state transition matrix and file mat_action with an action emission matrix are created in the current directory. The matrices are dumped rather slowly, and if you do not need them, you can press CTRL-C to stop that process prematurely.

A random seed can be specified as a program argument. If the random seed is non-negative, then the agent will operate normally. If the random seed is negative, then the agent will move in the labyrinth completely randomly. You could compare the program output for these two modes of program execution.

The source code of the example is provided in the file samples/maze.c in the package distribution and is also given below.

#include <assert.h>
#include <stdlib.h>
#include <string.h>

#include <qsmm/qsmm.h>

#define NVISIT 400
#define NSTATE 148


#define ERREXIT(fmt, ...)                                                 \
    do {                                                                  \
        fprintf(stderr,(fmt), ## __VA_ARGS__);                            \
        fprintf(stderr,"\n");                                             \
        goto Exit;                                                        \
    }                                                                     \
    while (0)


enum direct_e {
    DIRECT_NORTH=0,
    DIRECT_EAST =1,
    DIRECT_SOUTH=2,
    DIRECT_WEST =3
};


static int visit, n_gold_found=0, path_len=0;


static int opaque_maze(enum direct_e direct,
                       unsigned char *percept_p) {
    static char is_gf=0;
    static int node_curr=-1;
    static int maze[][4]={
        {21,  1, -1, -1},  // 0
        {24,  0, -1, 11},  // 1
        {-1,  9, -1, -1},  // 2
        { 7,  4, -1,  8},  // 3
        {-1, -1, -1,  3},  // 4
        {-1,  6, -1, -1},  // 5
        {-1, 12,  7,  5},  // 6
        {14, -1,  3,  6},  // 7
        {10, -1,  3, 20},  // 8
        {12, 13,  2, -1},  // 9
        { 8, -1, -1, -1},  // 10
        {-1, -1, -1,  1},  // 11
        {-1, 15,  9,  6},  // 12
        {-1, -1,  9, -1},  // 13
        {-1, -1,  7, -1},  // 14
        {25, 16, 12, -1},  // 15
        {-1, -1, -1, 15},  // 16
        {21, -1, -1, -1},  // 17
        {23, -1, -1, -1},  // 18
        {-1, 20, -1, -1},  // 19
        {26,  8, -1, 19},  // 20
        {23, 17,  0, -1},  // 21
        {-1, 24, -1, -1},  // 22
        {28, 18, 21, -1},  // 23
        {-1, 25, 22,  1},  // 24
        {35, -1, 15, 24},  // 25
        {32, 27, 20, -1},  // 26
        {33, 36, -1, 26},  // 27
        {30, 29, 23, -1},  // 28
        {-1, -1, -1, 28},  // 29
        {28, 31, -1, 34},  // 30
        {-1, -1, -1, 30},  // 31
        {26, -1, -1, -1},  // 32
        {-1, -1, 27, -1},  // 33
        {-1, -1, 30, -1},  // 34
        {-1, -1, 25, -1},  // 35
        {-1, -1, -1, 27}   // 36
    };
    unsigned char percept=0;
    int ii, result=0, node_new=(node_curr>=0?maze[node_curr][direct]:0);
    if (node_new<0) {
        percept=16;
        result=3;
        if (visit==NVISIT-1) printf(" x");
    }
    else {
        node_curr=node_new;
        assert(node_curr<sizeof(maze)/sizeof(*maze));
        for (ii=0; ii<4; ii++)
            if (maze[node_curr][ii]>=0) percept|=1 << ii;
        if (node_curr==31) {
            if (!is_gf) {
                is_gf=1;
                result=1;
            }
        }
        else if (node_curr==36) {
            is_gf=0;
            result=2;
        }
        if (visit==NVISIT-1)
            printf(" %d:%s%s%s%s%s", node_curr,
                   (percept & (1 << DIRECT_NORTH))?"N":"",
                   (percept & (1 << DIRECT_EAST ))?"E":"",
                   (percept & (1 << DIRECT_SOUTH))?"S":"",
                   (percept & (1 << DIRECT_WEST ))?"W":"",
                   result==1?"(***)":"");
        if (result==2) node_curr=-1;
    }
    if (percept_p) *percept_p=percept;
    return result;
}


static QSMM_INSTR_META_CLASS(move) {
    const char *ccp;
    int rc;
    enum direct_e direct=0;
    if (QSMM_HAS_INSTR_CLASS(qsmm_evt))
        qsmm_get_eh_instr_param(qsmm,sizeof(direct),&direct);
    switch (qsmm_evt) {
        case QSMM_EVT_INSTR_CLASS_INIT:
            switch (direct) {
                case DIRECT_NORTH: ccp="north"; break;
                case DIRECT_EAST:  ccp="east";  break;
                case DIRECT_SOUTH: ccp="south"; break;
                case DIRECT_WEST:  ccp="west";  break;
                default: assert(0);
            }
            qsmm_set_eh_instr_param_str_f(qsmm,"%s",ccp);
            qsmm_set_eh_noutcome(qsmm,17);
            break;
        case QSMM_EVT_ACTIVATE: {
            unsigned char percept=0;
            rc=opaque_maze(direct,&percept);
            qsmm_time_delta(qsmm,1);
            switch (rc) {
                case 0:
                case 3:
                    break;
                case 1:
                    qsmm_set_la_sig(qsmm,0,1);
                    n_gold_found++;
                    break;
                case 2: {
                    qsmm_sig_t sig_la=0;
                    qsmm_get_la_sig(qsmm,0,&sig_la);
                    if (sig_la) qsmm_spur_delta(qsmm,1,1);
                    qsmm_return_to_caller_node(qsmm);
                    break;
                }
                default:
                    assert(0);
            }
            if (rc!=2) {
                if (rc!=3) path_len++;
                qsmm_set_instr_outcome(qsmm,percept);
            }
            break;
        }
    }
    return 0;
}


static QSMM_INSTR_CLASS_SET(walker) {
    switch (qsmm_evt) {
        case QSMM_EVT_ENT_INIT: {
            enum direct_e direct;
            direct=DIRECT_NORTH, QSMM_REG_INSTR_CLASS_PARAM(move,direct);
            direct=DIRECT_EAST,  QSMM_REG_INSTR_CLASS_PARAM(move,direct);
            direct=DIRECT_SOUTH, QSMM_REG_INSTR_CLASS_PARAM(move,direct);
            direct=DIRECT_WEST,  QSMM_REG_INSTR_CLASS_PARAM(move,direct);
            qsmm_set_nstate_max(qsmm,__FUNCTION__,NSTATE);
            QSMM_NODE_CREATE(0);
            break;
        }
        case QSMM_EVT_NODE_ENTER: {
            unsigned char percept=0;
            qsmm_set_la_sig(qsmm,0,0);
            opaque_maze(DIRECT_NORTH,&percept);
            break;
        }
    }
    return 0;
}


int main(int argc, char **argv) {
    const char *ccp;
    int rc, seed=0, exit_code=1;
    qsmm_t qsmm=0;
    FILE *file_mat_goto_p=0, *file_mat_action_p=0;
    struct qsmm_desc_s desc;
    struct qsmm_dump_mat_goto_desc_s dump_mat_goto_desc;
    memset(&desc,0,sizeof(desc));
    desc.dont_use_instr_class_weights=1;
    desc.is_large_env=1;
    desc.is_large_opt=1;
    desc.nspur=2;
    desc.stack_sz_max=1;
    desc.ngram_env_la_sz=1;
    desc.nsig_ngram_env_la=2;
    desc.sparse_fill_max=0.2;
    desc.compat=1;
    if ((rc=qsmm_create(&desc,&qsmm))<0)
        ERREXIT("qsmm_create: %s",qsmm_err_str(rc));
    QSMM_REG_INSTR_META_CLASS(qsmm,move,0);
    QSMM_REG_INSTR_CLASS_SET(qsmm,walker,0);
    qsmm_engine_create(qsmm);
    if (argc>1 && (seed=atoi(argv[1]))<0) {
        qsmm_set_random(qsmm,1);
        seed=-seed;
    }
    qsmm_rng_seed(qsmm_get_rng(qsmm),seed);
    for (visit=0; visit<NVISIT; visit++) qsmm_node_call_default(qsmm,0,0);
    printf("\nn_gold_found=%d\npath_len=%d\nn_gold_found/path_len=%.8f\n",
           n_gold_found, path_len, (double) n_gold_found/path_len);
    if (!(file_mat_goto_p=fopen(ccp="mat_goto","w")) ||
        !(file_mat_action_p=fopen(ccp="mat_action","w")))
        ERREXIT("%s: failed to open the file for writing",ccp);
    memset(&dump_mat_goto_desc,0,sizeof(dump_mat_goto_desc));
    dump_mat_goto_desc.do_print_prob[QSMM_PROB_LEARNED]=1;
    qsmm_mat_goto_dump(qsmm,0,&dump_mat_goto_desc,file_mat_goto_p);
    qsmm_mat_action_dump(qsmm,0,0,file_mat_action_p);
    exit_code=0;

Exit:
    qsmm_destroy(qsmm);
    if (file_mat_action_p) fclose(file_mat_action_p);
    if (file_mat_goto_p) fclose(file_mat_goto_p);
    return exit_code;
}

Below is sample program output for the completely random mode of operation of the program.

$ ./maze -1
 0:NE 21:NES 23:NES 21:NES x 17:N 21:NES x 23:NES 28:NES 30:NEW x x 34
:S x x x x x x x x x x 30:NEW 34:S x x x 30:NEW 34:S x 30:NEW 28:NES 3
0:NEW x x 31:W(***) x 30:NEW 31:W 30:NEW 34:S x 30:NEW 34:S x x x x x 
x x x x x x x x x x x x 30:NEW x x x 31:W x x x x 30:NEW x 31:W 30:NEW
 x 34:S x x x x x x x x x x x x x 30:NEW x x 28:NES 29:W 28:NES x 30:N
EW 31:W x x x x x x x x x x 30:NEW 31:W x x 30:NEW 31:W x x x x 30:NEW
 x 28:NES 29:W x 28:NES 30:NEW x 34:S x x 30:NEW 31:W x 30:NEW 28:NES 
23:NES x 18:N 23:NES 18:N x x 23:NES 28:NES x 29:W x x 28:NES 23:NES 1
8:N x x x x x x x x x x x x 23:NES 18:N x x x x x x 23:NES 28:NES 29:W
 28:NES 29:W 28:NES 30:NEW 31:W x x 30:NEW 28:NES x 30:NEW x 28:NES 29
:W 28:NES x 23:NES x 18:N x 23:NES 21:NES x 17:N x x x x x 21:NES 0:NE
 1:NEW 11:W x x x x x x x 1:NEW x x 0:NE x 1:NEW x 11:W x x x 1:NEW 11
:W 1:NEW 24:ESW 25:NSW x 15:NES 25:NSW 15:NES 16:W x 15:NES 12:ESW 15:
NES 12:ESW 15:NES 16:W x x x x x x x 15:NES x 16:W x x 15:NES x x 16:W
 15:NES 16:W 15:NES x x 16:W x x x x x 15:NES x 16:W x x 15:NES 16:W x
 x x x x x 15:NES x 12:ESW 15:NES 16:W x x x x x x x 15:NES 12:ESW 15:
NES 16:W x 15:NES 16:W x x x 15:NES 25:NSW 35:S x x x x 25:NSW 24:ESW 
22:E x x x 24:ESW 25:NSW 35:S x x 25:NSW 24:ESW 22:E x x x 24:ESW 22:E
 x 24:ESW 1:NEW 24:ESW 1:NEW 0:NE x 21:NES 23:NES 18:N x x x 23:NES x 
28:NES 23:NES 21:NES 23:NES 28:NES 30:NEW 34:S x x x x x 30:NEW 31:W x
 x 30:NEW x 28:NES 23:NES 21:NES 23:NES 18:N x x x x x x x x x x 23:NE
S 21:NES 0:NE x 1:NEW 0:NE x 1:NEW 0:NE x 1:NEW 24:ESW 25:NSW 24:ESW 2
5:NSW 35:S x x 25:NSW x x x 35:S x x x x x x x x x x 25:NSW 35:S 25:NS
W x 15:NES 12:ESW x 9:NES x x 12:ESW 9:NES 13:S 9:NES 12:ESW 15:NES 12
:ESW 15:NES 12:ESW x 15:NES 12:ESW 15:NES 25:NSW 35:S 25:NSW x 15:NES 
16:W x x x x 15:NES 25:NSW 35:S x 25:NSW 15:NES x 25:NSW 15:NES 25:NSW
 24:ESW 25:NSW 35:S x 25:NSW 35:S 25:NSW 35:S x x x x x 25:NSW 15:NES 
x 25:NSW 24:ESW 1:NEW 24:ESW 22:E x x x x x x x 24:ESW 25:NSW 15:NES x
 x 25:NSW x 35:S x x x x x x x x x x x x 25:NSW x 24:ESW 1:NEW 11:W 1:
NEW 11:W x x x x x 1:NEW 11:W 1:NEW 24:ESW x 1:NEW 11:W x x x x x x x 
1:NEW x 11:W x x 1:NEW x 24:ESW 25:NSW 24:ESW x x 1:NEW x 11:W 1:NEW x
 24:ESW 22:E x x x x 24:ESW 22:E x x x x x x x 24:ESW 1:NEW x 11:W x 1
:NEW 0:NE 21:NES 17:N 21:NES 17:N x x x x x x 21:NES x 23:NES 21:NES 2
3:NES 21:NES x 0:NE x x x 1:NEW 24:ESW 1:NEW 11:W x x 1:NEW 24:ESW 25:
NSW 24:ESW x 1:NEW 11:W 1:NEW x 0:NE x 21:NES 17:N x 21:NES x 17:N 21:
NES x x x 17:N x x 21:NES 23:NES 18:N x x x x x x x 23:NES 21:NES 0:NE
 x x 1:NEW 0:NE x 1:NEW 11:W x x x x 1:NEW 24:ESW 25:NSW 24:ESW x 1:NE
W 11:W 1:NEW 11:W x x x x x x x 1:NEW 11:W 1:NEW 11:W 1:NEW 24:ESW 22:
E x x x x x x x x x x x x x x 24:ESW x 22:E x x x x 24:ESW 25:NSW 24:E
SW 25:NSW 24:ESW x x 22:E 24:ESW 22:E x x x x x x x x x 24:ESW 1:NEW 2
4:ESW x 25:NSW x 24:ESW 22:E 24:ESW 1:NEW 11:W x x 1:NEW 11:W x x x 1:
NEW 24:ESW x x x 1:NEW x 0:NE 21:NES 17:N x x x x x x x x x x x 21:NES
 x 23:NES x 18:N 23:NES 18:N 23:NES 28:NES 30:NEW x 31:W x 30:NEW 28:N
ES 23:NES 28:NES x 30:NEW 28:NES 29:W 28:NES x x 23:NES 21:NES 0:NE x 
x x 1:NEW 24:ESW 25:NSW 35:S x x x 25:NSW 35:S x x x x x x x x 25:NSW 
15:NES 25:NSW 35:S x 25:NSW 35:S 25:NSW 15:NES 16:W x x 15:NES 16:W x 
x x x 15:NES 12:ESW 9:NES 13:S x x x x x 9:NES 13:S x 9:NES 13:S 9:NES
 13:S x x x x x x x x x x x 9:NES 13:S x 9:NES 2:E x x x x x x x x x x
 x x x 9:NES x 12:ESW 6:ESW x 7:NSW 6:ESW 5:E x x x x 6:ESW x 5:E 6:ES
W 12:ESW 15:NES 12:ESW 15:NES 12:ESW 15:NES 16:W x x x x x x x x x x x
 15:NES 16:W x 15:NES x x 25:NSW 15:NES 12:ESW x 6:ESW 5:E x x x 6:ESW
 5:E x x x 6:ESW 5:E x x x x 6:ESW 12:ESW 9:NES x 2:E x x 9:NES 2:E x 
x x 9:NES 12:ESW x 6:ESW x 12:ESW x 15:NES x 12:ESW 6:ESW x 12:ESW 15:
NES 12:ESW x 15:NES x 12:ESW x 9:NES 2:E x x x x x x x 9:NES 2:E 9:NES
 12:ESW 15:NES 12:ESW 9:NES 12:ESW 6:ESW x 12:ESW 6:ESW x 5:E x x 6:ES
W 12:ESW 6:ESW 12:ESW 9:NES 12:ESW 9:NES 2:E x 9:NES 12:ESW 9:NES 12:E
SW x 6:ESW 12:ESW 15:NES 25:NSW x 15:NES 25:NSW 35:S 25:NSW 24:ESW 1:N
EW x 24:ESW x x 22:E x x x 24:ESW 1:NEW 11:W x x 1:NEW 24:ESW 1:NEW 24
:ESW 25:NSW 35:S x x x x 25:NSW 35:S 25:NSW 24:ESW 22:E 24:ESW 1:NEW x
 0:NE x x x x 1:NEW 0:NE 1:NEW x 11:W 1:NEW x x 24:ESW 25:NSW 35:S x 2
5:NSW 24:ESW 25:NSW x x 15:NES 16:W x x x 15:NES 16:W x x x x x x x x 
15:NES 16:W x x x x x x x x x 15:NES 25:NSW x x 15:NES 12:ESW 9:NES 2:
E 9:NES 2:E x x x x x 9:NES 13:S x x x 9:NES x 2:E 9:NES x 12:ESW 9:NE
S x x 2:E x x x 9:NES 2:E x x 9:NES 2:E x x 9:NES 13:S x x 9:NES 12:ES
W x 6:ESW 12:ESW 15:NES x 25:NSW 15:NES x 25:NSW 15:NES x x x 16:W 15:
NES 16:W x x x x 15:NES 12:ESW 9:NES 12:ESW 9:NES 2:E x x x 9:NES 12:E
SW 9:NES x x 2:E x 9:NES x 12:ESW 15:NES 12:ESW 9:NES 13:S x 9:NES 12:
ESW 9:NES x 12:ESW x 9:NES 2:E x 9:NES x 2:E x x 9:NES 2:E 9:NES x 13:
S x x x x 9:NES 13:S x x x x 9:NES 13:S x x x x 9:NES 13:S x 9:NES 12:
ESW 9:NES 12:ESW 9:NES 13:S x x x x x x x x x 9:NES 12:ESW x x 6:ESW 7
:NSW 6:ESW 5:E x 6:ESW 7:NSW x 6:ESW 12:ESW 15:NES 25:NSW x 15:NES 12:
ESW 15:NES 12:ESW 9:NES 2:E 9:NES 12:ESW 9:NES 13:S x 9:NES 13:S x 9:N
ES 13:S x x 9:NES 12:ESW x x 9:NES 13:S 9:NES 13:S x 9:NES 13:S 9:NES 
12:ESW 15:NES 16:W 15:NES 25:NSW x x 35:S 25:NSW 35:S x x 25:NSW x x 2
4:ESW 22:E x x 24:ESW 22:E x 24:ESW 22:E x x 24:ESW 25:NSW 15:NES 16:W
 x 15:NES 25:NSW x 35:S x 25:NSW 35:S 25:NSW 35:S x 25:NSW x 15:NES 16
:W 15:NES 16:W x x x 15:NES 16:W x x x 15:NES 12:ESW 9:NES 2:E 9:NES x
 2:E x 9:NES 13:S x x x x x x x x x 9:NES 12:ESW 6:ESW 7:NSW 14:S x x 
x 7:NSW x 3:NEW 7:NSW 6:ESW 7:NSW 14:S x x x x x x x x x x x 7:NSW 6:E
SW 5:E x x x 6:ESW 12:ESW x x 9:NES x 12:ESW x 9:NES 12:ESW 9:NES x 13
:S x 9:NES x 13:S x x x 9:NES 12:ESW 9:NES 13:S 9:NES 2:E x x x 9:NES 
2:E 9:NES 13:S x x x 9:NES 13:S x 9:NES 2:E x 9:NES 13:S x x x 9:NES x
 13:S 9:NES 12:ESW 15:NES x 12:ESW 9:NES x 12:ESW x 9:NES 13:S x 9:NES
 x 13:S x x 9:NES x 13:S x x x x x x 9:NES x 12:ESW 6:ESW 7:NSW x 3:NE
W 8:NSW x 3:NEW 4:W x x x x 3:NEW x 7:NSW 3:NEW 8:NSW 3:NEW 4:W x x x 
x x x x 3:NEW 4:W x x x x x x x x x x x x x x x x x x x x x x x 3:NEW 
4:W x x x x x x 3:NEW 4:W x 3:NEW 4:W x x x x x 3:NEW x x 8:NSW x 3:NE
W 8:NSW 10:N x x x 8:NSW 10:N x x x x x x x 8:NSW 3:NEW 8:NSW 3:NEW 8:
NSW 20:NEW 19:E x x x 20:NEW x x 8:NSW 10:N x 8:NSW 10:N x 8:NSW 3:NEW
 4:W 3:NEW 7:NSW x 14:S x x x x 7:NSW 6:ESW 5:E 6:ESW 12:ESW x 9:NES x
 13:S x x x x 9:NES 13:S x x x x x x 9:NES 13:S x 9:NES 12:ESW 9:NES 2
:E x x 9:NES 12:ESW x 6:ESW 7:NSW 6:ESW 12:ESW x x x 9:NES x 12:ESW 6:
ESW 7:NSW 6:ESW 12:ESW 15:NES 16:W 15:NES 12:ESW 15:NES 12:ESW 9:NES 1
2:ESW 9:NES 13:S 9:NES 2:E 9:NES 2:E x 9:NES x x 2:E x x x x x x x x 9
:NES x 2:E x x x x x x 9:NES 13:S 9:NES x 12:ESW 9:NES 2:E x x 9:NES 1
3:S x x x 9:NES 12:ESW 9:NES 13:S x x 9:NES x 12:ESW 15:NES 12:ESW x 6
:ESW 7:NSW 14:S x x x x x x x x x x x x x 7:NSW 3:NEW x 7:NSW 6:ESW 7:
NSW 14:S x x 7:NSW 6:ESW x 7:NSW 3:NEW 8:NSW x 20:NEW x 8:NSW x 10:N x
 x x x x 8:NSW 10:N x x x x x x 8:NSW 20:NEW 26:NES 32:N 26:NES x x 32
:N x 26:NES 27:NEW 33:S 27:NEW 33:S x x x x x 27:NEW 36:W
n_gold_found=297
path_len=257582
n_gold_found/path_len=0.00115303

Below is sample program output for the normal mode of operation of the program.

$ ./maze 1
 0:NE x 21:NES x 23:NES x x 21:NES 23:NES 28:NES 29:W x x 28:NES x 23:
NES 28:NES 30:NEW 34:S x x x 30:NEW 28:NES x x 30:NEW 31:W(***) 30:NEW
 31:W 30:NEW 34:S x x x x x x 30:NEW 31:W 30:NEW 28:NES 23:NES x 21:NE
S x 17:N x x x x x 21:NES 0:NE x 1:NEW x x 24:ESW x 25:NSW 35:S x x x 
x x 25:NSW 15:NES 16:W x x x x x 15:NES 16:W 15:NES x 12:ESW 6:ESW x x
 5:E 6:ESW x 7:NSW 14:S x x x 7:NSW 3:NEW 8:NSW 20:NEW 26:NES 27:NEW x
 x 26:NES 27:NEW 36:W
n_gold_found=398
path_len=37254
n_gold_found/path_len=0.01068342

Results of invocation of the sample program using random seeds in the range 1 to 20 (normal mode of operation) and in the range -20 to -1 (completely random mode of operation) are represented in the table below.

  SEED NGF PATH_LEN NGF/PATH_LEN    SEED NGF PATH_LEN NGF/PATH_LEN
------ --- -------- ------------  ------ --- -------- ------------
     1 398    37254   0.01068342      -1 297   257582   0.00115303
     2 400    55424   0.00721709      -2 310   254296   0.00121905
     3 399    49060   0.00813290      -3 282   238204   0.00118386
     4 389    35382   0.01099429      -4 285   245584   0.00116050
     5 400    34992   0.01143118      -5 284   238040   0.00119308
     6 398   117074   0.00339956      -6 290   227870   0.00127266
     7 395    41422   0.00953600      -7 288   229944   0.00125248
     8 399    46858   0.00851509      -8 287   243174   0.00118022
     9 399    41146   0.00969718      -9 280   238668   0.00117318
    10 396    53364   0.00742073     -10 299   230718   0.00129595
    11 394    37840   0.01041226     -11 297   228010   0.00130257
    12 399    34672   0.01150784     -12 284   237060   0.00119801
    13 399    58556   0.00681399     -13 286   233272   0.00122604
    14 397    47514   0.00835543     -14 274   239664   0.00114327
    15 400    37706   0.01060839     -15 272   235452   0.00115522
    16 398    42292   0.00941076     -16 296   234588   0.00126179
    17 393    52206   0.00752787     -17 284   219864   0.00129171
    18 398    30352   0.01311281     -18 297   230014   0.00129123
    19 395    50552   0.00781374     -19 285   245476   0.00116101
    20 399    75942   0.00525401     -20 288   243924   0.00118070
------ --- -------- ------------  ------ --- -------- ------------
   AVG 397    48980  [0.00811039]    AVG 288   237570  [0.00121333]
STDDEV 2.8    19221   0.00231747  STDDEV 9.0     9114   0.00005491

As it can be seen from the table, the average amount of gold found per one move in the labyrinth for 20 invocations of the sample program in the normal mode of operation is about 7 times greater than in the completely random mode of operation.


Previous: , Up: Multinode Model   [Contents][Index]