libgdx/gdx-ai

Why is the MessageDispatcher's delay in seconds ?

JonathanGeoffroy opened this issue · 3 comments

According to the documentation, the MessageDispatcher can delay the message. The delay is always given in seconds.

However, some games could use another piece of time. For example, on turn-based game, time can be expressed in turns, not in seconds. So we could send a message in 3 turns for example.

Is there any reason to force the delay in seconds ? Could gdx-ai provide a more "generic way" to delay a message ?

You can use immediate messages to implement turn based games.
For instance, at the end of the turn a player might send a message to the next player.

You're absolutely right: you can give a message to the next player by sending an immediate message.
But in my mind, you should also send a message to tell players that an event will arrived in 5 turns.

The fact is each game could have it own definition of what is time, and how it spent. So lets take another example: simulation games (or more specifically City-building game for this example).

Imagine a game where, for each industry in your city, you'll win 1 gold every piece of time (example: every 4 seconds). Now what if you want manage the city speed ?

  • If you double the city speed, you would like you're message arrive earlier (in the example, every 2 seconds), but you have to divide the delay by 2 for every future messages ... Moreover, messages has already waiting, so you can't change there delay !
  • if you pause the city, message should be stopped ...

In this example, managing delay is simpler if you master how the time is spent : you don't have to change all messages delay, but just the MessageDispatcher ; I'm sure there are many examples where strategy would be simpler to write if you master it ...

By the way, my needs is maybe too specific ? I can try to create a generic MessageDispatcher that fit my needs ; would you mind if I send you a Gist if I succeed ? This is maybe the best way to make my speech understandable.

Regards.

ok