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

aioprt.h

Go to the documentation of this file.
00001 /* Operational Roles and Analysis 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 namespace Xconq {
00022 namespace AI {
00023 
00025 
00026 enum OpRole_Type {
00028     OR_NONE = 0,
00030     OR_SHUTTLE,
00032     OR_CONSTRUCTOR,
00033     /* (TODO: Insert new oproles here.) */
00034     OR_Total
00035 };
00036 
00038 
00039 enum OpRole_Outcome {
00041     ORO_INVALID = 0,
00043     ORO_FAILED,
00045     ORO_OK,
00047     ORO_HANDLED_TACTICAL
00048     // TODO: Insert new oprole outcomes here.
00049 };
00050 
00052 
00053 struct OpRole {
00054     /* Basic Info */
00056     int id;
00058     OpRole_Type type;
00059     /* Extended Info */
00061     int dedication;
00063     int execs_this_turn;
00065     int fails_this_turn;
00066     /* (TODO: Graft in tasks queue here.) */
00067     /* Overhead */
00069     OpRole *next;
00071     OpRole *next_by_type;
00073     Side *side;
00074 };
00075 
00076 
00077 /* TEMPORARY: Side-related AI management.
00078     Should be moved to new files in the future. */
00079 
00081 
00082 struct AI_Side {
00083     /* Scorekeeper-related information. */
00085     AI_SKAnalysis *sk_analyses;
00086     /* Operational roles. */
00088     OpRole *oproles;
00090     OpRole *oproles_free;
00092     OpRole **oprole_buckets;
00093     /* Overhead. */
00095     Side *side;
00096 };
00097 
00099 extern void create_side_ai(Side *side);
00101 extern AI_Side * get_side_ai(Side *side);
00102 
00105 
00106 #define OR_BLK_SZ       200
00107 
00109 
00110 #define for_all_oproles(side,oprole) \
00111     for ((oprole) = (get_side_ai(side) ? get_side_ai(side)->oproles : NULL); \
00112          (oprole); (oprole) = (oprole)->next)
00113 
00115 
00116 #define for_all_oproles_by_type(side,type,oprole) \
00117     for ((oprole) = (get_side_ai(side) ? \
00118                         get_side_ai(side)->oprole_buckets[type] : NULL); \
00119          (oprole); (oprole) = (oprole)->next_by_type)
00120 
00122 extern void allocate_oproles(Side *side, int nodesnum = OR_BLK_SZ);
00124 extern OpRole *acquire_oprole(Side *side, int id, OpRole_Type type);
00126 extern void release_oprole(OpRole *oprole);
00128 extern OpRole *find_oprole(Side *side, int id);
00129 
00132 /* Construction */
00133 
00135 extern int choose_utype_to_construct(OpRole *oprole, int *uscore);
00137 extern Unit *choose_transport_to_construct_in(
00138     int u2, Side *side, UnitView *uview, int upchain = FALSE);
00140 extern Task *generate_construction_task(Unit *unit, int u2);
00142 extern int choose_construction_or_repair(OpRole *oprole);
00144 extern OpRole_Outcome handle_constructor_oprole(OpRole *oprole);
00145 
00146 /* General Operational Role Handling */
00147 
00149 extern void handle_oprole(OpRole *oprole);
00151 extern void handle_oproles(Side *side);
00152 
00153 } // namespace Xconq::AI
00154 } // namespace Xconq

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