Game algorithms

Hello,

I am new to the Panda3d and I wish to computerise a boardgame. It has four distinct steps which are repeated ad nauseum until the game ends.

initiative
move
combat
resolve

The obvious solution is to throw this into an infinite loop and have events trap keyboard commands to escape and quit but everything I have read suggests that this is a baaaaad idea with Panda as it is event driven.

I can obviously create an event for the move step but the others are not so obvious how I would handle those so that they all happen in a sequence. I generally dislike asking for code samples, but this kind of thing HAS to have been done already. Can anyone suggest, or provide a solution, as to how I use panda to simulate the infinite loop that a board game would be run by?

Or perhaps throw it all inside of the move event so that when the mouse is clicked, it rerolls initiative, then the move event does it’s graphical thing. A crosshair is displayed to select a target, firing happens, and then, resolve the outcome. All within the move event…

Cheers!
-Caolan O’Domhnaill

Hi Caolan, welcome to the forums. One way to handle what you are describing is to look at tasks:
Tasks .
Tasks allow you to execute a function each frame.
You can create and use a task as a loop to handle all your game logic.
Please read more about them within the manual by clicking the link.

Also, look into finite state machines, which sound like a perfect fit for describing the different game states and the transitions between them.