Refreshing, delay &amp; timing issue.

As my first simple game, I'm making an OpenGL and GLUT program where the player uses the arrow keys to move a multi-colored block around the screen avoiding another (AI) block. The bot is simple, and will increase or decrease his own x & y position in an attempt to match yours.

Basically, the necessities (like the main loop with the GLUT stuff), most of the display stuff, the screen collision and the input are done. The AI also works. Too well, that's the problem.

First, the yellow square would only move when you moved your square. I quickly realized this was because I had only placed a glutPostRedisplay(); command in my input loop and not the AI one. So I added one after all the bot if statements. The bot square simply didn't appear, so instead I put it at the end of ALL the possible bot calculations, or after the AI call in the display loop. The bot now moves much too fast because he can do so every cycle.

I could just say it's "turn based" and he only moves after you do, but that seems like the lazy man's way out.

I just need some kind of timer, or perhaps I'm putting my sync/refresh commands in the wrong places?