Computer Science Canada Cointoss Game Help |
Author: | nelsonkkyy [ Wed Nov 04, 2009 8:04 pm ] | ||
Post subject: | Cointoss Game Help | ||
What is it you are trying to achieve? I am making a coin toss game. First, the coin toss three times and 2 people are playing.For each player they have to choose 3 times (Like,Head,tail,head {HTH}).To win this game, who get the most correct of sides and that is the winner. What is the problem you are having? <Now i am stuck in the last part which is how to deciede who is the winner. Can anyone help me?> Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) <Answer Here>
Please specify what version of Turing you are using <Answer Here> |
Author: | Superskull85 [ Wed Nov 04, 2009 9:54 pm ] |
Post subject: | RE:Cointoss Game Help |
Well you could add the outcomes together and check for different situations. If the total is equal to (1 * 3) (if all of the outcomes were heads) than whoever chose heads wins. If the total is equal to (2 * 3) (if all of the outcome were tails) than whoever chose tails wins. For the other two possibilities (1, 1, 2) or (1, 2, 2), in any order, the total would be 4 and 5 respectively. If the first two possibilities are false than check if the total is evenly divisible by 2. If it is, than whoever chose heads wins. If it isn't, than whoever chose tails wins. This method only works for three outcomes. However, you could extend it to include any odd amount of outcomes. If you want to include an even amount of outcomes, you will have to include a check for the possibility of getting the same amount of heads as tails. |