Persistent ai_interface

Discussion of all aspects of the game engine, including development of new and existing features.

Moderators: Forum Moderators, Developers

Post Reply
mihoshi
Posts: 52
Joined: February 16th, 2008, 10:18 pm

Persistent ai_interface

Post by mihoshi »

Now Ai instance is created every move for every side. That's not very convinient - it's hard for AI to memorize past moves and it has to initialize all the way each time.
So, I propose to do this way.
Very simple, just one method more.

Code: Select all

class ai
{
  static ai* start(char* past);
  char* stop();
  void play_turn(info& turn_info);
};
Method start(char* past) with null argument returns an instance of ai. Generally one instance per team should be used, but ideally ai should be able to act if it is one instance per game, or one instance per turn, etc. Different instances should act completely independent.

play_turn(info& turn_info) do nearly same is now is done with "new ai_something(info)->play_turn()" - reads unfi about current situation and gives commands.

char* past() releases instance of ai and returns a string (if you prefer, it can be config& instead of char*) with serialized info that ai wants to remember. It should be stored in save file in separate tag, and when game is reloaded, it should be passed as argement to start(char* past) method. If ai implements this methods, it should serialize only that info that this instance was receiving by play_turn methods.

Also, ai_memory should be removed from team.

Post Reply