research AI

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Post Reply
Message
Author
m_k
Space Floater
Posts: 33
Joined: Wed Mar 12, 2008 10:54 am
Location: Aachen, Germany

research AI

#1 Post by m_k »

I'm finally done with the first working version, so here are some results:

The approach I took is similar to the one here, using the general idea the silent one described, implemented using the algorithm I added. There are some parts that aren't quite finished yet, for simplicity the current demands are just the different tech categories, and their values are static, and the value of each tech is just determined by the type, (I figured refinements are probably the most desireable, because they need no additional investments, followed by applications and lastly theories, whose values only lie in the techs they unlock) and their costs and research time (currently unnoticeable, but I've done tests changing the techs.txt)

Given the nature of the research AI, I have no graphical proof that it works, but there is enough output to the log to see whats going on. Interestingly with all techs at 1 RP/ 1 turn, the last tech gets researched at the end of turn 15, which is nearly optimal, considering there are 131 techs, so it is only one turn of.
I've already found some things I'd like to change, but for now this version is definitively working so I thought I'd get some opinions first.

By the way, is it possible to make the TechManager class visible to python, since I haven't found a way to access the names of unresearched techs and had to include them manually as a list extracted from techs.txt. Also I am missing a function like the totalSpent for the production queue, the equivalent exists in the c++ code, but isn't included in PythonEmpireWrapper.cpp.

So, could someone tell me all the things I did wrong :wink: , correct them and upload the file to the svn (and add import statement and function call to FreeOrionAI.py)?
Attachments
ResearchAI.zip
(2.67 KiB) Downloaded 98 times

User avatar
The Silent One
Graphics
Posts: 1129
Joined: Tue Jul 01, 2003 8:27 pm

Re: research AI

#2 Post by The Silent One »

Nice. I'll look into this some time next week.
If I provided any images, code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: research AI

#3 Post by Geoff the Medio »

m_k wrote:By the way, is it possible to make the TechManager class visible to python, since I haven't found a way to access the names of unresearched techs and had to include them manually as a list extracted from techs.txt. Also I am missing a function like the totalSpent for the production queue, the equivalent exists in the c++ code, but isn't included in PythonEmpireWrapper.cpp.
http://freeorion.svn.sourceforge.net/vi ... threv=2416

m_k
Space Floater
Posts: 33
Joined: Wed Mar 12, 2008 10:54 am
Location: Aachen, Germany

Re: research AI

#4 Post by m_k »

Geoff the Medio wrote:
m_k wrote:By the way, is it possible to make the TechManager class visible to python, since I haven't found a way to access the names of unresearched techs and had to include them manually as a list extracted from techs.txt. Also I am missing a function like the totalSpent for the production queue, the equivalent exists in the c++ code, but isn't included in PythonEmpireWrapper.cpp.
http://freeorion.svn.sourceforge.net/vi ... threv=2416
Thanks, but I seem to be missing something, since it is in the same scope as for example getTech, I try to call the function the same way, but calling fo.techs() just gets me:

Code: Select all

2008-03-23 12:50:55,421 DEBUG AI : Traceback (most recent call last):
2008-03-23 12:50:55,421 DEBUG AI :   File "C:\Dokumente und Einstellungen\Eins\Desktop\FreeOrion_SDK\FreeOrion\default\AI\FreeOrionAI.py", line 91, in generateOrders
2008-03-23 12:50:55,421 DEBUG AI :     ResearchAI.generateResearchOrders()
2008-03-23 12:50:55,421 DEBUG AI :   File "C:\Dokumente und Einstellungen\Eins\Desktop\FreeOrion_SDK\FreeOrion\default\AI\ResearchAI.py", line 14, in generateResearchOrders
2008-03-23 12:50:55,421 DEBUG AI :     technames = fo.techs()
2008-03-23 12:50:55,421 DEBUG AI : Boost.Python.ArgumentError: Python argument types in
2008-03-23 12:50:55,421 DEBUG AI :     freeOrionAIInterface.techs()
2008-03-23 12:50:55,421 DEBUG AI : did not match C++ signature:
2008-03-23 12:50:55,421 DEBUG AI :     techs(class TechManager {lvalue})
Is this an actual bug or am I just calling the function in the wrong way.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: research AI

#5 Post by Geoff the Medio »

m_k wrote:Is this an actual bug or am I just calling the function in the wrong way.
It's a bug... I'm trying to call a member function like it was static or a free function. The TechManager::TechNames functions need a TechManager pointer passed to function properly. I'll whip up some boost::bind to deal with it...

Edit: Try again with the latest SVN please...

Post Reply