Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

aiscore.h

Go to the documentation of this file.
00001 /* Scorekeeper Analysis Functions for AIs
00002    Copyright (C) 2005 Eric A. McDonald.
00003 
00004 Xconq is free software; you can redistribute it and/or modify
00005 it under the terms of the GNU General Public License as published by
00006 the Free Software Foundation; either version 2, or (at your option)
00007 any later version.  See the file COPYING.  */
00008 
00021 
00022 
00023 enum AI_SKANKind {
00024     AI_SKAN_NONE = 0,
00025     AI_SKAN_UPROPI,
00026     AI_SKAN_TESTOP
00027 };
00028 
00030 
00035 struct AI_SKANode {
00037     int kind;
00039     AI_SKANode *next;
00041     static void init(AI_SKANode *skanode);
00043     void copy_to(AI_SKANode *skanode);
00044 };
00045 
00047 
00048 struct AI_SKANode_UpropInt : public AI_SKANode {
00050     char *upropname;
00052     PackedBoolTable *sides_and_utypes;
00054     static void init(AI_SKANode_UpropInt *skanode);
00056     static AI_SKANode_UpropInt *construct(
00057         char *upropname, int *utypeary, SideMask sideset);
00059     void copy_to(AI_SKANode_UpropInt *skanode);
00061     AI_SKANode_UpropInt *clone();
00063     AI_SKANode_UpropInt *clone_list();
00065     static void destroy(AI_SKANode_UpropInt **skanode);
00067     static void destroy_list(AI_SKANode_UpropInt **skanode);
00069     static void merge_or_insert_into_list(
00070         AI_SKANode_UpropInt **skanodep, char *upropname, int *utypeary,
00071         SideMask sideset);
00072 };
00073 
00075 
00076 struct AI_SKANode_TestOp : public AI_SKANode {
00078     int op;
00080     static void init(AI_SKANode_TestOp *skanode);
00082     static AI_SKANode_TestOp *construct(int testop);
00084     void copy_to(AI_SKANode_TestOp *skanode);
00086     AI_SKANode_TestOp *clone();
00088     AI_SKANode_TestOp *clone_list();
00090     static void destroy(AI_SKANode_TestOp **skanode);
00092     static void destroy_list(AI_SKANode_TestOp **skanode);
00093 };
00094 
00096 
00102 struct AI_SKAnalysis {
00104     AI_SKAnalysis *next;
00106 
00109     int basic_flags;
00111     int action_flags;
00113     SideMask win_eq_some_turn;
00115     SideMask lose_eq_some_turn;
00117     SideMask win_ge_some_turn;
00119     SideMask lose_ge_some_turn;
00121     SideMask win_gt_some_turn;
00123     SideMask lose_gt_some_turn;
00125     SideMask win_eq_some_score;
00127     SideMask lose_eq_some_score;
00129     SideMask win_ne_some_score;
00131     SideMask lose_ne_some_score;
00133     SideMask win_le_some_score;
00135     SideMask lose_le_some_score;
00137     SideMask win_lt_some_score;
00139     SideMask lose_lt_some_score;
00141     SideMask win_ge_some_score;
00143     SideMask lose_ge_some_score;
00145     SideMask win_gt_some_score;
00147     SideMask lose_gt_some_score;
00149     int *win_eq_turn;
00151     int *lose_eq_turn;
00153     int draw_eq_turn;
00155     int *win_ge_turn;
00157     int *lose_ge_turn;
00159     int draw_ge_turn;
00161     int *win_gt_turn;
00163     int *lose_gt_turn;
00165     int draw_gt_turn;
00167     int *win_eq_score;
00169     int *lose_eq_score;
00171     int *win_ne_score;
00173     int *lose_ne_score;
00175     int *win_le_score;
00177     int *lose_le_score;
00179     int *win_lt_score;
00181     int *lose_lt_score;
00183     int *win_ge_score;
00185     int *lose_ge_score;
00187     int *win_gt_score;
00189     int *lose_gt_score;
00191     AI_SKANode_UpropInt *uprops_win_eq_some_sum;
00193     AI_SKANode_UpropInt *uprops_lose_eq_some_sum;
00195     AI_SKANode_UpropInt *uprops_win_ne_some_sum;
00197     AI_SKANode_UpropInt *uprops_lose_ne_some_sum;
00199     AI_SKANode_UpropInt *uprops_win_le_some_sum;
00201     AI_SKANode_UpropInt *uprops_lose_le_some_sum;
00203     AI_SKANode_UpropInt *uprops_win_lt_some_sum;
00205     AI_SKANode_UpropInt *uprops_lose_lt_some_sum;
00207     AI_SKANode_UpropInt *uprops_win_ge_some_sum;
00209     AI_SKANode_UpropInt *uprops_lose_ge_some_sum;
00211     AI_SKANode_UpropInt *uprops_win_gt_some_sum;
00213     AI_SKANode_UpropInt *uprops_lose_gt_some_sum;
00215     AI_SKANode_UpropInt *uprops_change_score;
00217     AI_SKANode_TestOp *opstack;
00219     static void init(AI_SKAnalysis *skanal);
00221     static AI_SKAnalysis *construct();
00223     void copy_to(AI_SKAnalysis *skanal);
00225     AI_SKAnalysis *clone();
00227     static void destroy(AI_SKAnalysis **skanalp);
00229     void push_test_op(int testop);
00231     AI_SKANode_TestOp *pop_test_op();
00233     int search_test_ops_for(int op);
00234 };
00235 
00237 
00238 #define for_all_ai_sk_analyses(skanals, skanal) \
00239     for ((skanal) = (skanals); (skanal); (skanal) = (skanal)->next)
00240 
00241 /* Scorekeeper analysis flags. */
00242 
00243 #define AI_SK_NONE              0
00244 
00245 #define AI_SK_DONT_UNDERSTAND   0x1
00246 #define AI_SK_DONT_TEST         0x2
00247 #define AI_SK_LAST_SIDE         0x10
00248 #define AI_SK_LAST_ALLIANCE     0x20
00249 #define AI_SK_CHANGE_SCORE      0x40
00250 
00251 /* Possible scorekeeper actions from AI perspective. */
00252 
00253 #define AI_SKA_NONE             0
00254 
00255 #define AI_SKA_CHANGE_SCORE     0x1
00256 #define AI_SKA_WIN              0x2
00257 #define AI_SKA_LOSE             0x4
00258 #define AI_SKA_DRAW             0x8
00259 #define AI_SKA_LAST_SIDE        0x10
00260 #define AI_SKA_LAST_ALLIANCE    0x20
00261 
00262 /* Possible scorekeeper tests from AI perspective. */
00263 
00264 #define AI_SKT_NONE             0
00265 
00266 #define AI_SKT_NOT              0x1
00267 #define AI_SKT_AND              0x2
00268 #define AI_SKT_OR               0x4
00269 #define AI_SKT_EQ               0x8
00270 #define AI_SKT_NE               0x10
00271 #define AI_SKT_LE               0x20
00272 #define AI_SKT_LT               0x40
00273 #define AI_SKT_GE               0x80
00274 #define AI_SKT_GT               0x100
00275 #define AI_SKT_PLUS             0x200
00276 #define AI_SKT_MINUS            0x400
00277 #define AI_SKT_MULTIPLY         0x800
00278 #define AI_SKT_DIVIDE           0x1000
00279 
00281 
00282 #define AI_SKT_ARITH_COMPARISONS \
00283     (AI_SKT_EQ | AI_SKT_NE | AI_SKT_LE | AI_SKT_LT | AI_SKT_GE | AI_SKT_GT)
00284 
00286 
00287 #define AI_SKT_ARITH_OPERATIONS \
00288     (AI_SKT_PLUS | AI_SKT_MINUS | AI_SKT_MULTIPLY | AI_SKT_DIVIDE)
00289 
00290 /* Function Declarations */
00291 
00293 extern AI_SKAnalysis *analyze_sk_sum_uprop_test(
00294     Side *side, Scorekeeper *sk, Obj *sktest, AI_SKAnalysis *parent);
00296 extern AI_SKAnalysis *analyze_sk_turn_test(
00297     Side *side, Scorekeeper *sk, Obj *sktest, AI_SKAnalysis *parent);
00299 extern AI_SKAnalysis *analyze_sk_score_test(
00300     Side *side, Scorekeeper *sk, Obj *sktest, AI_SKAnalysis *parent);
00302 extern AI_SKAnalysis *analyze_sk_arith_op_test(
00303     Side *side, Scorekeeper *sk, Obj *sktest, AI_SKAnalysis *parent);
00305 extern AI_SKAnalysis *analyze_sk_arith_gt_test(
00306     Side *side, Scorekeeper *sk, Obj *sktest, AI_SKAnalysis *parent);
00308 extern AI_SKAnalysis *analyze_sk_arith_ge_test(
00309     Side *side, Scorekeeper *sk, Obj *sktest, AI_SKAnalysis *parent);
00311 extern AI_SKAnalysis *analyze_sk_arith_lt_test(
00312     Side *side, Scorekeeper *sk, Obj *sktest, AI_SKAnalysis *parent);
00314 extern AI_SKAnalysis *analyze_sk_arith_le_test(
00315     Side *side, Scorekeeper *sk, Obj *sktest, AI_SKAnalysis *parent);
00317 extern AI_SKAnalysis *analyze_sk_arith_ne_test(
00318     Side *side, Scorekeeper *sk, Obj *sktest, AI_SKAnalysis *parent);
00320 extern AI_SKAnalysis *analyze_sk_arith_eq_test(
00321     Side *side, Scorekeeper *sk, Obj *sktest, AI_SKAnalysis *parent);
00323 extern AI_SKAnalysis *analyze_sk_arith_comp_test(
00324     Side *side, Scorekeeper *sk, Obj *sktest, AI_SKAnalysis *parent);
00326 extern AI_SKAnalysis *analyze_sk_bool_or_test(
00327     Side *side, Scorekeeper *sk, Obj *sktest, AI_SKAnalysis *parent);
00329 extern AI_SKAnalysis *analyze_sk_bool_and_test(
00330     Side *side, Scorekeeper *sk, Obj *sktest, AI_SKAnalysis *parent);
00332 extern AI_SKAnalysis *analyze_sk_bool_comp_test(
00333     Side *side, Scorekeeper *sk, Obj *sktest, AI_SKAnalysis *parent);
00335 extern AI_SKAnalysis *analyze_sk_when_test(
00336     Side *side, Scorekeeper *sk, Obj *sktest, AI_SKAnalysis *parent);
00338 extern AI_SKAnalysis * analyze_sk_always_true_test(
00339     Side *side, Scorekeeper *sk, Obj *sktest, AI_SKAnalysis *parent);
00341 extern AI_SKAnalysis *analyze_sk_test(
00342     Side *side, Scorekeeper *sk, Obj *sktest, AI_SKAnalysis *parent);
00344 extern AI_SKAnalysis *analyze_sk_if_action(
00345     Side *side, Scorekeeper *sk, Obj *skact, AI_SKAnalysis *parent);
00347 extern AI_SKAnalysis *analyze_sk_action(
00348     Side *side, Scorekeeper *sk, Obj *skact, AI_SKAnalysis *parent);
00350 extern AI_SKAnalysis *analyze_scorekeeper(Side *side, Scorekeeper *sk);
00352 extern AI_SKAnalysis *analyze_scorekeepers(Side *side);

Generated on Sat Sep 17 10:28:52 2005 for XconqKernel by doxygen 1.3.6