[freeciv-ai] [RFC] (PR#8805) Cleaning up build system
[Top] [All Lists]
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
 
<URL: http://rt.freeciv.org/Ticket/Display.html?id=8805 >
Here are some notes on what I am working towards.  I appreciate that my
divisions might not be ideal, but I feel some blueprint is needed.
Comments and criticism is welcome.  After some discussion I will put these
notes into README.AI
Data structure:
==============
struct ai_choice {
  int want;     /* Numerical value, scale not fixed */
  int choice;   /* Unit_Type_id or Impr_Type_id of the choice */
  bool is_unit; /* A clarification of the above */
  enum choice_classes {
    CC_MIL_EMERGENCY,    /* Enemy at the gates */
    CC_CIVIL_EMERGENCY,  /* Riots, famine */
    CC_MILITARY,         /* Regular military needs */
    CC_CIVIL,            /* Regular civil needs, development */
    CC_EXPANSION         /* Settlers */
  } class;
  bool need_boat; /* Does this unit need a boat for the task in mind? */
  /* And maybe */
  int x, y;       /* Coordinates of the target we have in mind */
}
Advisor hierarchy:
=================
CIVIL (DOMESTIC):
 Terrain Improvements
 City Improvements
   buildings
   wonders
 Help Wonders
MILITARY:
 Defence
   defenders
   defence structures
   counter-attack
 Attack
   attackers
   diplomat
   hunters
EXPANSION:
 Settlers
 Explorers
For each item on each level there should be a function which fills the
choice struct.  These choices are compared, on each level, against it's
peers using copy_if_better_choice function to improve logging and ease
introduction of priorities.
Function Naming and Interface:
=============================
All function should start with ai_chooseN_ where N is the depth in the
hierarchy.  Examples:
            ai_choose1_civil_build,
            ai_choose2_settlers,
            ai_choose3_diplomat
Each function takes (city, choice, other_params...).
Choice is assumed to be empty.
Notes:
=====
1. Choice classes may be further fragmented if needed.  The three
   types roughly correspond to expansionist/militaristic/perfectionist
   characters of civ2.
2. It is the current practice to substitute
   the chosen unit_type with ferry if a boat will be needed.  This
   will be now done in the end when the final choice is clear, to
   improve logging and facilitate future separation of ferry building
   into a standalone centralized module.
3. In the futures, modules will be taken out and made centralized.
   Good candidates are ferries, settlers, diplomats, hunters, attackers.
 
- [freeciv-ai] [RFC] (PR#8805) Cleaning up build system,
Gregory Berkolaiko <=
 
 
 
 | 
 |