FreeOrion

Forums for the FreeOrion project
It is currently Fri May 24, 2013 7:44 pm

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Patch for AI #1
PostPosted: Mon Feb 23, 2009 12:35 am 
Offline
Space Dragon
User avatar

Joined: Thu Oct 02, 2008 11:00 pm
Posts: 339
Location: Slovakia
I created patch for AI:
-fixed problem with exploring new stars with AI scouts after game load
-added new functions for PythonUniverseWrapper.cpp
-fixed TODO syntax
-moved explorable systems from ExplorationAI to AIState from TODO work, later it will be reused from ColonizationAI and others
-preparation for Fog of war
-removing some unnecessary free space


Attachments:
AI_1.zip [5.51 KiB]
Downloaded 74 times
Top
 Profile  
 
 Post subject: Re: Patch for AI #1
PostPosted: Tue Feb 24, 2009 4:50 pm 
Offline
Space Dragon
User avatar

Joined: Thu Oct 02, 2008 11:00 pm
Posts: 339
Location: Slovakia
Any objections why not to commit?


Top
 Profile  
 
 Post subject: Re: Patch for AI #1
PostPosted: Tue Feb 24, 2009 4:59 pm 
Online
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7898
Location: Vancouver, BC
I saw this, but haven't yet looked it over. I'll get to it soon.


Top
 Profile  
 
 Post subject: Re: Patch for AI #1
PostPosted: Tue Feb 24, 2009 5:56 pm 
Offline
Graphics Lead Emeritus
User avatar

Joined: Mon Mar 08, 2004 6:17 pm
Posts: 1933
Location: 52°16'N 10°31'E
Does this take fuel into account?


Top
 Profile  
 
 Post subject: Re: Patch for AI #1
PostPosted: Tue Feb 24, 2009 6:04 pm 
Offline
Space Dragon
User avatar

Joined: Thu Oct 02, 2008 11:00 pm
Posts: 339
Location: Slovakia
pd wrote:
Does this take fuel into account?

Not yet. But I intend to do it in future. This will be series of AI patches(when I have free time and motivation to do something for FO). It is always better to do a lot of patches than one huge(others can also participate) which may become absolete. But in this patch there is only solved problem after saving and loading game(then AI scouts do absolutely nothing, when game is not saved and loaded, then scout run out of fuel).


Top
 Profile  
 
 Post subject: Re: Patch for AI #1
PostPosted: Tue Feb 24, 2009 9:54 pm 
Offline
Design & Graphics Lead
User avatar

Joined: Sat Sep 23, 2006 7:09 pm
Posts: 3693
Location: USA — midwest
Quote:
It is always better to do a lot of patches than one huge(others can also participate) which may become absolete.


generally, yes:
release early, release often.

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

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


Top
 Profile  
 
 Post subject: Re: Patch for AI #1
PostPosted: Wed Feb 25, 2009 2:54 am 
Online
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7898
Location: Vancouver, BC
Committed.


Top
 Profile  
 
 Post subject: Re: Patch for AI #1
PostPosted: Wed Feb 25, 2009 8:55 am 
Offline
Graphics
User avatar

Joined: Tue Jul 01, 2003 8:27 pm
Posts: 395
Location: Würzburg, Germany
pd wrote:
Does this take fuel into account?

OndrejR wrote:
Not yet. But I intend to do it in future.

To avoid that the AI's ships run out of fuel the AI would best be able to stack fleet actions (e.g. send scout to system A to refuel, then send to system B to explore). Since order stacking is not being supported by the main code yet, it would have to be coded within the AI code. I quickly browsed through the AI interface and everything required seems to be exposed (fleet.fuel and maxFuel, universe.leastJumpsPath).


Top
 Profile  
 
 Post subject: Re: Patch for AI #1
PostPosted: Wed Feb 25, 2009 11:27 am 
Offline
Space Dragon
User avatar

Joined: Thu Oct 02, 2008 11:00 pm
Posts: 339
Location: Slovakia
The Silent One wrote:
To avoid that the AI's ships run out of fuel the AI would best be able to stack fleet actions (e.g. send scout to system A to refuel, then send to system B to explore). Since order stacking is not being supported by the main code yet, it would have to be coded within the AI code. I quickly browsed through the AI interface and everything required seems to be exposed (fleet.fuel and maxFuel, universe.leastJumpsPath).


It's no so simple. There is also need for distance between systems and better function is ShortestPath. We don't want path with least jumps, but with least distance. And there is also problem with supply range. In the supply range there is no need to take fuel into consideration, but in out of supply area AI need this information(from fleetSupplyableSystems from PythonEmpireWrapper.cpp).

And there is also another problem - if system A leads only to system B and system B leads to only A and C, then explore B means also explore system C with same scout(these problems are resolved by graph theory). For additional info see book Graph Theory by Reinhard Diestel. In graph theory this problem is named Hamiltonian path.

Problem is also with enemy systems - system A leads to B and D, B leads to A and C, C leads to B and D. System B is enemy system and distance from A to D is large. Also another graph theory problem(Dijkstra algorithm is in boost and it is function ShortestPath, but this function doesn't solve problem because all systems are connected graph). Probably some Python graph theory library will be required.

I am trying to say that all these AI problem only seems simple. They aren't. But to solve them we must begin with simple things and later solve all difficulties.


Top
 Profile  
 
 Post subject: Re: Patch for AI #1
PostPosted: Wed Feb 25, 2009 1:03 pm 
Offline
Graphics
User avatar

Joined: Tue Jul 01, 2003 8:27 pm
Posts: 395
Location: Würzburg, Germany
OndrejR wrote:
I am trying to say that all these AI problem only seems simple. They aren't. But to solve them we must begin with simple things and later solve all difficulties.
I certainly agree that this will not be a simple task. My intention was to point out where might be a good point to start (implementing the ability to stack fleet orders), not an in-depth analysis of the galaxy map AI code.
The main trouble I ran into when writing the few bits of AI that are there now was that some methods had not been exposed to python (although Geoff helped quickly), so I wanted to check for you if the very basics are there, that's all.

OndrejR wrote:
There is also need for distance between systems and better function is ShortestPath. We don't want path with least jumps, but with least distance.
As fuel usage currently equals star lane jumps, leastJumpsPath will return the most fuel-efficient path rather than ShortestPath. The latter could be used when enough fuel is at hand and speed is essential, e.g. within supply range, but if the question is if a ship can visit a star system and return to a supply point, leastJumpsPath should be the way to go.

Anyway, you seem to have insight into the involved intricacies, so I'm looking forward to what you'll create.


Top
 Profile  
 
 Post subject: Re: Patch for AI #1
PostPosted: Tue Sep 29, 2009 8:45 pm 
Offline
Space Kraken

Joined: Sun Sep 27, 2009 10:51 am
Posts: 162
Location: Moskow, RU
Don't you think about making fuel to be spended on ETA rather then starlanes?


Top
 Profile  
 
 Post subject: Re: Patch for AI #1
PostPosted: Tue Sep 29, 2009 9:15 pm 
Online
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7898
Location: Vancouver, BC
mZhura wrote:
Don't you think about making fuel to be spended on ETA rather then starlanes?

It's not clear what you're suggesting or asking, but if it was about making fuel costs depend on distance travelled, yes it was considered, but we chose instead to make fuel consumption depend on number of starlane jumps.


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

All times are UTC


Who is online

Users browsing this forum: Dilvish 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