FreeOrion

Forums for the FreeOrion project
It is currently Wed May 22, 2013 3:11 am

All times are UTC




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: AI how-to?
PostPosted: Fri Apr 13, 2012 9:31 am 
Offline
Space Dragon

Joined: Mon Aug 15, 2011 5:33 pm
Posts: 429
I read the Wiki page about Python AI and I don't understand a thing. Here's a request for a how-to primer on how to update the AI scripts.

-----------------
Is it possible to code something like:
1) if I discover a good planet, colonize it -> first priority
2) if I discover an adequate planet, colonize it -> second in priority

3) if I have Habitation Domes researched, build Outpost Ships instead of Colony Ships


Top
 Profile  
 
 Post subject: Re: AI how-to?
PostPosted: Fri Apr 13, 2012 10:03 am 
Offline
Programmer and Packager
User avatar

Joined: Wed Nov 16, 2011 12:56 pm
Posts: 766
Location: Sol III
Zireael wrote:
Is it possible to code something like:
1) if I discover a good planet, colonize it -> first priority
2) if I discover an adequate planet, colonize it -> second in priority

3) if I have Habitation Domes researched, build Outpost Ships instead of Colony Ships
Yep.

Python is a full blown programming language. You can code almost everything you want (performance might become an issue if the AI gets too complex), if you're skilled enough, this being probably the main constraint. AI programming isn't exactly novice stuff, developing a good AI certainly requires quite advanced programming skills.

Take a look at the current AI python scripts. This should give you an idea what and how it can be done.


Top
 Profile  
 
 Post subject: Re: AI how-to?
PostPosted: Fri Apr 13, 2012 4:22 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7891
Location: Vancouver, BC
The API wiki page is an API listing, not a programming tutorial. If you don't know how to write computer programs in general, and a bit about the Python language specifically, reading the FreeOrion AI Python API isn't going to help at all. In that case, you should start by reading some dedicated Python tutorials which can be found in many places online, including at python.org, or in most bookstores. If you do know a bit about programming in Python, then the API in the wiki should tell you how to access the gamestate and how to issue orders for the AI empire. It's then up to you to figure out what orders to issues based on the gamestate info the API provides.


Top
 Profile  
 
 Post subject: Re: AI how-to?
PostPosted: Fri Apr 13, 2012 5:00 pm 
Offline
Space Dragon

Joined: Mon Aug 15, 2011 5:33 pm
Posts: 429
I don't know a thing about programming, I was simply hoping it could be done (by someone better versed in programming) so that the AIs would be a little more active...


Top
 Profile  
 
 Post subject: Re: AI how-to?
PostPosted: Fri Apr 13, 2012 5:26 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7891
Location: Vancouver, BC
Zireael wrote:
I don't know a thing about programming, I was simply hoping it could be done (by someone better versed in programming) so that the AIs would be a little more active...
It could, if such a someone would like to do so.


Top
 Profile  
 
 Post subject: Re: AI how-to?
PostPosted: Sat Apr 14, 2012 12:14 pm 
Offline
Space Dragon

Joined: Mon Aug 15, 2011 5:33 pm
Posts: 429
Geoff the Medio wrote:
Zireael wrote:
I don't know a thing about programming, I was simply hoping it could be done (by someone better versed in programming) so that the AIs would be a little more active...
It could, if such a someone would like to do so.


As we have no hot-seat function to allow multiple people playing from a single computer, AI is the first thing that could be improved to make the game more enjoyable...


Top
 Profile  
 
 Post subject: Re: AI how-to?
PostPosted: Sat Apr 14, 2012 6:52 pm 
Offline
Programmer and Packager
User avatar

