
-----------------------------------
yuvan
Mon May 20, 2013 4:19 pm

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)








Please specify what version of Turing you are using


-----------------------------------
Nathan4102
Mon May 20, 2013 4:56 pm

Re: Turing TIC TAC TOE: Need help with storing my variables
-----------------------------------
I broke it!

http://i0.simplest-image-hosting.net/picture/untitled349.png

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
Mon May 20, 2013 5:01 pm

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
Mon May 20, 2013 5:48 pm

RE:Turing TIC TAC TOE: Need help with storing my variables
-----------------------------------
@Nathan- try to read OP's entire post before you reply. 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
Tue May 21, 2013 3:11 pm

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
Tue May 21, 2013 4:00 pm

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
Tue May 21, 2013 4:46 pm

RE:Turing TIC TAC TOE: Need help with storing my variables
-----------------------------------
Nathan that is easily fixed by removing the put statement.

-----------------------------------
yuvan
Tue May 21, 2013 4:47 pm

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.

-----------------------------------
storm2713687
Wed May 22, 2013 8:27 pm

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
[/code]
Just seeing the picture above, it's not a text based Tic Tac Toe game, but that should still help, hopefully :)
