Next: , Previous: Half Eyes, Up: Worms and Dragons


7.5 Dragons

The array struct dragon_data dragon[MAX_BOARD] collects information about the dragons. We will give definitions of the various fields. Each field has constant value at each vertex of the dragon. (Fields will be discussed below.)

     
     struct dragon_data {
       int color;    /* its color                               */
       int id;       /* the index into the dragon2 array        */
       int origin;   /* the origin of the dragon. Two vertices  */
                     /* are in the same dragon iff they have    */
                     /* same origin.                            */
       int size;     /* size of the dragon                      */
       float effective_size; /* stones and surrounding spaces   */
       int crude_status;     /* (ALIVE, DEAD, UNKNOWN, CRITICAL)*/
       int status;           /* best trusted status             */
     };
     
     extern struct dragon_data dragon[BOARDMAX];
     

Other fields attached to the dragon are contained in the dragon_data2 struct array. (Fields will be discussed below.)

     
     struct dragon_data2 {
       int origin;
       int adjacent[MAX_NEIGHBOR_DRAGONS];
       int neighbors;
       int hostile_neighbors;
       int moyo_size;
       float moyo_territorial_value;
       int safety;
       float weakness;
       float weakness_pre_owl;
       int escape_route;
       struct eyevalue genus;
       int heye;
       int lunch;
       int surround_status;
       int surround_size;
       int semeais;
       int semeai_margin_of_safety;
       int semeai_defense_point;
       int semeai_defense_certain;
       int semeai_attack_point;
       int semeai_attack_certain;
       int owl_threat_status;
       int owl_status;
       int owl_attack_point;
       int owl_attack_code;
       int owl_attack_certain;
       int owl_second_attack_point;
       int owl_defense_point;
       int owl_defense_code;
       int owl_defense_certain;
       int owl_second_defense_point;
       int owl_attack_kworm;
       int owl_defense_kworm;
     };
     
     extern struct dragon_data2 *dragon2;
     

The difference between the two arrays is that the dragon array is indexed by the board, and there is a copy of the dragon data at every stone in the dragon, while there is only one copy of the dragon2 data. The dragons are numbered, and the id field of the dragon is a key into the dragon2 array. Two macros DRAGON and DRAGON2 are provided for gaining access to the two arrays.

     #define DRAGON2(pos) dragon2[dragon[pos].id]
     #define DRAGON(d) dragon[dragon2[d].origin]

Thus if you know the position pos of a stone in the dragon you can access the dragon array directly, for example accessing the origin with dragon[pos].origin. However if you need a field from the dragon2 array, you can access it using the DRAGON2 macro, for example you can access its neighor dragons by

     for (k = 0; k < DRAGON2(pos).neighbors; k++) {
       int d = DRAGON2(pos).adjacent[k];
       int apos = dragon2[d].origin;
       do_something(apos);
     }

Similarly if you know the dragon number (which is dragon[pos].id) then you can access the dragon2 array directly, or you can access the dragon array using the DRAGON macro.

Here are the definitions of each field in the dragon arrray.

Here are definitions of the fields in the dragon2 array.