0

I'm writing my first ever Android game.
It's a simple card game where player will have 3 BOT players.

Right now i'm writing a core logic for it in pure java. (Not thinking much about AndEngine and graphics yet)

The game has two phase:

  1. Initially all players would draw a match of card asynchronously
  2. After a first phase control moves serially (Synchronously) from one player to next one to draw a card.

So, i'm confused about how many threads would i need?

shall i put each player into a separate thread? (as phase 1 may need it)
OR
Or should i carry out this in one single thread? (as in Phase 2 synchronous behavior is needed)

If i put each player into different thread how can i serialize those threads to do sequential tasks (Phase 2- control move to player one after other)????

ALso
Right now the logic I'm writing is in pure java. Will it give me any trouble while configuring it with AndEngine?? I mean is there any specific format of handling inputs and using this logic in ANdEngine?? Its all about just calling methods of those classes to start game and to perform any operation on game.

Chaitanya Chandurkar
  • 2,142
  • 3
  • 24
  • 43
  • I can't see any reason to thread out BOT players drawing a hand of cards. – Geobits Oct 15 '12 at 15:34
  • if i didn't thread out BOT players to draw a hand of card, next players would have to wait until 1st BOT would complete its work and so on. Also in 1st phase User (non-bot) is also required to draw hand of card by himself (Touching the card area on screen). So non-BOT player should not wait to begin drawing hands of cards until BOTs complete their work. – Chaitanya Chandurkar Oct 15 '12 at 15:39
  • 1
    A bot player can draw a hand in a couple milliseconds, tops. The user won't be waiting on that. The added complexity of threadlocking the deck to make sure players' threads aren't interfering with each other is just not worth it. – Geobits Oct 15 '12 at 15:41
  • 1
    I do not see the need to thread out bots - the only reason for dedicating them their own threads is if they take up alot of time and 'block' your app and you think the speed gain would be worth the paralelism. You could still limit their 'thinking' or 'drawing card' time in one thread. – Shark Oct 15 '12 at 15:46
  • No its not going to consume any time as game itself is such that you don't have to think at all, all you have to do is snatch a random card from a player next to you. so yes i somewhat agree now that multithreading is not needed. :D thanks – Chaitanya Chandurkar Oct 15 '12 at 15:54
  • How about my 2nd question?? Using this pure java logic on android with andEngine.Its all about just calling methods from these classes to operate game. I hope i can use this java classes to work with andEngine. – Chaitanya Chandurkar Oct 15 '12 at 15:58
  • @bot rofl.. I won't be so rude ;) – Chaitanya Chandurkar Oct 16 '12 at 14:37

1 Answers1

3

I think Synchronous. If you think of a card game, you can't do anything until the previous player has made their move anyway.

If you start using separate threads you are just over-complicating things for yourself.

StuStirling
  • 15,601
  • 23
  • 93
  • 150