Programming Question that has me stumped

Paradox1

Fully Optimized
Messages
2,913
I am currently making a simple (or so it seemed before I began) Tic Tac Toe Program because we have no more assignments anymore lol My teacher ran out of curriculum for us

Anyways, I have it set up, you can play a game, if you get three in a row you win and all, but the only thing is... you can overwrite the other players selection. (P1 picks top left, top left becomes X; P2 then picks top left, top left becomes O)





My idea is set the variables unchangable after a certain number of changes, in this case 1 change (until a given situation resetting it{the end of the game})


I'll take any advice I can get to make it work, I've been doing this for fun for some time prety much out of boredom, If you have an idea different from mine I'd like to hear it.
 
wow, it's been really long since I've done any programming. I've forgot everything! lol

Out of curiousity, what language are you using? I've only ever had experience with PASCAL.
 
keep an array:

gameinfo(0 to 2, 0 to 2, 0 to 1) as long

gameinfo(x,y,0) = (x,y) location used ( boolean [ 1 | 0 ] )
gameinfo(x,y,1) = (x,y) player mark, if gameinfo(x,y,0) is set

thats what it would look like ( somewhat - the part of that says what the array element is equal to is not really code ) in vb6
 
Could have sworn I said what language it was in =\ oh well, thanks for the replies, It's in C++ .NET
 
Sorry for double post, But I really need an answer for this thing =\

I dont see how an array could help anything. What I want to do is basically make a temporary constant (after topleft is initialized to X it becomes constant until a given action (end of the game, reseting it to " ")

but i dont know how to say that in code
 
Ok, what i would do is set a flag on each of the 9 squares, say, square 1 = 0 , square 2 = 0 etc all the way to 9, then when a square is clicked, set the flag of that square to 1.

Now, before you can click on a square, put all the clicking code which puts a x down under an if statement saying - if square 1 = 0 then (do the click) otherwise do nothing, as its already got something it?!
 
its console based, And the source code was too long to post (7 header files, 1 source, each around 2-5 pages long)

anyways, I got it working by saying if top left was selected and if top left did not = marker 1, and if top left did not = marker 2 then it would be applied as whoever was marking it.

then left an else at the end saying that it was either already selected, or the selection was not valid
 
Back
Top Bottom