Computer Science Canada Tie game code not working in tictactoe |
Author: | goroyoshi [ Mon Apr 04, 2011 8:45 am ] | ||
Post subject: | Tie game code not working in tictactoe | ||
What is it you are trying to achieve? <I am trying to make a code that detects if there is a tie game but it keeps going off when only a few boxes are filled instead of all>
Please specify what version of Turing you are using <Answer Here> |
Author: | apython1992 [ Mon Apr 04, 2011 9:24 am ] | ||
Post subject: | RE:Tie game code not working in tictactoe | ||
I'm assuming this plethora of conditions is supposed to mean "The box is full". I'm not going to go through these conditions to verify that they are correct, because there are much better ways to do it. What is a much simpler way to know that the box is full? Of course, with a little bit of logic you can call it a tie before-hand (maybe this was what you were trying to do here), but even that could be implemented much more effectively. |
Author: | Zren [ Mon Apr 04, 2011 4:59 pm ] |
Post subject: | Re: Tie game code not working in tictactoe |
if boardIsFull() and noWinner() then tieGame() There is a maximum of 9 turns in a tic tac toe game is there not? |
Author: | RandomLetters [ Mon Apr 04, 2011 6:17 pm ] |
Post subject: | RE:Tie game code not working in tictactoe |
You haven't considered every possibility for tied games. There are at least 3 other arrangements which your code does not consider. I think you should either spend hours adding every possible tied arrangement, or think of another condition that would indicate the game is a tie, such as what Zren posted. |
Author: | goroyoshi [ Mon Apr 04, 2011 6:52 pm ] |
Post subject: | RE:Tie game code not working in tictactoe |
no randomletters, i got every combination, it checks if every box has one possibility or the other\ back to the question, shouldn't this work because its triggering if i do turn 1 (1, 2) turn 2 (2, 2) turn 3 (3, 2) tie |
Author: | apython1992 [ Mon Apr 04, 2011 6:57 pm ] |
Post subject: | RE:Tie game code not working in tictactoe |
If it should work, would you be asking about it on the forum right now? The much better solution would be just to count how many turns have been played without a winner. |
Author: | goroyoshi [ Mon Apr 04, 2011 7:00 pm ] |
Post subject: | RE:Tie game code not working in tictactoe |
i know but still IT SHOULD WORK AND IT'S NOT WORKING! |
Author: | Tony [ Mon Apr 04, 2011 7:06 pm ] |
Post subject: | Re: RE:Tie game code not working in tictactoe |
goroyoshi @ Mon Apr 04, 2011 7:00 pm wrote: IT SHOULD WORK AND IT'S NOT WORKING!
I don't believe that the Compiler is making any mistakes there. The code is doing exactly what you are asking it to do. |
Author: | Zren [ Mon Apr 04, 2011 8:01 pm ] | ||||
Post subject: | RE:Tie game code not working in tictactoe | ||||
It's because of boolean logic. if box (1) = 1 or box (1) = 2 and .... when player 1 choose (1,1), the logic is cut short since it's calculated like...
The whole statement could be fixed with a simple function...
|
Author: | goroyoshi [ Tue Apr 05, 2011 4:37 pm ] |
Post subject: | RE:Tie game code not working in tictactoe |
i fixed it now, realized my retarded mistake |