Way to execute code while drawing??

Started by
14 comments, last by geez 20 years ago
crap, no html for APs :/
Advertisement
quote:
I have a game with several entities involved & I use seperate threads to run each of the enemy entity''s AI modules. It actually removed some bad timing issues in the game & there are nifty ways you can threads. For instance, my entities all run a path-finding routine that can take quite a while even though its optimized. So what was happening was that on the frame where they need to find a new path you would see a small pause... cus that AI module had to run. So instead of running the whole AI module in just 1 frame each time the entity had to make a decision or chance direction, I would run it in a thread & the entity would only update when it finished. That way it spread the computation out over several frames. I do it a little differently, but thats the easiest way to explain it.



thats a good example
Ok, hmm, let me tell you what my project is, so maybe you can help me better on which procedure to take. Im coding a chess game. My graphical interface is done : i can click and move the pieces on the board and i have to respect all the movements and the rules of the game. Now i would like to create a computer opponent, i dont want it to be a master undefeatable computer, but just to think that if he moves his piece to that place he can loose it. That can take a while to determine considering that he must look over all the movements possibilities and create a table of possible movements he can make. That cant be done between two frame, (the clock will stop running for example), i already made a dos version and that can take from 5sec up to 10sec "thinking" and building that table. So, if i want my clock and my animations to keep on moving i need another way : like thinking in background which could be done with threads right? ( im coding in c++ using VS .net with opengl libs and NEHE base code )
You got it

I suggust programming some sort of foreward processing algorithm; that is you build tables while your opponent is moving. The trick is to make it efficient.
AH HA... you are coding an AI for a perfect information turn-based game. that is one of the specialties... you probably want to give the computer opponent more look-ahead than just 1 move & you can probably even give each piece a score, so that instead of just looking ahead a couple moves for whether or not he wins or loses... he could look ahead a few moves & just take the move that would maximize his score. (say 1 point for a pawn & 2 for a rook, & 3 for a queen, etc...)
If you are not familiar with such a program... let me know, & I will post something very useful tonight when I get home.
FYI - I won the AI competition at Purdue University in 2003.
Heh, i could certainly use ur help. Now that my multithread problem is resolved, im getting into AI . But I have a question actually if u could help me out: its how to give the movement a score?? maybe if he eats some1 else without beeing eaten back that would give him like +2 or to protect another piece +1 etc?? And im thinking about giving the choice to the player to choose the level of the comp: level 1, 2, 3.... which means, lets say his choice was lvl 1: the comp will play random moves, lvl 2: he makes all of is possible movements, then create a table of best moves, (looks 1 move ahead), lvl 3: he moves one of his possible movement, looks at all the possible movement the player can make, then pass on to his other possible movements, and so on... (looks 2 move ahead), lvl 4: moves his first possible movement, create the player''s possible movements, play the player''s first possible movement, create a table of score, passe on to the player''s second possible movement, update the table of score, third, fourth etc., then go back to the start then move his second possible movement, and here we go again... (looks 3 move ahead). And i think Im gonna stop there, because the player will make his move then come back tomorrow to find out that the comp is still thinking. Is this the best way to do so? I know that normal chess games just have a database of pro''s best moves, and they select the best one thatll fit into the game. But that''ll be too complicated for me, since i dont have that kind of database.

AI is the futur. :O)

This topic is closed to new replies.

Advertisement