AI Improvement Alpha Testings.
Posted: Sat Jan 21, 2012 2:25 pm
1. I’ve always had a desire to improve AI play to the point where even an experienced player could be challenged by an AI that followed sound strategic and tactical strategies. I’ve even held a deep down desire to include some learning and storage functions where the AI could “learn” from its mistakes and improve its play through experience as we humans do. I realize this latter desire is very ambitious and would be like trying to get an advance graduate degree before learning to read. I guess we better start off with, “Jack and Jill” before we start working on a doctorial dissertation.
2. For the past year or two I’ve been dabbling with the AI on a very low priority basis. I do have a day job and GS is not it. Playing and improving GS is a hobby and will always remain that way with me. Any AI improvement takes a back seat to GS beta testing and development. And, truthfully it takes a back seat to life and may go “untouched” for weeks at a time. With the upcoming and official release of GSv2.10, I have a desire to spend more time on the AI and focus on improving it.
3. To be fully honest, nothing may ever come from my plunge into the world of the GS AI. However; if I don’t take the plunge then nothing for sure will ever come. So, for now, I’m sticking my toes into the water. What does that mean?
4. I’ve have built a separate location for my AI improvement development and testing. I call this location a sandbox and it’s a separate install from the GSv2.10 beta and what will become the official GSv2.10 release. When and how this activity will ever be merged back into GS is a consideration far away down the road and isn’t a particular concern now.
5. Also, I’ve made no attempt to rewrite any AI code. My philosophy, so far, has been that the AI code “works” to some extent and so, as I work my way through it I’ve been tweaking it to try to improve play and also try to understand what it’s doing in order for some day to support actually rewriting it. However; for now, I’m sticking to the tweaking and probing because of both time limitations and my understanding of the AI logic/code. Hence, my plunge for now is only toe deep.
6. My GS-AI sandbox uses the same data, image and map files as GS; but a different set of class files. My plan is to always keep it that way; so if we ever decide to integrate this back into GS it can possibly be done by have separate class files for play against the AI. That is; expect for these files, it will use the same files as GS (non-AI) uses. Since a set of class files is only about 1-MB this will not really add to the size of a GS install, which is now at 400-MB.
7. All tweaks to the AI so far have been hardcoded; but eventually I would like to make the AI actions controlled through data files as much as possible. So, even in the near-term, I see the addition of an AI-centric data file. However; at worse, I see this data file only adding 1 or 2-MB more to the install. In the distance future and if I ever make the plunge into the deep, I envisage one or more additional data files containing what the AI has learned (i.e., it’s memory). These files could eventually reach 10’s of MB’s in size but if we every get there … wow …
8. Here are the tweaks I’ve made so far:
a. Make the AI focused on a minor country’s capital when it invades and stop attacking the minor forces when the capital falls.
b. Be more aggressive to advance after combat and to attack adjacent and depleted enemy units. For example, it was frustrating to see the AI repair a unit, say at 5 or 6-steps, when that unit was adjacent to Warsaw and could have finished off a 1 or 2-step Polish unit there and completed the conquest of Poland. The tweaks I’ve made have changed this in most cases, not only for Warsaw; but for attacking enemy units on any resource hex.
c. When on the defense have the AI review its defenses. It will try to rail/move garrisons to all cities; except the capital in which case it will deploy an infantry corps there. Only units not at the front are considered for this duty. Any unit assigned to this duty will (or should) defend their assigned city/resource until destroyed, their country is conquered or the game ends. My intention was to stop the game from moving corps back and forth to cities in the rear areas and to free them up for frontline action.
d. The axis AI will accept the French armistice 75% of the time and reject it 25% of the time. This decision is hardwired and is made independent of the situation at the time in France. This is a prime example of an AI decision logic point that needs to be significantly reworked and controlled by data in a soon to be built AI-data file. But; for now it is what it is and it there to add more dimension to the AI play and testing.
e. In order not to “punish” the AI for GS changes “it doesn’t know about” there have been a number of cheats so that the AI is not charge of transport or invasion overages. Also, I just make a code change to allow it to land troops in non-fair weather. The long-term goal would be to do away with all AI-cheats; but that a way off. These for now are needed to keep the AI somewhat competitive.
9. The GS-AI alpha version, for now, is only available for the PC and at times it’s undergoing constant tweaks/changes and at other times being ignored. I will make this GS-AI alpha version (i.e., class file set) available if folks would like to join in on the alpha testing. If you do, I’d strongly suggest that you too make a separate sandbox for this testing as games created and stored by this version will not work with GSv2.10. If there’s enough interest I’ll upload the GS-AI alpha class file set, and update them as they change, and make available instructions for how to create a separate install (or sandbox) on you PC. Basically, you’d create another copy of GSv2.10 and then copy the GS-AI class files over the top of that.
10. For now, I’d recommend play against the AI (both against the axis and allied AI) with fog of war off in order to see what the AI is doing. I run the GS-AI beta with the axis AI playing against the allied AI. That is, the game is playing itself and watching it (for the most part) is like watching paint dry. This is controlled by the variable DEBUG_AI_VS_AI 1 (1=AI vs AI, 0= player vs AI) in the GS210_settings.txt file. NOTE: This file, along with the game turns, scenarios and additional output logs are stored in a different folder than used by GSv2.10. This different folder is: *\My Documents\CEAW Grand Strategy 2.10AI. Also, a set of game logs for debugging and development purposes are now generated and stored in *:\My Documents\CEAW Grand Strategy 2.10AI\data\gamelogs. The files in these logs are appended to so if you stop and restart, or start a new game, the information will be added to any previous information in these files. So you need to make sure you clean these files out periodically so they don’t grow too large.
11. If you’re interesting in AIalpha testing, I’m NOT recommending that you run it with AI vs AI. You can if you wish; but again that’s like watching paint dry. I do it to see if both AI’s can play a game through to the end without code error and I usually start one of these games before I go to bed or work and let it play while I’m not there. What I’m looking for now in alpha testing is if the axis AI, or allied AI, play is better than in GSv2.10 and what needs to be done to make it play better both tactically and strategically.
12. After reading this are you a PC user that’s interesting in GS AI improvement alpha testing? The one caveat though is that I may stick my toe in the water and decide it’s too cold; but who knows … I may swim across the Atlantic with this.
2. For the past year or two I’ve been dabbling with the AI on a very low priority basis. I do have a day job and GS is not it. Playing and improving GS is a hobby and will always remain that way with me. Any AI improvement takes a back seat to GS beta testing and development. And, truthfully it takes a back seat to life and may go “untouched” for weeks at a time. With the upcoming and official release of GSv2.10, I have a desire to spend more time on the AI and focus on improving it.
3. To be fully honest, nothing may ever come from my plunge into the world of the GS AI. However; if I don’t take the plunge then nothing for sure will ever come. So, for now, I’m sticking my toes into the water. What does that mean?
4. I’ve have built a separate location for my AI improvement development and testing. I call this location a sandbox and it’s a separate install from the GSv2.10 beta and what will become the official GSv2.10 release. When and how this activity will ever be merged back into GS is a consideration far away down the road and isn’t a particular concern now.
5. Also, I’ve made no attempt to rewrite any AI code. My philosophy, so far, has been that the AI code “works” to some extent and so, as I work my way through it I’ve been tweaking it to try to improve play and also try to understand what it’s doing in order for some day to support actually rewriting it. However; for now, I’m sticking to the tweaking and probing because of both time limitations and my understanding of the AI logic/code. Hence, my plunge for now is only toe deep.
6. My GS-AI sandbox uses the same data, image and map files as GS; but a different set of class files. My plan is to always keep it that way; so if we ever decide to integrate this back into GS it can possibly be done by have separate class files for play against the AI. That is; expect for these files, it will use the same files as GS (non-AI) uses. Since a set of class files is only about 1-MB this will not really add to the size of a GS install, which is now at 400-MB.
7. All tweaks to the AI so far have been hardcoded; but eventually I would like to make the AI actions controlled through data files as much as possible. So, even in the near-term, I see the addition of an AI-centric data file. However; at worse, I see this data file only adding 1 or 2-MB more to the install. In the distance future and if I ever make the plunge into the deep, I envisage one or more additional data files containing what the AI has learned (i.e., it’s memory). These files could eventually reach 10’s of MB’s in size but if we every get there … wow …
8. Here are the tweaks I’ve made so far:
a. Make the AI focused on a minor country’s capital when it invades and stop attacking the minor forces when the capital falls.
b. Be more aggressive to advance after combat and to attack adjacent and depleted enemy units. For example, it was frustrating to see the AI repair a unit, say at 5 or 6-steps, when that unit was adjacent to Warsaw and could have finished off a 1 or 2-step Polish unit there and completed the conquest of Poland. The tweaks I’ve made have changed this in most cases, not only for Warsaw; but for attacking enemy units on any resource hex.
c. When on the defense have the AI review its defenses. It will try to rail/move garrisons to all cities; except the capital in which case it will deploy an infantry corps there. Only units not at the front are considered for this duty. Any unit assigned to this duty will (or should) defend their assigned city/resource until destroyed, their country is conquered or the game ends. My intention was to stop the game from moving corps back and forth to cities in the rear areas and to free them up for frontline action.
d. The axis AI will accept the French armistice 75% of the time and reject it 25% of the time. This decision is hardwired and is made independent of the situation at the time in France. This is a prime example of an AI decision logic point that needs to be significantly reworked and controlled by data in a soon to be built AI-data file. But; for now it is what it is and it there to add more dimension to the AI play and testing.
e. In order not to “punish” the AI for GS changes “it doesn’t know about” there have been a number of cheats so that the AI is not charge of transport or invasion overages. Also, I just make a code change to allow it to land troops in non-fair weather. The long-term goal would be to do away with all AI-cheats; but that a way off. These for now are needed to keep the AI somewhat competitive.
9. The GS-AI alpha version, for now, is only available for the PC and at times it’s undergoing constant tweaks/changes and at other times being ignored. I will make this GS-AI alpha version (i.e., class file set) available if folks would like to join in on the alpha testing. If you do, I’d strongly suggest that you too make a separate sandbox for this testing as games created and stored by this version will not work with GSv2.10. If there’s enough interest I’ll upload the GS-AI alpha class file set, and update them as they change, and make available instructions for how to create a separate install (or sandbox) on you PC. Basically, you’d create another copy of GSv2.10 and then copy the GS-AI class files over the top of that.
10. For now, I’d recommend play against the AI (both against the axis and allied AI) with fog of war off in order to see what the AI is doing. I run the GS-AI beta with the axis AI playing against the allied AI. That is, the game is playing itself and watching it (for the most part) is like watching paint dry. This is controlled by the variable DEBUG_AI_VS_AI 1 (1=AI vs AI, 0= player vs AI) in the GS210_settings.txt file. NOTE: This file, along with the game turns, scenarios and additional output logs are stored in a different folder than used by GSv2.10. This different folder is: *\My Documents\CEAW Grand Strategy 2.10AI. Also, a set of game logs for debugging and development purposes are now generated and stored in *:\My Documents\CEAW Grand Strategy 2.10AI\data\gamelogs. The files in these logs are appended to so if you stop and restart, or start a new game, the information will be added to any previous information in these files. So you need to make sure you clean these files out periodically so they don’t grow too large.
11. If you’re interesting in AIalpha testing, I’m NOT recommending that you run it with AI vs AI. You can if you wish; but again that’s like watching paint dry. I do it to see if both AI’s can play a game through to the end without code error and I usually start one of these games before I go to bed or work and let it play while I’m not there. What I’m looking for now in alpha testing is if the axis AI, or allied AI, play is better than in GSv2.10 and what needs to be done to make it play better both tactically and strategically.
12. After reading this are you a PC user that’s interesting in GS AI improvement alpha testing? The one caveat though is that I may stick my toe in the water and decide it’s too cold; but who knows … I may swim across the Atlantic with this.

