Second Pass on AI
Moderator: Committer
Second Pass on AI
Hi, well I did another revamp of the AI. It manages its fleets a fair bit more intelligently now & should do a much better job of defense and be able to put up decent resistance for longer than before. I had also hoped to work in some improved colonization, but I think I should toss this over while Vezzra is still around to (hopefully) work it into a pre-packaged build for the Windows users.
In updating to the current head and making sure this is all compatible, I just now saw the implementation of Rebels, etc. Hopefully my next pass can have some improved invasion planning to cope with Rebels, as well as better colonization. I'll also get around to planning some better ships for the AIs at the higher end of the tech chain, as it stands now they get stuck with upper-mid-tier ships.
Feedback of any kind is always welcome.
p.s. oh yeah, released under GPL 2.0
In updating to the current head and making sure this is all compatible, I just now saw the implementation of Rebels, etc. Hopefully my next pass can have some improved invasion planning to cope with Rebels, as well as better colonization. I'll also get around to planning some better ships for the AIs at the higher end of the tech chain, as it stands now they get stuck with upper-mid-tier ships.
Feedback of any kind is always welcome.
p.s. oh yeah, released under GPL 2.0
- Attachments
-
- AI_upgrade3.zip
- (61.45 KiB) Downloaded 58 times
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: Second Pass on AI
Rebels stuff isn't finished yet, but also shouldn't yet have any impact on the game, as long as nothing modifies the rebel troops meter. Properly implementing rebels will require a bunch of content changes, perhaps including a "suppress rebels" focus or similar, and ways to determine how many rebel troops should be present, including various modifiers to happiness, and some way for a planet to know whether it should have rebellions at all (which recently captured planets should more often than an empires self-colonized planets)... So, for the short term, don't worry about it for the AI.Dilvish wrote:I just now saw the implementation of Rebels, etc. Hopefully my next pass can have some improved invasion planning to cope with Rebels...
Re: Second Pass on AI
Done. I've committed your update to SVN, the new test builds already have these changes incorporated.Dilvish wrote:...but I think I should toss this over while Vezzra is still around to (hopefully) work it into a pre-packaged build for the Windows users...
I had to fix two things:
1.) The PythonEmpireWrapper.cpp you provided had the following statement on line 69:
Code: Select all
typedef typename std::pair<int, int> IntPair;
2.) The debug print statement on line 61 in ProductionAI.py:
Code: Select all
print " " + str(buildingType.name) + " cost:" + str(buildingType.productionCost) + " time:" + str(buildingType.productionTime)
Code: Select all
2012-10-15 20:10:22,548 ERROR AI : Traceback (most recent call last):
2012-10-15 20:10:22,548 ERROR AI : File "/Users/.../SoftwareProjekte/FO/release/FreeOrion/Xcode/build/Test/FreeOrion.app/Contents/Resources/default/AI/FreeOrionAI.py", line 233, in generateOrders
2012-10-15 20:10:22,549 ERROR AI : ProductionAI.generateProductionOrders()
2012-10-15 20:10:22,549 ERROR AI : File "/Users/.../SoftwareProjekte/FO/release/FreeOrion/Xcode/build/Test/FreeOrion.app/Contents/Resources/default/AI/ProductionAI.py", line 61, in generateProductionOrders
2012-10-15 20:10:22,549 ERROR AI : print " " + str(buildingType.name) + " cost:" + str(buildingType.productionCost) + " time:" + str(buildingType.productionTime)
2012-10-15 20:10:22,549 ERROR AI : Boost.Python.ArgumentError: Python argument types in
2012-10-15 20:10:22,549 ERROR AI : None.None(buildingType)
2012-10-15 20:10:22,549 ERROR AI : did not match C++ signature:
2012-10-15 20:10:22,549 ERROR AI : None(BuildingType {lvalue}, int, int)
Anyway, I was able to solve this issue by commenting out everything after "str(buildingType.name)".
Re: Second Pass on AI
yeah, I see that building type production cost and time now require an empireID and locationID. The odd thing is that even taking that into account I haven't yet (in the 10 minutes I've been looking at it) been able to get the call to work.
It's especially odd because just a few lines above, I can successfully make a different call thats always had empireID and location ID:
fo.getBuildingType(bldTID).canBeProduced(empire.empireID, homeworld.id)
but trying to call
buildingType = fo.getBuildingType(buildingTypeID)
buildingType.productionCost(empire.empireID, homeworld.id)
fails
I'll keep looking at it, though it's not critical, currently the AI doesn't take that info into account, it was just for debugging purposes.
It's especially odd because just a few lines above, I can successfully make a different call thats always had empireID and location ID:
fo.getBuildingType(bldTID).canBeProduced(empire.empireID, homeworld.id)
but trying to call
buildingType = fo.getBuildingType(buildingTypeID)
buildingType.productionCost(empire.empireID, homeworld.id)
fails
I'll keep looking at it, though it's not critical, currently the AI doesn't take that info into account, it was just for debugging purposes.
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: Second Pass on AI
The problem is that productionTime and productionCost are exposed as properties, not functions, so there's probably no way they'll work. I was just about to attempt to fix it by exposing as functions, and adding a default case (using the capital and the AI player's empire id) as a property.Dilvish wrote:yeah, I see that building type production cost and time now require an empireID and locationID. The odd thing is that even taking that into account I haven't yet (in the 10 minutes I've been looking at it) been able to get the call to work.
Re: Second Pass on AI
Oh yes, good catch Geoff, that's exactly it. I just changed the ".add_property" for those to ".def" , recompiled and tried the calls again as above and they work just fine.
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: Second Pass on AI
Should I not bother with the default case properties then?Dilvish wrote:I just changed the ".add_property" for those to ".def" , recompiled and tried the calls again as above and they work just fine.
Re: Second Pass on AI
right, here's a new version of univerwrapper with just those 2 lines changed, let's just go with that.
I should also note, I can see that this new AI round still needs a fair bit of tuning It had a number of important new hooks in the various wrappers, though, that I really wanted to get submitted before the code changes I was making got to be too much of a headache to merge with the ones Geoff was making. I think once I get the new python scripting routines tuned well, it will be a substantial improvement; I'll try to get that done as soon as possible.
I should also note, I can see that this new AI round still needs a fair bit of tuning It had a number of important new hooks in the various wrappers, though, that I really wanted to get submitted before the code changes I was making got to be too much of a headache to merge with the ones Geoff was making. I think once I get the new python scripting routines tuned well, it will be a substantial improvement; I'll try to get that done as soon as possible.
- Attachments
-
- PythonUniverseWrapper.cpp
- (34.71 KiB) Downloaded 53 times
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: Second Pass on AI
Your work and quickness in the AI is very much appreciated.Dilvish wrote:...I'll try to get that done as soon as possible.
However, don't let it become an obligation that's no longer fun.
I'd rather you work at a slower, sustainable pace, and stick around for the long haul rather than feel like feel like you need to work at a certain rate, and eventually burn out your enjoyment in working on the project. Choose the pace that you want, but don't worry that we've started to frown at you because updates, corrections, etc aren't swiftly made.
Re: Second Pass on AI
Thanks for the kind words. Here's a couple more tweaks to the AI.
- Attachments
-
- AI_upgrade3.1.zip
- (6.38 KiB) Downloaded 49 times
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: Second Pass on AI
FYI, an upcoming commit will require similar changes to how tech, ship part, ship hull, and ship design production / research costs and time are accessed from Python.Dilvish wrote:Here's a couple more tweaks to the AI.
Re: Second Pass on AI
Ok, I'll keep that in mind. Perhaps as a failsafe I'll try to work in a bunch of
try:
current
except:
new
calls for all those things, it will be usable during your testing and wont be broken immediately upon update
try:
current
except:
new
calls for all those things, it will be usable during your testing and wont be broken immediately upon update
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: Second Pass on AI
The update has already happened, so if you're building the latest svn, the try/except shouldn't be necessary.Dilvish wrote:...it will be usable during your testing and wont be broken immediately upon update
Re: Second Pass on AI
Ah, no, hmm. I thought I had gotten fully up to date earlier today, but must have been before your changes went in, I certainly see a fair number of files needing update now. For some reason my IDE stopped showing me when files need updating & I have to check a different tool, need to look up how to fix that.Geoff the Medio wrote:The update has already happened, so if you're building the latest svn, the try/except shouldn't be necessary.Dilvish wrote:...it will be usable during your testing and wont be broken immediately upon update
Anyways, if there's not default versions like we considered earlier, compatible with the previous calls, then the AI is likely crippled - I'll double check & try to get changes in soon if needed.
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: Second Pass on AI
I didn't add any.Dilvish wrote:Anyways, if there's not default versions like we considered earlier, compatible with the previous calls...