Computer Science Canada

Tic Tac Toe Help

Author:  Joy [ Thu Jan 08, 2015 11:02 am ]
Post subject:  Tic Tac Toe Help

What is it you are trying to achieve?

A simple tic tac toe game without advanced commands, and without using arrays. It is for grade 10 culminating assignment.


What is the problem you are having?

I can't figure out how to make this game without using arrays. I am having the biggest problem with starting it off as well.

Describe what you have tried to solve this problem

Just started.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)




[/syntax]

Please specify what version of Turing you are using

4.1

Author:  Insectoid [ Thu Jan 08, 2015 7:08 pm ]
Post subject:  RE:Tic Tac Toe Help

Quote:
A simple tic tac toe game without advanced commands, and without using arrays.


This is a seriously moronic restriction, but you can partially get around it by using strings in place of arrays. If you're not comfortable with strings, then that might cause a headache.

Fortunately, tic-tac-toe is a pretty simple game with only 9 tiles, so you can just write 9 variables to hold the game state. var topleft, topmiddle, topleft, middleleft, middlemiddle, etc. Now you can write a couple of functions that together can pretend to be an array. For example,
code:

function getVariable (int x, int y) : int
if x = 1 && y = 1 then
    result topleft
elsif x = 2 && y = 1 then
    result topmiddle
elsif... you get the idea
end getVariable


Write a similar function called 'setVariable' that accepts an x, y & a value and assigns that value to the proper variable and you can write the program just like you were using arrays.

Author:  Joy [ Thu Jan 15, 2015 9:21 am ]
Post subject:  RE:Tic Tac Toe Help

My instructor is expecting us to use simple code, because this a beginners class. Unfortunately, we haven't used functions either. Is there a way to do this using simple turing code? Thanks, you reply is very much appreciated.

Author:  Insectoid [ Thu Jan 15, 2015 10:24 am ]
Post subject:  RE:Tic Tac Toe Help

The simpler you try to make it, the harder it will be.

Author:  asdfasdf123 [ Thu Jan 15, 2015 11:40 am ]
Post subject:  Re: Tic Tac Toe Help

I made a fairly simple tic tac toe game a while ago. Hope this helps.

Author:  Joy [ Fri Jan 16, 2015 10:22 am ]
Post subject:  RE:Tic Tac Toe Help

This helps but it has to be user controlled. Maybe if statements and such? Im sorry, Im just really stuck and cant figure out how to do this Sad

Author:  Joy [ Fri Jan 16, 2015 10:50 am ]
Post subject:  Re: Tic Tac Toe Help

This is what I have so far, I cant figure out why the O's don't show up.


: