AI:Development: Difference between revisions

From Spring
Jump to navigationJump to search
mNo edit summary
 
(11 intermediate revisions by the same user not shown)
Line 2: Line 2:


=How to write a Skirmish AI for Spring=
=How to write a Skirmish AI for Spring=
This section gives help on how to create Artificial Intelligence agents that control teams (as if a player) - "Skirmish AI".
The SpringRTS engine interacts with the Skirmish AIs through an "Interface". There are stable (10-2014, Spring v98) interfaces for the languages C/C++ and Java (not currently sure about the others but I think Lua too).


==Quick Start==
==Quick Start==
See these pages for tutorials on how to setup a development environment to start building AIs and how to build your first AI agent:
See these pages for tutorials on how to setup a development environment, connect to the appropriate "Interface" and how to build your first example Skirmish AI:


* '''[[AI:Development:Lang:Cpp|C++]]'''<br>
* '''[[AI:Development:Lang:C|C]]'''<br>
* '''[[AI:Development:Lang:Java|Java]]''' ''(up-to-date as of 10-2014, SpringRTS v98)''<br>
* '''[[AI:Development:Lang:Lua|Lua]]'''<br>
* '''[[AI:Development:Lang:Lua|Lua]]'''<br>
* '''[[AI:Development:Lang:C|C]]'''<br>
* '''[[AI:Development:Lang:Python|Python]]'''<br>
* '''[[AI:Development:Lang:Cpp|C++]]'''<br>
* '''[[AI:Development:Lang:CSharp|C#]]'''<br>
* '''[[AI:Development:Lang:CSharp|C#]]'''<br>
* '''[[AI:Development:Lang:Java|Java]]'''<br>
* '''[[AI:Development:Lang:Groovy|Groovy]]'''<br>
* '''[[AI:Development:Lang:Groovy|Groovy]]'''<br>
* '''[[AI:Development:Lang:Python|Python]]'''<br>
 


==I have setup my development environment. What now?==
==I have setup my development environment. What now?==


* '''[[AI:Skirmish:List|AIs for Spring]]''' - list of some of the AI agents that have already been developed for SpringRTS<br>
* '''[[AI:Development:System|SpringRTS <-> AIs architecture]]''' - architecture of SpringRTS and how it interacts with the AIs.
* '''[[AI:Links|AI related links]]''' - check that page for ideas ranging from how to conceptualize AI agents all the way down to how to tackle very specific problems like pathfinding<br>
* '''[[AI:Development:TheMaps|The mappings provided by the AI Interface]]''' - how the engine maps the game area and how the interface exposes those maps.
* '''[http://springrts.com/phpbb/viewforum.php?f=15 Springs AI dev forum]''' - comunity's forum dedicated to AI development<br>
* '''[[AI:Development:MonitorAndDebug|How to monitor and debug your Skirmish AI]]''' - How to monitor and debug your Skirmish AI.
* '''[[AI:Development:Interface|AI Interfaces & Wrappers]]''' - see a description of how the AI agents interact with SpringRTS engine<br>
* '''[[AI:Skirmish:List|AIs for Spring]]''' - list of some of the Skirmish AIs that have already been developed for SpringRTS.
* '''[[AI:Development:System|Introduction to Springs AI interface system]]''' - general explanation about Spring's AI API. Though, an AI dev does not have to know about this, and should just follow the link to his preffered language from the list above.<br>
 
 
==Overall AI ideas, practical examples, useful resources==


==Lua<-->AI communications [in Spring 0.83+]==
* '''[[AI:Links|AI related links]]''' - ranging from how to conceptualize AI agents all the way down to how to tackle very specific problems like pathfinding.
http://springrts.com/phpbb/viewtopic.php?f=15&t=26298
* '''[[AI:GameInferences|Useful inferences]]''' - how to infer where the opponents might have started, where on the maps can your units go, etc..
He shall only say it once!
* '''[http://springrts.com/phpbb/viewforum.php?f=15 Springs AI dev forum]''' - comunity's forum dedicated to AI development.
* '''[[AI:Development:Interface|AI Interfaces & Wrappers]]''' - semi-technical description of the Interfaces that expose the SpringRTS engine to the AI agents.
 
 
== Other hints, tips and interesting infos ==
 
