Using GLUT for a science project
Hi,
I'm having some trouble trying to work out how to display a simulation run at each step using GLUT.
I'm trying to evolve a neural network that will guide a bot towards a target.
I've tried to put my simulation code within the display function but that runs through the simulation and does not display the world until the _end_ of the simulation.
My simulation loop is like this
Actually, I guess this is an animation problem. At the moment I've been starting at this neural network code for ages and my brain is a bit fried. So may be it's something very simple that I'm missing
Thanks in advance for any help!
Anthony
I'm having some trouble trying to work out how to display a simulation run at each step using GLUT.
I'm trying to evolve a neural network that will guide a bot towards a target.
I've tried to put my simulation code within the display function but that runs through the simulation and does not display the world until the _end_ of the simulation.
My simulation loop is like this
Code:
for (i = 0; i < EXPERIMENT_LOOPS; i++)
{
for (j = 0; j < TRIAL_LOOPS; j++)
{
for (k = 0; k < NUM_BOTS; k++)
{
pass world info to bot[k]'s neural network
update bot[k] position based on neural network's output
[b][i]I'd like to then draw the bot[k] at new position[/i][/b]
}
}
// trial run is over
run the genetic algorithm
// reset loop counter
j = 0
}Actually, I guess this is an animation problem. At the moment I've been starting at this neural network code for ages and my brain is a bit fried. So may be it's something very simple that I'm missing

Thanks in advance for any help!
Anthony
You should structure your code like this:
Use glutIdleFunc to set idle as your idle function.
Code:
int experimentCounter = 0;
int trialCounter = 0;
void idle(void) { glutPostRedisplay(); }
void display(void) {
/* update bots, draw them */
glutSwapBuffers();
++trialCounter;
if (trialCounter == TRIAL_LOOPS) {
trialCounter = 0;
++experimentCounter;
}
}Use glutIdleFunc to set idle as your idle function.
If you want an evolving Neural Network you may use the ART Neural Network, find the algorithm and implement it into your code.

