Logo
Spacer News Wiki Features F.A.Q. Team members Screenshots Download Messageboard Bug tracker Submit files
Top divider

Greenai

greenai is the first groupAI developed for Nanoblobs. I picked Nanoblobs because it has a small number of units, and KAIBLOB kicked my ass so I figured I could use some help.

[edit] Info

  • Status : 0.01
  • Compatible mods : Nanoblobs
  • Playability : builds 500 knights in 6k frames
  • Limitations : Only works for nanoblobs, and sometimes you need to assign a group of units a different group to get them to execute commands.


Here is how I accomplished some basic tasks.

[edit] Get started.

1. Get an IDE and compiler. I got the current windows only source code build, grabbed the free M$ visual studio package, the platform SDK, and put it on a spare box I had. The IDE requires some setup , and I hope to lay out step by step how you can get it to work at a later date, it is quite frustrating if you havn't done it before.

2. I found what I though was a suitable bit of code to help me get started with, the metal maker AI.

3. Studied the file structure, if you are unfamiliar with c this can be non-trivial. The main files you need are in the vcproj file, the ones you will be editing are:

  • TestAI.cpp This file defines the functions that Spring uses to connect to the .dll. If you keep the main AI class the same name, you should not have to modify it.
  • TestAI.h
  • GroupAI.cpp everythign goes in here for the most part
  • GroupAI.h

4. Take a look at how GroupAI works. This can be done by looking at the header file for the main components. Lets take a look and see what they do. For now i'm going to pretend you know the difference between a header .h file and a .cpp file.

[edit] Functions and Data

  • CGroupAI()
    • this is the constructor for the groupAI object
  • virtual ~CGroupAI()
    • this is the destructor, if you dont' know what these first 2 do you need to read up on C OO
  • virtual void InitAi(IGroupAICallback* callback)
    • this is the first thing that happense to the object, when it is created you add stuff here and it is the first bit of code run.
  • virtual bool AddUnit(int unit)
    • this is called when you add units to your groupAI, or your groupAI adds units to itself.
  • virtual void RemoveUnit(int unit)
    • this removes units from your group... kinda self descriptive arn't they
  • virtual void GiveCommand(Command* c)
    • i havn't played with this one yet, but I think this is for group commands
  • virtual const vector<CommandDescription>

Retrieved from "http://spring.clan-sy.com/wiki/Greenai"

This page has been accessed 2,304 times. This page was last modified 21:22, 12 April 2007.