*''' AI "frame skipping"'''
http://springrts.com/phpbb/viewtopic.php?p=463953#p463953<br>
As in: if a Java/C/C++ SkirmishAI gets delayed responding back to the Interface, the SpringRTS engine will wait on the AI. Thus delaying the game, thus not having the AI "skip" frames.


==AI "frame skipping"==
http://springrts.com/phpbb/viewtopic.php?f=15&t=24838&start=9


==Hints==
*''' Engine commands to control the AIs'''
In spring you have some control over AIs with these commands:
In spring you have some control over AIs with these commands:
<code><pre>
<code><pre>
Line 37: Line 50:
/aicontrol
/aicontrol
</pre></code>
</pre></code>
*''' Lua<-->AI communications [in Spring 0.83+]'''
http://springrts.com/phpbb/viewtopic.php?f=15&t=26298
He shall say that only it once!
*''' Link to source code of the Interface, engine-side'''
Chances are you'll have doubts about what exactly the commands abc(), qwe() or xyz() do. Asking in the AI forum is a good way to clarify. The most reliable is probably to look at the source code (if you're able to navigate the maze of C++ code in all its glory, that is):<br>
https://github.com/spring/spring/blob/develop/rts/ExternalAI/AICallback.h<br>
https://github.com/spring/spring/blob/develop/rts/ExternalAI/AICallback.cpp<br>


[[Category: AI Dev]]
[[Category: AI Dev]]

Latest revision as of 00:45, 23 October 2014

Development < AI Development

How to write a Skirmish AI for Spring

This section gives help on how to create Artificial Intelligence agents that control teams (as if a player) - "Skirmish AI".

The SpringRTS engine interacts with the Skirmish AIs through an "Interface". There are stable (10-2014, Spring v98) interfaces for the languages C/C++ and Java (not currently sure about the others but I think Lua too).


Quick Start

See these pages for tutorials on how to setup a development environment, connect to the appropriate "Interface" and how to build your first example Skirmish AI:


I have setup my development environment. What now?


Overall AI ideas, practical examples, useful resources

  • AI related links - ranging from how to conceptualize AI agents all the way down to how to tackle very specific problems like pathfinding.
  • Useful inferences - how to infer where the opponents might have started, where on the maps can your units go, etc..
  • Springs AI dev forum - comunity's forum dedicated to AI development.
  • AI Interfaces & Wrappers - semi-technical description of the Interfaces that expose the SpringRTS engine to the AI agents.


Other hints, tips and interesting infos

  • AI "frame skipping"

http://springrts.com/phpbb/viewtopic.php?p=463953#p463953
As in: if a Java/C/C++ SkirmishAI gets delayed responding back to the Interface, the SpringRTS engine will wait on the AI. Thus delaying the game, thus not having the AI "skip" frames.


  • Engine commands to control the AIs

In spring you have some control over AIs with these commands:

/aireload
/ailist
/aikill
/aicontrol


  • Lua<-->AI communications [in Spring 0.83+]

http://springrts.com/phpbb/viewtopic.php?f=15&t=26298 He shall say that only it once!


  • Link to source code of the Interface, engine-side

Chances are you'll have doubts about what exactly the commands abc(), qwe() or xyz() do. Asking in the AI forum is a good way to clarify. The most reliable is probably to look at the source code (if you're able to navigate the maze of C++ code in all its glory, that is):
https://github.com/spring/spring/blob/develop/rts/ExternalAI/AICallback.h
https://github.com/spring/spring/blob/develop/rts/ExternalAI/AICallback.cpp