0

hey I'm writing an android app to play a simple card game (Dutch Blitz) I have a simple algorithm already made but I was wondering if I needed to run AI's as a new Thread or somehow integrate it into the main thread, or if anyone else has some good idea's I would love to hear them...

thanks for any ideas!

ziggystar
  • 28,410
  • 9
  • 72
  • 124
Darrellii
  • 47
  • 1
  • 6
  • This is a very broad question. Please be more specific. – Burkhard Nov 28 '12 at 06:59
  • The answer would depend on your implementation. For example, if the game is played where each player takes a turn and the algorithm doesn't take long to complete, you could just have the AI run on the main logic thread after each time the player goes. If there are turns and part of the game is playing as quickly as possible, you might want the AI to have its own thread to do its thinking. – Kevin Nov 28 '12 at 07:10

2 Answers2

2

Yes as this is very simple card game you can either use main thread for AI or else use a separate thread for it. Both will show the same performance as the logic of AI would not be so complex :)

Ali Imran
  • 8,927
  • 3
  • 39
  • 50
  • okay i thought so! thanks for advice, i have it as separate threads now and i'm ending up with allot of problems so i think i'll switch to the main thread. as far as logic of the AI goes i think i got that down! thanks for the advice!! :) – Darrellii Dec 04 '12 at 23:42
0

I'd never use a main thread for AI evaluations, I don't know this game "dutch blitz" but you have to remember that on the weakest smartphone out there, if your algorithme just has a small chance to near itself to 5 (probably more like 4) seconds(blocking the ui thread), then your application will be closed.
So asynctask is where you should do such a thing.

Anders Metnik
  • 6,096
  • 7
  • 40
  • 79