Alex Rivera | Logout

Which method should I use to give the perception the computer is thinking in programming?

Asked 2010-04-20T07:20:33.733
11

I want to create a simple game like tic tac toe where the human user is playing against the computer. The computer function takes a couple of milliseconds to run but I would like to give the perception of the computer taking 5 seconds to make a move. Which method should I use?

1) Create two memory threads. One for the computer and one for the human user. When the computer is taking 5 seconds to imitate thinking, the human user thread is paused for 5 seconds.

2) Disable input devices for 5 seconds using timer or dispatchertimer

3) Any better methods you can think of..

Thanks!

Edit - The question is about the how and now the why. 5 seconds is just an example. I prefer 1-2 seconds but for example purposes I just chose 5. So please focus on what is the best way to do this and not on the 5 seconds. Thanks again.

c#
Edit
Report

1 Answer

1

Two very important usability principles:

  • Don't block the UI thread! Only disable the game control so that the player cannot perform a step during the thinking.
  • Show a visual feedback to the user indicating the thinking and that he can't perform the step for a while.

And of course, balance the exact duration of thinking carefully. Treat the players' time as very precious.

answered 2010-04-20T21:09:25.753

Your Answer