AI programming

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

Moderator: Committer

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

Re: AI programming

#31 Post by The Silent One »

freereign wrote:Okay, I had this bookmarked before, and now I can't find it. What variable sets a planet's primary and secondary focus? (WOW its been along time since I've been on here.
This is what you are looking for (AIInterface.cpp):

Code: Select all

int IssueChangeFocusOrder(int planet_id, FocusType focus_type, bool primary)
Not sure how to determine what focus a planet currently has, though... it probably has not been exposed to python yet. Anyway, if you want to code AI modules, it will help you a lot if you familiarise yourself with AIInterface.cpp (in fo/AI) as well as all .cpp files in fo/python. Are you working on resource management? Keep us informed, please!
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: 12802
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: AI programming

#32 Post by Geoff the Medio »

The Silent One wrote:Not sure how to determine what focus a planet currently has, though... it probably has not been exposed to python yet.
Planet is a ResourceCenter, and ResourceCenter has properties exposed to python "primaryFocus" and "secondaryFocus" that return the enum focusType, which as values "balanced", "farming", "industry", "mining", "research", and "trade".

freereign
Space Squid
Posts: 53
Joined: Wed Mar 19, 2008 4:40 pm

Re: AI programming

#33 Post by freereign »

Thanks. I have been working my way through the python interface, somehow I missed that command though. And yes I am working on Resource AI.
MoO: Darloks Rule!
MoO2: Custom Darloks Rule!
MoO3: Dunno cuz I'm a cheapskate

freereign
Space Squid
Posts: 53
Joined: Wed Mar 19, 2008 4:40 pm

Re: AI programming

#34 Post by freereign »

Unfortunately, something has happened that means I will be able to do next to no work on anything for the next two months or so. I have attached what I have done on it (which is pretty awful right now) if anyone else wants to work on it, please do. If not, I will pick it back up when I can.
Attachments
ResourceAI.py.zip
Really bad and incomplete resource script. Needs tons of work.
(1.27 KiB) Downloaded 75 times
MoO: Darloks Rule!
MoO2: Custom Darloks Rule!
MoO3: Dunno cuz I'm a cheapskate

Post Reply