Author |
Message |
yuvan
|
Posted: Mon May 20, 2013 4:19 pm Post subject: Turing TIC TAC TOE: Need help with storing my variables |
|
|
What is it you are trying to achieve?
I am trying to recreate a two player tic tac toe using turing.
What is the problem you are having?
I have everything done, except that my pragram can`t declare a winner. To this this I believe I need to store where my players are going, but I can`t seem to figure out how. Sorry if what I am saying doesn't make any sense because I am new to programming.
Describe what you have tried to solve this problem
I have tried using a for loop using the "i" to call on an array, but it didn't work.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
<Add your code here>
|
Please specify what version of Turing you are using
<Answer Here>
Description: |
|
Download |
Filename: |
tic_tac_toe.t |
Filesize: |
1.6 KB |
Downloaded: |
137 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Nathan4102
|
Posted: Mon May 20, 2013 4:56 pm Post subject: Re: Turing TIC TAC TOE: Need help with storing my variables |
|
|
I broke it!
To get a winner, after every move, you need to be checking to see if anyone has gotten 3 in a row. Do you know how to do this?
|
|
|
|
|
|
yuvan
|
Posted: Mon May 20, 2013 5:01 pm Post subject: RE:Turing TIC TAC TOE: Need help with storing my variables |
|
|
umm no to check if someone has three in a row I need to store some variables...
|
|
|
|
|
|
Insectoid
|
Posted: Mon May 20, 2013 5:48 pm Post subject: RE:Turing TIC TAC TOE: Need help with storing my variables |
|
|
@Nathan- try to read OP's entire post before you reply. Quote: I have everything done, except that my pragram can`t declare a winner.
@OP- you could use a 2D array of integers. If player 2 picks the spot (1,2), then array(1)(2) = 2. If player 1 picks (2,0), then array(2)(0) = 1. You can then check through the array to see if there's a row of 3.
|
|
|
|
|
|
yuvan
|
Posted: Tue May 21, 2013 3:11 pm Post subject: RE:Turing TIC TAC TOE: Need help with storing my variables |
|
|
I was hoping to do something like that, but how can I make sure my program know that the player has picked the spot?
|
|
|
|
|
|
Insectoid
|
Posted: Tue May 21, 2013 4:00 pm Post subject: RE:Turing TIC TAC TOE: Need help with storing my variables |
|
|
You can set the whole array to 0 at first. If array(x)(y) = 0 then the spot hasn't been picked yet.
|
|
|
|
|
|
yuvan
|
Posted: Tue May 21, 2013 4:46 pm Post subject: RE:Turing TIC TAC TOE: Need help with storing my variables |
|
|
Nathan that is easily fixed by removing the put statement.
|
|
|
|
|
|
yuvan
|
Posted: Tue May 21, 2013 4:47 pm Post subject: RE:Turing TIC TAC TOE: Need help with storing my variables |
|
|
Okay but can you please show me an example using a bit of my code, I am so confused.
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
storm2713687
|
Posted: Wed May 22, 2013 8:27 pm Post subject: Re: Turing TIC TAC TOE: Need help with storing my variables |
|
|
I'm not sure how you made your Tic Tac Toe game, but you can do it something like this (You can make it X or O, but I'll use X):
code: |
if square 1 = "X" && square 2 = "X" && square 3 = "X" then
X player wins
else
O player wins
end if
|
Just seeing the picture above, it's not a text based Tic Tac Toe game, but that should still help, hopefully
|
|
|
|
|
|
|