Advertisement

Duel of the Planeswalkers AI/Engine Architecture Question

Started by September 10, 2013 07:40 AM
2 comments, last by flyslasher 11 years, 5 months ago

Hi

I've been working on my own TCG and found a link an article discussing the Duel of the Planeswalkers AI.

http://www.wizards.com/Magic/Magazine/Article.aspx?x=mtg/daily/feature/44

I really liked the concept of an instanced-based engine for each AI which can basically "simulate" turns. I re-wrote a lot of my engine in an attempt to get a similar setup. From the article, each computer player has an AI with it's own copy of a game instance. However, in trying to implement this, I am not sure how to isolate the player list, AI, and engine to prevent circular references during initialization of the engine.

For example if I have the following class structure

class cGameEngine

{

cPlayer* _plrList;

}

class cPlayer

{

cAI* _ai;

}

class cAI

{

cGameEngine* _engInstance;

}

1) When the game engine instance is created, it will create a copy of the player list.

2) Each NPC player will create an AI.

3) Each AI will create another game engine instance copy.

4) This game engine instance copy will create another copied player list, and the cycle will continue....

Where is the best place to break this circularity?

?Thanks in advance for any input!

Why do you need to make a copy of the game engine instance? Pass down a reference to the game engine.

Advertisement

Unfortunately I can't, as the premise of the "instanced"-based engine is the ability manipulate a copy of the engine to simulate player turns, combat targets, actions, etc (all in a separate thread) and not having it affect the game the player sees.

Well you can do the copying of the player list in a function rather than in the constructor and only call that function for the original game engine, not the AI copies.

Also wouldn't you need a more specialized AI version of the game engine? Assuming that the game engine deals with player input, rendering, etc.. you don't need to have all that aswell. The AI, in the case of a card game, would only really need stats about the cards in play and other various aspects just relating to the card and gameplay element. It makes more sense to me atleast. Either through inheritance, class cAIEngine : public cGameEngine, or a class that just retrieves relative information from the game engine.

This topic is closed to new replies.

Advertisement