IT Community - Software Programming, Web Development and Technical Support

Determining who's turn it is

This is a discussion on Determining who's turn it is within the Java Programming forums, part of the Software Development category; I'm just wondering what strategy you would use to determine what players turn it is in a game with ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > Java Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 02-23-2007, 09:49 AM
pranky pranky is offline
D-Web Programmer
 
Join Date: Feb 2007
Posts: 51
pranky is on a distinguished road
Default Determining who's turn it is

I'm just wondering what strategy you would use to determine what players turn it is in a game with more than two people. For two players I would just have a value increase after each player went then use the remainder operator to determine if the number is even or odd, if it is even player 1's turn, if its odd, player 2's turn...something like this

Code:

if(count % 2 == 0){
//player 1's turn
} else {
//player 2's turn
}

but I'm not sure what strategy i should use with, say a game with 4 players, any ideas?

Edit:
Other than manually coding, because there is infinity moves and I cant code that many lines, something like this is unreasonable imo

if count = 0
//player 1
else if count = 1
//player 2
else if count = 2
//player 3
else if count = 3
//player 4
else if count = 4
//player 1
else if count = 5
//player 2

and so on indefinitely
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you turn off cookies for one page in your site in asp .net? H2o ASP and ASP.NET Programming 1 07-20-2007 02:49 AM
Determining Midlet Launches jeyaprakash.c Mobile Software Development 0 05-07-2007 08:31 AM


All times are GMT -7. The time now is 10:58 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0