ralphtricky
Posts: 6685
Joined: 7/27/2003 From: Colorado Springs Status: offline
|
I'm starting this thread to both ask for help, and to explain some of what Elmer does. I'm starting at the big picture level and going down to the detail later. Everything is subject to change, and there's always the chance that I'll figure out how to write an awesome strategic AI and this will become obsolete. I'll also update this first post as I find out more things and answer questions, etc. I know it's going to be confusing, I'm putting this together so that designers understand a bit better some of the restrictions, and so that some people may help me correct some of my bad assumptions, and places where I simply didn't write the code correctly. Note : If you're a player, you may not want to read this. I know once I found out for first person shooters work, it totally ruined them for me. I don't think that's true for Elmer, since he doesn't use many tricks, but I can't guarantee it. Commons problems I see in scenario design... Not spacing objectives at least 4 hexes apart so he understands front and back. Not having a 'safe' objective 0 to fall back on. Without this, special case code kicks in that probably isn't what you want like fallling back to supply sources, etc. If you really want to understand what's happening, you should go into the Opart 3.ini file and turn on the POLog Flag, I wouldn't do unitpolog unless you're a masochist. First, the only cheats I know of are 1) Overruns are always at the same odds. He gets multiple attempts, but while humans are multiplied by between .7 and 1.3, his are always at 1.0. Modifying him to move the units likely to do overruns first may be possible, but it would take a lot of restructuring. 2) He does know the overall strength on the board and uses it to set his aggression ratings only if the designer didn't set it. 3) He does know the ownership of hexes in a radius, he uses this to set the individual stance of his formations. It's a minor information cheat. If I ever allow the designer to set biases instead, I can get rid of that, and go by the visible hexes. 4) He does know the strength of units which have an unknown counter, and uses that to calculate his attack odds. I consider this to be the only cheat of any consequence, and I don't think he's smart enough to really use that to any effect. Unknowns like that are the hardest thing to deal with in an AI, and I'm not sure which version will change that. Probably sometime after he starts playing well enough to be taken seriously by the PBEM crowd I'll have to add probing attacks so he can determine what units have what without cheating. Full Strategic Layer This is where he decides how he's going to make his attacks. Right now, it consists mainly of the events that choose objective tracks and set the expernal po bias. Pseudocode NOTE: // means this is a comment Set the po_search Radius to between 7 and 11 for a smart opponent and 5 and 9 for a dumb one. disembark_all(); Set general orders biases. This depends on the unit strength on the map, with a bit more agression near the end of a scenario. It will be one of these 5 values. I assume the reason that this was coded this way was so that scenarios like Korea could be coded with fewer events and be more dynamic. If the external PO bias is set, it's assumed that you are setting it by hand, and this logic is ignored. FLEE, RETREAT, STAND, ADVANCE, BANZAI
if < 1:3 odds, general_orders_bias=FLEE;
else if < 1:2 odds, general_orders_bias=RETREAT;
else if > 3:1 odds, general_orders_bias=BANZAI;
else if > 1:1 odds, general_orders_bias=ADVANCE;
else if losing and > 7/8 way through game, or a 2% chance, general_orders_bias=ADVANCE;
if losing and within 3 turns of the projected end, general_orders_bias=BANZAI;
if(external_po_bias[current_player]!=STAND)
general_orders_bias=general_orders_bias+external_po_bias[current_player]
if(general_orders_bias>RETREAT)
rebuild_bridges();
//move individual formations
move_all_formations();
if(general_orders_bias<=RETREAT)
blow_bridges_near_enemy();
set_air_missions(current_player); More Strategic Stuff. (Formation Orders) I need to explain a little about how the path actually works. When looking at objectives, Elmer actually draws a line between them, and then draws another line perpindicular to the first objective passed in. HE ONLY DOES THIS IF THE OBJECTIVES ARE MORE THAN 3 HEXES APART. If they're 3 or less hexes apart, he does a circle of 1/2 the PO Radius instead. For example, if he's advancing, and one objective is at 5, 10 and the previous was at 5, 5, he would draw a line from 5,5 to 5,10, then draw a line perpindicular to that that has a PORadius length and counts the units that you have behind that line in a half-circle compared to the number that he has behind that line. If the enemy owns more than 1/2 the hexes behind that line, then he is considered to 'own' that objective for planning purposes. It's kind of like the center circle of a soccer field. If he's advancing, and one objective is at 5, 10 and the previous was at 5, 9, he would draw a circle of diameter of PORadius/2 length and count the units in that circle. If the enemy owns more than 1/2 the hexes behind that line, then he is considered to 'own' that objective for planning purposes. Note that the 1/2 was only for illustration purposes, different stances actually dictate what percentage of units are allowed 'behind' Elmer. There is a special case for the 3.4 patch, where he sees if the objective hex has a victory point value, if it does, he has to actually occupy that hex for it to be considered owned. For other hexes, that isn't true, he considers that he 'owns' it when a percentage of the hexes in that half-circle are owned by you. This can be used to fine tune forcing him to take out hard points instead of avoiding them. The important thing to note is that if the points on the paths are spaced at least 4 hexes apart, you should generally get better behavior since he does understand what is behind and in front mean. Now that that's out of the way, here's what the formations do. If the formation orders are DEFEND_ORDERS, and the enemy controls any points then the formation orders become ATTACK orders. If the formation orders are ATTACK_ORDERS, and the enemy controls no points then the formation orders become DEFEND orders. If the formation orders are SCREEN_ORDERS, and the enemy controls any points then the formation orders become SECURE orders. If the formation orders are ADVANCE_ORDERS, and the enemy controls no points then the formation orders become SCREEN orders. If the formation orders are SECURE_ORDERS, and the enemy controls no points then the formation orders become SCREEN orders. Adjust formation local orders bias by the displayable strength in PORadius. If the formation is unsupplied, if the center hex of the formations is not owned by you or the center hex is supplied, then flee otherwise lunge forward. Determine the pullback objective. This is either a a safe hex on the path, a supply hex or an enemy supply hex, or objective 0. Sets the local orders based on the formation orders and the strength bias. This is generally pretty straightforward. The following units ignore being able to be flanked. airborne_unit, airmobile_unit, special_forces_unit, hq_unit, unit_is_embarked, unit_in_deep_water_hex. Determine whether the hex is secure based on the pullback objective and whether attacking or defending. Attacking requires 33% of the hexes 'behind' you to be secure, defending requires 50%. This should have the effect of not letting formations get too far ahead to where they are likely to be cut off. If the hex isn't secure, then back off the agression. Override retreats if no formation objectives remain to fall back on, or unsupplied airborne. If emphasis isn't all costs and it's round 1 and the formation readinessandsupply is less than 50% then there's a chance of doing nothing to get caught up on readiness and supply. cock_airborne_units cock_airmobile_units cock_disembark_units cock_amphibious_units cock_rail_reinforcements Elmer actually moves by formation, sets up assaults, terminates ones that are late before moving the the next formation. After moving all the formations, he runs through another several optimizing steps.
move_formation(current_formation);
if((local_orders==PUSH_FORWARD)||(local_orders==LUNGE_FORWARD))
divide_special_forces_units();
if(local_orders==EXPAND)
divide_expansion_units(); //I don't remember seeing this, but apparently units with screen orders will divide.
else
integrate_children();
set_up_unit_queue(the_formation); //This determines the order units will move in a formation. Helicopters are last, AA are first, artillery second, bridging engineers third, etc.
//move all units
move_formation_units();
release_unused_transport_assets();
Now for the fun part, Moving Units.
These are the local orders that formation orders are translated into, depending on local strengths.
BUG_OUT = 10, //Back up and form a defensible line.
PULL_BACK = 11, //Back up one hex and hold???
CONSOLIDATE = 12, //Centralize and attempt to establish a line. Attack locally.
MOP_UP = 13, //Attempt to establish a perimeter. Attack locally.
PUSH_FORWARD = 14, //Advance and engage.
MOVE_FORWARD = 15, //Advance but do not engage.
LUNGE_FORWARD = 16, //Advance without regard for security. avoid engagements if movement is possible
EXPAND = 17, //Independently move to secure nearby territory
LOCAL_SECURITY = 18, //Pull individual units back from non secure locations
DO_NOTHING = 19, //Just sit there and keep your mouth shut
//following are sub categories of po orders
SUPPORT_FORWARD = 20,
ENGINEER_FORWARD = 21,
SUPPORT_COMBAT_FORWARD = 22
I'll update this first post later. Please feel free to post any questions, and I'll try to answer most of them. I'm trying to keep this at a high enough level to be useful without getting down into the weeds. Engineers, for example, can get very complicated in how the look for bridges to repair. Please let me know if you have a specific case where you don't believe he is doing as good as he could, and I'll be glad to look into it. Some of them I may be able to fix, others may need to wait until I can add either more designer control or a better high-level understanding of how things work. For example, adding in a count of dead units per hex might help him avoid suicidal attacks, adding in more control over the formation objectives like allowing the designer to override the radius, percent of enemies allowed, whether a perpindicular line should be formed, etc. Any suggestions along that line are welcome as well. I want to strike the best balance between allowing control and not requiring control to allow flexibility for changing conditions. Ralph
_____________________________
Ralph Trickey TOAW IV Programmer Blog: http://operationalwarfare.com --- My comments are my own, and do not represent the views of any other person or entity. Nothing that I say should be construed in any way as a promise of anything.
|