Joined: Wed Nov 16, 2011 12:56 pm
Posts: 766
Location: Sol III
Zireael wrote:
...As we have no hot-seat function to allow multiple people playing from a single computer, AI is the first thing that could be improved to make the game more enjoyable...
The problem is that this isn't really possible at the current stage of development. An AI that is even remotely able to provide a decent challenge to a human player has to be implemented as probably one of the last parts of a game. The reason is that such an AI has to be fine tuned to the game mechanics, and any change to the game mechanics or how things are balanced quickly renders any AI useless. Take for example the current changes to the food system: if we had a functional AI now, a major rewrite would have been necessary (actually, even the only partly implemented experimental AI we have ATM is probably severely affected by the recent changes).

The same applies to any but minor changes to the tech tree (which I suspect is going to be subject to major changes frequently in the future), ditto once game mechanics are added that make use of the trade resource, and so on.

I agree - having a decent AI would be really great, but unless you manage to recruit a team of some very dedicated AI programmers who wouldn't mind to reimplement the AI frequently until the game is sufficiently finished, I don't see how that could be done...


Top
 Profile  
 
 Post subject: Re: AI how-to?
PostPosted: Sun Apr 15, 2012 8:58 am 
Offline
Space Dragon

Joined: Mon Aug 15, 2011 5:33 pm
Posts: 429
Well, habitability wheel and outposts ships aren't likely to be changed, and making the AI colonize more would be a great step towards making the game more enjoyable.

I agree that a fine-tuned AI is not necessary now, however, one that is a bit more active - is...


Top
 Profile  
 
 Post subject: Re: AI how-to?
PostPosted: Sun Apr 15, 2012 1:59 pm 
Offline
Programmer and Packager
User avatar

Joined: Wed Nov 16, 2011 12:56 pm
Posts: 766
Location: Sol III
Zireael wrote:
Well, habitability wheel and outposts ships aren't likely to be changed, and making the AI colonize more would be a great step towards making the game more enjoyable.

I agree that a fine-tuned AI is not necessary now, however, one that is a bit more active - is...
Sure, it would be definitely better than what we have now, but don't expect any kind of real challenge from an AI like that. Furthermore, I suspect with the currently dramatically enhanced space monsters, most AI's will be crushed by the time you encounter them.

That said, it definitely wouldn't hurt to work on the AI scripts. Gray Area was doing that, but I haven't seen anything from him since shortly before the 0.4 release (IIRC). Until now no one has picked up where he left...


Top
 Profile  
 
 Post subject: Re: AI how-to?
PostPosted: Sun Apr 15, 2012 4:27 pm 
Offline
Space Dragon

Joined: Mon Aug 15, 2011 5:33 pm
Posts: 429
Well, I don't want challenge, I just want to see AI that at least tries to colonize a bit. The monsters are a different cup of cake. 'Sides, you can play with 'Never' in the monster frequency and that'd allow me to test the colonizing AI :P


Top
 Profile  
 
 Post subject: Re: AI how-to?
PostPosted: Sun Apr 15, 2012 5:19 pm 
Offline
Design & Graphics Lead
User avatar

Joined: Sat Sep 23, 2006 7:09 pm
Posts: 3693
Location: USA — midwest
If somebody wants to improve the Ai, nobody will stop them.

There just aren't that many people who can.

_________________
—• Read this First before posting Game Design Ideas!
—• Design Philosophy

—•— My Ideas, Organized —•— Get an Avatar —•— Acronyms —•—


Top
 Profile  
 
 Post subject: Re: AI how-to?
PostPosted: Wed May 09, 2012 10:47 pm 
Offline
Space Krill

Joined: Wed May 09, 2012 9:57 pm
Posts: 1
Hi All,

I have only just stumbled across this project today!

Massive MOO/space 4x fan.

I'm going to be away for a few months, but I'm planning to learn the mechanics for the game as implemented at the moment, and then get to grips with working on the AI.
I have a background in python development, so in theory I should be able to understand how it works. In theory, if the AI is broken down into enough modules, you should be able to simply change the "weights" assigned to AI actions, in order to change it's behaviour under a new food model for instance.

No promises, but I'm looking forward to getting to grips with it.


Top
 Profile  
 
 Post subject: Re: AI how-to?
