Patch for AI #1
Moderator: Committer
Patch for AI #1
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
-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 128 times
Re: Patch for AI #1
Any objections why not to commit?
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: Patch for AI #1
I saw this, but haven't yet looked it over. I'll get to it soon.
Re: Patch for AI #1
Does this take fuel into account?
Re: Patch for AI #1
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).pd wrote:Does this take fuel into account?
- eleazar
- Design & Graphics Lead Emeritus
- Posts: 3858
- Joined: Sat Sep 23, 2006 7:09 pm
- Location: USA — midwest
Re: Patch for AI #1
generally, yes:It is always better to do a lot of patches than one huge(others can also participate) which may become absolete.
release early, release often.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: Patch for AI #1
Committed.
- The Silent One
- Graphics
- Posts: 1129
- Joined: Tue Jul 01, 2003 8:27 pm
Re: Patch for AI #1
pd wrote:Does this take fuel into account?
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).OndrejR wrote:Not yet. But I intend to do it in future.
If I provided any images, code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0.
Re: Patch for AI #1
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).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).
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.
- The Silent One
- Graphics
- Posts: 1129
- Joined: Tue Jul 01, 2003 8:27 pm
Re: Patch for AI #1
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.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.
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.
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.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.
Anyway, you seem to have insight into the involved intricacies, so I'm looking forward to what you'll create.
If I provided any images, code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0.
Re: Patch for AI #1
Don't you think about making fuel to be spended on ETA rather then starlanes?
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: Patch for AI #1
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.mZhura wrote:Don't you think about making fuel to be spended on ETA rather then starlanes?