AI:Development:Lang:Cpp: Difference between revisions

From Spring
Jump to navigationJump to search
Af (talk | contribs)
No edit summary
Abma (talk | contribs)
 
(7 intermediate revisions by 2 users not shown)
Line 3: Line 3:
=Writing a Skirmish AI in C++=
=Writing a Skirmish AI in C++=


There are two ways of writing a C++ AI, using the [[AIWrapper:LegacyCpp| deprecated legacy API]] or the [[AIWrapper:Cpp| C++ Wrapper API]]. The legacy API is for older AIs using the old interface ( e.g. KAI, RAI, AAI etc ).
There are two ways of writing a C++ AI, using the [[AIWrapper:LegacyCpp| deprecated legacy API]] or the [[AIWrapper:Cpp| C++ Wrapper API]]. The legacy API is used for AIs using the old interface ( e.g. KAI, RAI, AAI etc ).


For an example of an AI using the new OO C++ Wrapper interface, refer to Shard by AF.
For an example of an AI using the new OO C++ Wrapper interface, refer to [[AI:Shard|Shard]] by AF.


For further info, have a look at the forum.
For further info, have a look at the forum: http://springrts.com/phpbb/viewtopic.php?p=552433#p552433


[[Category: AI]]
==Start off==
[[Category: Development]]
 
easiest is to copy the existing CpptestAI to a new folder:
 
<code><pre>cp -rv AI/Skirmish/CppTestAI/* AI/Skirmish/myAI/ </pre></code>
 
adjust AI/Skirmish/myAI/cont/data/AIInfo.lua, for example change "value  = 'CppTestAI'", "to 'myAI'".
 
==Compile==
 
run cmake again in the root of the spring source to make the buildsystem recoginize the newly created folder:
<code><pre>cmake .</pre></code>
 
To create the needed interface files run:
 
<code><pre>make Cpp-AIWrapper</pre></code>
 
for each AI there exists such an target, for example:
 
<code><pre>make myAI</pre></code>
 
to list all available targets run
 
<code><pre>make help</pre></code>
 
 
[[Category: AI Dev]]

Latest revision as of 13:53, 31 January 2014

Development < AI Development < C++ AI Development

Writing a Skirmish AI in C++

There are two ways of writing a C++ AI, using the deprecated legacy API or the C++ Wrapper API. The legacy API is used for AIs using the old interface ( e.g. KAI, RAI, AAI etc ).

For an example of an AI using the new OO C++ Wrapper interface, refer to Shard by AF.

For further info, have a look at the forum: http://springrts.com/phpbb/viewtopic.php?p=552433#p552433

Start off

easiest is to copy the existing CpptestAI to a new folder:

cp -rv AI/Skirmish/CppTestAI/* AI/Skirmish/myAI/ 

adjust AI/Skirmish/myAI/cont/data/AIInfo.lua, for example change "value = 'CppTestAI'", "to 'myAI'".

Compile

run cmake again in the root of the spring source to make the buildsystem recoginize the newly created folder:

cmake .

To create the needed interface files run:

make Cpp-AIWrapper

for each AI there exists such an target, for example:

make myAI

to list all available targets run

make help