First Pass at an AI upgrade
Moderator: Committer
First Pass at an AI upgrade
Hi, I've made a number of changes to the AI that really help it be more challenging. First off, I've given it a fixed research schedule that I think works better than the previous arrangement. Second, I gave it a few more ship building options, and implemented a naming scheme so that it always builds the best available in class rather than a random one in a given class (really only effects military ships currently). I also improved the colonization decision making so that it takes into account related technology, and I tweaked the production/research priority handling as well.
***revised files attached a few posts down***
You can drop the attached zip file in your "FreeOrion/default" folder (after backing up said folder please), and upon unpacking it should replace 3 of the text files related to ships (I only updated the english stringtable, so if you use a diff language there may be problems unless you port my stringtable changes), and will replace a few of the AI python files.
I've play-tested this a bit, but not as much testing as I'd planned, so definitely backup the default folder before unpacking.
That said, I'm pretty proud of these improvements; the seem to me to do a lot to making the game enjoyable for the strategy challenge rather than being more of a sandbox. I'm quite interested in hearing feedback & will try to be responsive if anyone has trouble with it. I have been getting a lot of "end of file" disconnects from the networking thread, lately that I haven't been able to figure out yet, but I don't *think* it's from these AI changes.
Cheers,
Dilvish
p.s. I release this code under the GPL 2.0 license.
p.p.s. My "end of file" disconnections seem to be entirely linked in with the system design system -- I very frequently get disconnects upon game save after making new ship designs or deleting old ones. If I do the design changes immediately after loading a game file, I can then save the game & things seem to proceed fine. I'll try double checking if this could be tied to any typos in the revised ship files included above.
***revised files attached a few posts down***
You can drop the attached zip file in your "FreeOrion/default" folder (after backing up said folder please), and upon unpacking it should replace 3 of the text files related to ships (I only updated the english stringtable, so if you use a diff language there may be problems unless you port my stringtable changes), and will replace a few of the AI python files.
I've play-tested this a bit, but not as much testing as I'd planned, so definitely backup the default folder before unpacking.
That said, I'm pretty proud of these improvements; the seem to me to do a lot to making the game enjoyable for the strategy challenge rather than being more of a sandbox. I'm quite interested in hearing feedback & will try to be responsive if anyone has trouble with it. I have been getting a lot of "end of file" disconnects from the networking thread, lately that I haven't been able to figure out yet, but I don't *think* it's from these AI changes.
Cheers,
Dilvish
p.s. I release this code under the GPL 2.0 license.
p.p.s. My "end of file" disconnections seem to be entirely linked in with the system design system -- I very frequently get disconnects upon game save after making new ship designs or deleting old ones. If I do the design changes immediately after loading a game file, I can then save the game & things seem to proceed fine. I'll try double checking if this could be tied to any typos in the revised ship files included above.
Last edited by Dilvish on Sun Sep 23, 2012 9:20 am, edited 4 times in total.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
- eleazar
- Design & Graphics Lead Emeritus
- Posts: 3858
- Joined: Sat Sep 23, 2006 7:09 pm
- Location: USA — midwest
Re: First Pass at an AI upgrade
Sounds promising!
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: First Pass at an AI upgrade
Also, what version of FreeOrion are these changes written for?Geoff the Medio wrote:Be sure to note in your post that you release the changes under the GPL 2.0 or later.Dilvish wrote:Hi, I've been working on AI upgrades and am pretty pleased with them. I'll upload a zip file & make a separate post for it.
Re: First Pass at an AI upgrade
I believe I grabbed the trunk via SVN early morning of Sept 8. The changelog is dated 9/4/12 and says v0.4.1 + SVN -- If I go into svn I can see lots of revision numbers for files that have changed since then, but I'm not that famiar with SVN and I'm not sure how to more precisely identify the version I have.Geoff the Medio wrote:Also, what version of FreeOrion are these changes written for?Geoff the Medio wrote:Be sure to note in your post that you release the changes under the GPL 2.0 or later.Dilvish wrote:Hi, I've been working on AI upgrades and am pretty pleased with them. I'll upload a zip file & make a separate post for it.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: First Pass at an AI upgrade
You should make a separate thread about this. I doubt it's related to any changes you've made, and even if it is, it probably still shouldn't be happening.Dilvish wrote:p.p.s. My "end of file" disconnections seem to be entirely linked in with the system design system -- I very frequently get disconnects upon game save after making new ship designs or deleting old ones. If I do the design changes immediately after loading a game file, I can then save the game & things seem to proceed fine. I'll try double checking if this could be tied to any typos in the revised ship files included above.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: First Pass at an AI upgrade
A few requested changes:Dilvish wrote:Hi, I've made a number of changes to the AI that really help it be more challenging.
* Update SVN to the latest revision, so that your stringtable file has the additions since the version you based your changes on.
* Replace all tab characters with four spaces in changes you made.
Please resubmit with those changes...
Re: First Pass at an AI upgrade
Ok, I cleaned up the tabs that had slipped though before I changed my editor settings. In the review I also realized I had missed one of the changed ship text files, so that's cleared up also). I also fully updated my installation via SVN, merged my changes in, and confirmed that these all still seem to work fine with the current SVN version.Geoff the Medio wrote:A few requested changes:Dilvish wrote:Hi, I've made a number of changes to the AI that really help it be more challenging.
* Update SVN to the latest revision, so that your stringtable file has the additions since the version you based your changes on.
* Replace all tab characters with four spaces in changes you made.
Please resubmit with those changes...
Say, also, just to check -- rather than making a new ship description in the stringtable for every new ship build, in the premade ship designs file for some of the ship designs I specify the same description from the stringtable -- like the designs for SD_MARK_A8 and SD_MARK_A8B both refer to the same description SD_MARK8_DESC . It seemed that ought to work, & I was a bit lazy on the typing, but if the stringtable parser is expecting every ship name to also have an accompanying ship description then I could add the extras. It does seem to work fine, though since I'm having some issues with ship design interactions causing me some disconnects I'm wondering if this could be it. I guess I shouldn't be so lazy and just add the extra descriptions to be sure, but I want to play the game
edit: updated files with corrections mentioned below
- Attachments
-
- AI_upgrade.zip
- (100.56 KiB) Downloaded 73 times
Last edited by Dilvish on Sun Sep 23, 2012 8:18 pm, edited 1 time in total.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: First Pass at an AI upgrade
oh, btw, it seems that updating fully to the current SVN fixed the disconnect issues I was having, so it seems not have been related to my being miserly with ship descriptions.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: First Pass at an AI upgrade
You didn't do this correctly for the stringtable. Several strings are marked as being removed or other changes undone in your modified version when I compare with the latest SVN.Dilvish wrote:I also fully updated my installation via SVN, merged my changes in...
Re: using the same description string for multiple designs: That should be fine.
Are you rebuilding the executables from source after updating, or did you just update the content files and had it apparently stop disconnecting? Particularly if it was just content files, that's probably just a coincidence / random testing variation... If it is really just from the content files though, it'd be nice if you could isolate a process to reproduce it.oh, btw, it seems that updating fully to the current SVN fixed the disconnect issues I was having, so it seems not have been related to my being miserly with ship descriptions.
Re: First Pass at an AI upgrade
Ah, well, I did intentionally remove strings that I had superseded, such as SD_MARK1 --> SD_MARK_A1 since I believed the old strings are no longer used in the modified fileset. If that's a problem let me know and I can put those back. If there's something else I messed up with, please at least give an example to help me verify that I don't make the same mistake I made before.Geoff the Medio wrote:You didn't do this correctly for the stringtable. Several strings are marked as being removed or other changes undone in your modified version when I compare with the latest SVN.
I rebuilt the executables after updating; I don't think I made any other content changes between the period of having disconnections and no longer having disconnections.Geoff the Medio wrote:Are you rebuilding the executables from source after updating, or did you just update the content files and had it apparently stop disconnecting? Particularly if it was just content files, that's probably just a coincidence / random testing variation... If it is really just from the content files though, it'd be nice if you could isolate a process to reproduce it.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: First Pass at an AI upgrade
Whatever the cause for this issue is, it's not fixed in the latest SVN. I just ran a test game with Dilvish's updated AI and content scripts, and experienced a network disconnect (and consequent crash) around turn 95. I didn't have this particular problem before, so that might indicate that it's somehow related to the Dilvish's changes. Unfortunately I'm not able to reproduce the problem, reloading fixed it.Geoff the Medio wrote:Are you rebuilding the executables from source after updating, or did you just update the content files and had it apparently stop disconnecting? Particularly if it was just content files, that's probably just a coincidence / random testing variation... If it is really just from the content files though, it'd be nice if you could isolate a process to reproduce it.Dilvish wrote:oh, btw, it seems that updating fully to the current SVN fixed the disconnect issues I was having, so it seems not have been related to my being miserly with ship descriptions.
The improvements to the AI's performance are significant however. I'm delighted. Aside from the disconnect issues, I'd vote for committing these changes.
- eleazar
- Design & Graphics Lead Emeritus
- Posts: 3858
- Joined: Sat Sep 23, 2006 7:09 pm
- Location: USA — midwest
Re: First Pass at an AI upgrade
What happens if the some techs expected by the new AI script aren't present, or occur in a different order, or with new prerequisits?
Re: First Pass at an AI upgrade
An example:Dilvish wrote:...If there's something else I messed up with, please at least give an example to help me verify that I don't make the same mistake I made before.
eng_stringtable SVN r5258:
Code: Select all
...
BUILDING
Building
FIELD
Field
PASSED
<rgba 0 255 0 255>(PASSED)</rgba>
FAILED
<rgba 255 0 0 255>(FAILED)</rgba>
...
Code: Select all
...
BUILDING
Building
PASSED
<rgba 0 255 0 255>(PASSED)</rgba>
FAILED
<rgba 255 0 0 255>(FAILED)</rgba>
...
Another example:
eng_stringtable.txt SVN r5258:
Code: Select all
...
BLD_SHIPYARD_AST_DESC
'''This building is required for the production of all asteroid hulls and all further asteroid processor upgrades.
A massive processing plant dedicated to the purpose of hollowing out asteroids and preparing them to be used as ships' hulls. Asteroids thus prepared are sent to a shipyard in the same system, where they are turned into the final hull. This building can only be built on asteroid belts.'''
...
Code: Select all
...
BLD_SHIPYARD_AST_DESC
'''This is an upgrade to the Basic Shipyard and is required for the production of all asteroid hulls and all further asteroid hulls shipyard upgrades.
A shipyard dedicated to the purpose of hollowing out asteroids and using them as ships' hulls. It can only be built at an asteroid belt.'''
...
Obviously you've been working with an outdated working copy of this file, and didn't merge changes by later commits. I think that is what Geoff was referring to.
Aside from that, nice work with the AI!
Re: First Pass at an AI upgrade
As far as I can guess:eleazar wrote:What happens if the some techs expected by the new AI script aren't present, or occur in a different order, or with new prerequisits?
Not present: Will likely break the AI (because trying to enqueue a nonexistent tech probably results in an exception thrown, aborting the AI python script).
Different order: What exactly do you mean by that?
New prerequisites: Will more or less impact the AI's efficiency at researching (assuming Dilvish has optimized the order in which the techs are reserched), but otherwise things should continue to work, as prerequisites are queued automatically (as far as I know).
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: First Pass at an AI upgrade
It should just put an ERROR line in the AI log file if a nonexistent tech is ordered enqueued. See IssueEnqueueTechOrder in AIInterface.cpp.Vezzra wrote:Not present: Will likely break the AI (because trying to enqueue a nonexistent tech probably results in an exception thrown, aborting the AI python script).
I think that only happens in the human client; AIs need to explicitly enqueue every tech. If a prereq is missing, the dependent tech will just not receive any RP....prerequisites are queued automatically (as far as I know).