Author Topic: News from the AI Modularization Branch  (Read 2281 times)

0 Members and 1 Guest are viewing this topic.

Offline Fabian

  • AI Code Modulator
    Temporal Mechanic
  • 25
News from the AI Modularization Branch
Hey,

I now have the AI modularization branch so far, that its usable and working.

The best new thing is dynamic loading of the chosen AI implementation via a dynamic library.

This means I can change the AI code, click into my freespace window, select restart mission and its starting with my new AI :-). (under linux that is, under windows, you'd probably need to change the name in the AI Profile as well)

A new AI implementation that is just hooking into the init_ship_info function could look like:

Code: [Select]
#include "ai/aibig.h"
#include "ai/aigoals.h"
#include "ai/aiinternal.h"

struct aicode_call_table AICodeNewAITable;

void newai_aicode_init_ship_info()
{
        fprintf(stderr, "Init ship info was called\n");
        AICodeDefaultTable.init_ship_info();
}

extern "C" {
        void ai_module_init();
}

void ai_module_init()
{
   
        fprintf(stderr, "ai_module_init() called\n");
 
        // First make a copy
        memcpy(&AICodeNewAITable, &AICodeDefaultTable, sizeof(AICodeNewAITable));

        // Now set up our overridden functions 

        aicode_table = &AICodeNewAITable;
        aicode_table->init_ship_info=newai_aicode_init_ship_info;
}

I will probably change the ai_module_init later to be <dllname>_ai_module_init, because like that you could also compile a static version into the binary and use that if no library is available.

Quote
AND theproblem with wingmen ignoring friendly ships in-between them and their target?

Anyway, I also looked into this AI behavior and at least when they are standing still the AI is never ever firing on a "same team" ship. It always chooses a vector, which is not hitting a friendly ship.

Are there other AI related issues at hand known?

Best Wishes,

Fabian

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: News from the AI Modularization Branch
I saw the commit on this a couple of minutes ago. Excellent work Fabian. :yes:
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

  

Offline Fabian

  • AI Code Modulator
    Temporal Mechanic
  • 25
Re: News from the AI Modularization Branch
I saw the commit on this a couple of minutes ago. Excellent work Fabian. :yes:

Thanks, I now changed it so that one or more AIs can be built-in statically as well via the same mechanism, but you can override it with a library file if you want.

I also added doxygen docs ;-).

That means: Updates of AI / Testing new AIs independent of the program. :-)

Best Wishes,

Fabian