libgdx / gdx-ai

Artificial Intelligence framework for games based on libGDX or not. Features: Steering Behaviors, Formation Motion, Pathfinding, Behavior Trees and Finite State Machines
Apache License 2.0
1.18k stars 241 forks source link

Why is the MessageDispatcher's delay in seconds ? #71

Closed JonathanGeoffroy closed 7 years ago

JonathanGeoffroy commented 7 years ago

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 ?

davebaol commented 7 years ago

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.

JonathanGeoffroy commented 7 years ago

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 ?

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.

davebaol commented 7 years ago

ok