Difference between revisions of "AI Refactoring2009Crab"
m (→CURRENT) |
m (→CURRENT) |
||
Line 5: | Line 5: | ||
Proposed syntax (A'): | Proposed syntax (A'): | ||
− | ai_move_result move_my_leader = | + | ai_move_result move_my_leader = execute_move_unit_action(from,keep); |
if (move_my_leader.ok()){ | if (move_my_leader.ok()){ | ||
− | ai_recruit_result recruit_soldiers = | + | ai_recruit_result recruit_soldiers = execute_recruit_action(); |
if (!recruit_soldiers.ok()){ | if (!recruit_soldiers.ok()){ | ||
} | } |
Revision as of 18:32, 11 April 2009
CURRENT
extract gamestate-changing actions from AI code to separate classes.
Proposed syntax (A'):
ai_move_result move_my_leader = execute_move_unit_action(from,keep); if (move_my_leader.ok()){ ai_recruit_result recruit_soldiers = execute_recruit_action(); if (!recruit_soldiers.ok()){ } }
Benefits:
1. well-defined interface between c++ ai and game state changes
2. separate return status from other values (such as 'move ok/move failed/move interrupted' vs 'where moved unit is now')
3. ability to detect unchecked ai commands at runtime (if .ok() wasn't called, we can complain in the destructor of called command).
DONE
r34723 AI Refactoring: changed 'team' to 'side' when it means 'side number that starts from 1'.
r34720 AI Refactoring: Moved location of ai_interface::info to ai_manager. Now using a single copy of ai_interface::info for all AIs, and using get_info() accessor to get it from AIs. Also, fixed side to be unsigned int where it is possible.
r34719 AI Refactoring: removed unused turn_data_ from ai_interface::info
r34705 AI Refactoring. Extracted 'team number' and 'master' from ai_interface::info. This makes ai_interface::info ai-independent and allows to push it out of ai.