Sunday, April 13, 2014

More Interface Updates

After a lot of tinkering, I think I finally have the initial interface for the AI system. I've been building a simple example program.  Here's the main() function from that example program. You can get a general idea of the AI interface from it. I think it'll be quite simple to use.

int main()
 // create an initialize our map ---------------------------------------------
 Map game_map(64, 12);

 // Set up the entity Manager ------------------------------------------------
 EntityManager entity_manager;
 EntityControllerPlayer player(entity_manager.InsertEntity('P', game_map));

 // start the AI sytem
 sdp_rootai::AIEngineCreateParams desc;
 sdp_rootai::AIEngine *the_ai_engine;

 if(sdp_rootai::CreateAIEngine(desc, the_ai_engine) != sdp_rootai::AIResult_OK)
  PrintError("Unable to create the AI engine");
  return 0;

 // create the world
 sdp_rootai::AIWorldCreationParams world_desc;
 sdp_rootai::WORLD_HANDLE world_handle;
 if(the_ai_engine->CreateWorld(world_desc, world_handle) != sdp_rootai::AIResult_OK)
  PrintError("Unable to create the AI world");
  return 0;

 // create the AI agent
 sdp_rootai::AIAgentCreationParams agent_desc;
 sdp_rootai::AIAgent *aiagent;
 if(the_ai_engine->GetWorldByHandle(world_handle).CreateAgent(agent_desc, aiagent) != sdp_rootai::AIResult_OK)
  PrintError("Unable to create the AI agent");
  return 0;

 // add the AI entity
 EntityControllerAI enemy(entity_manager.InsertEntity('E', game_map), aiagent);

 // the game loop
  // send agent position data to the AI system
  // update the AI
  the_ai_engine->UpdateSystem(1000.0f / 60.0f);

  // clear the screen ---------------------------------------------------------

  // render the map

  // get results of AI update

  // update the enemy AI
  enemy.OnUpdate(entity_manager, game_map);

 } while (player.OnUpdate(entity_manager, game_map));

 return 0;