Re: How to maintain responsiveness during long functions?



On 24 Jun 1999 19:28:22 -0400, Ian Peters <itp@gnu.org> wrote:
>Hello,
>
>Recently, two people have sent me some very good reversi algorithms
>for inclusion into iagno.  Since many people have complained about the
>skill level of the computer players (very low), this is a good thing.
>However, obviously both algorithms need to spend a good bit of time
>thinking, and currently, this means that the game does not respond (ie
>menus, redraws, etc are not handled) until the computer makes its
>move.
>
>What is the `proper' way to handle this?  Is there any simple way to
>tell it to process any pending events at critical junctions in the
>algorithm

This should work:

	while(gtk_events_pending())
		gtk_main_iteration();

> or do I have to either restructure the algorithms to work through with the gtk event system

If you can find a way to do parts of the computation, save the state, and
restore it back to do more, then that's another possibility.

> or make the application threaded?

That'd be a last resort... I think the first option is probably the
easiest one to implement. The performance issues of the first vs. the
second might deserve a little thought.

-- Elliot
I really like iagno. It's the first game I can actually win.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]