PostPosted: Wed May 09, 2012 11:03 pm 
Offline
Designer and Programmer
User avatar

Joined: Tue Aug 14, 2007 6:33 pm
Posts: 1771
Location: Orion
TinBane wrote:
Hi All,

I have only just stumbled across this project today!

Massive MOO/space 4x fan.

I'm going to be away for a few months, but I'm planning to learn the mechanics for the game as implemented at the moment, and then get to grips with working on the AI.
I have a background in python development, so in theory I should be able to understand how it works. In theory, if the AI is broken down into enough modules, you should be able to simply change the "weights" assigned to AI actions, in order to change it's behaviour under a new food model for instance.

No promises, but I'm looking forward to getting to grips with it.

Welcome. More contributors are always appreciated.

I would be careful about the AI however - significant changes such as eliminating a resource, as we have with food, will probably require more than just changing some weights to account for, regardless, since anything referencing that resource or the meters that produce it will need to be changed. Theoretically though, if the AI was adequately modular, that should really only be one "module", which would then communicate the priority of that particular resource to other "modules" which would use that information to enqueue techs, buildings, etc, which could be designed to be agnostic towards the types of resources that actually exist.

So yeah, being modular, with each module being as agnostic as possible with respect to content, I think, is going to be the key to making an AI that doesn't have to be completely redone every time a change is made.

_________________
Warning: Antarans in dimensional portal are closer than they appear.


Top
 Profile  
 
 Post subject: Re: AI how-to?
PostPosted: Fri May 11, 2012 8:17 pm 
Offline
Space Floater
User avatar

Joined: Fri Jun 11, 2010 9:10 pm
Posts: 29
Vezzra wrote:
... Furthermore, I suspect with the currently dramatically enhanced space monsters, most AI's will be crushed by the time you encounter them ...


Hmmm....

Would it be possible to dial-back the space-monsters?
Or maybe set them to "go easy on" the AI races?

By default, that is. Make it so you have to turn UP the monsters to get the real "RAWRRR" factor... :wink:

This would, I think, make FO more-approachable and more "fun" (and improve the quality of feedback?) from casual players and n00bs ... :D

Currently, I'm playing WITHOUT space monsters, so the 3rd & later-encountered AI's are fairly widely dispersed by the time I encounter them... :mrgreen:


Top
 Profile  
 
 Post subject: Re: AI how-to?
PostPosted: Sat May 12, 2012 2:41 am 
Offline
Designer and Programmer
User avatar

Joined: Tue Aug 14, 2007 6:33 pm
Posts: 1771
Location: Orion
Steve wrote:
Hmmm....

Would it be possible to dial-back the space-monsters?
Or maybe set them to "go easy on" the AI races?

By default, that is. Make it so you have to turn UP the monsters to get the real "RAWRRR" factor... :wink:

This would, I think, make FO more-approachable and more "fun" (and improve the quality of feedback?) from casual players and n00bs ... :D

Currently, I'm playing WITHOUT space monsters, so the 3rd & later-encountered AI's are fairly widely dispersed by the time I encounter them... :mrgreen:

It would be possible to scale them back, certainly, but it would defeat the purpose of having them. Any space monsters that are powerful enough to actually provide a challenge to the player are probably going to be powerful enough to destroy the current AI. I'm planning on making many techs increase resource production based on infrastructure instead of population and attempt to introduce a dichotomy between growth and construction. The only way to test if it's actually beneficial for the player to choose one or the other instead of researching both is to have an opponent that is dangerous enough to actually defeat the player, which at the moment, can't possibly be the AI.

The uber death space monsters that appear after turn 200 or so are definitely temporary, but I'm actually pretty happy with the strength of the other space monsters as is, though perhaps the higher level ones could use an increase in attack power. The trouble is that the level 3 monsters can potentially show up too early to really be fair (and also, it's more exciting to see a Great Kraken if they're actually rare and don't show up until late game).

_________________
Warning: Antarans in dimensional portal are closer than they appear.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group