sweetandy
2006.05.27, 11:24 AM
I was bored in Math class, so what did I do? Cracked open the Prgm function on my calculator and started experimenting. It didn't take long for me to get an idea for Tic Tac Toe, even though I haven't done too much coding.
My question here is basically, what do you think of the efficiency of this coding structure, and what do you think about porting the idea to something like ObjC / Cocoa in a universal binary? Is that possible with this setup?
Draw TTT board and surroundings
Set variables A-I to 0
// Thinking behind that:
// ABC
// DEF <--- TTT board
// GHI
GetX:
If winning combonation (ABC, DEF, GHI, ADG, BEH, etc.) multiplied together = 8
goto WinO
// It checks for the O winner in the X loop because that's where it goes after
// drawing the third O and setting the variable to 2.
Get an input key > N
// I used 1-9 on my calc for the TTT game board.
If N=7 and A=0
goto XdrawA
// Checks for A=0, b/c that means nobody has played A yet.
etc., etc.
GetO:
If winning combonation multiplied together = 1
goto WinX
// X is stored as 1, so the three multiplied together equals 1 if they are all X.
If all numbers A-I are bigger than 1
goto WinCat
//If all positions have been played but no winner has been found
// (leading to O being the next to play), then the cat has won.
If N=7 and A=0
goto OdrawA
etc., etc.
XdrawA:
A = 1
Draw the X there
goto GetO
XdrawB:
B = 1
Draw the X there
goto GetO
etc., etc.
OdrawA:
A = 2
Draw the O there
goto GetX
etc., etc.
Winning messages
That's the outline of my idea. I think it's pretty cool, since like it takes 1^3 or 2^3 for a win to be found, all other multiplied solutions either being a 0, 2, or 4, which the program completely ignores.
What do you think?
My question here is basically, what do you think of the efficiency of this coding structure, and what do you think about porting the idea to something like ObjC / Cocoa in a universal binary? Is that possible with this setup?
Draw TTT board and surroundings
Set variables A-I to 0
// Thinking behind that:
// ABC
// DEF <--- TTT board
// GHI
GetX:
If winning combonation (ABC, DEF, GHI, ADG, BEH, etc.) multiplied together = 8
goto WinO
// It checks for the O winner in the X loop because that's where it goes after
// drawing the third O and setting the variable to 2.
Get an input key > N
// I used 1-9 on my calc for the TTT game board.
If N=7 and A=0
goto XdrawA
// Checks for A=0, b/c that means nobody has played A yet.
etc., etc.
GetO:
If winning combonation multiplied together = 1
goto WinX
// X is stored as 1, so the three multiplied together equals 1 if they are all X.
If all numbers A-I are bigger than 1
goto WinCat
//If all positions have been played but no winner has been found
// (leading to O being the next to play), then the cat has won.
If N=7 and A=0
goto OdrawA
etc., etc.
XdrawA:
A = 1
Draw the X there
goto GetO
XdrawB:
B = 1
Draw the X there
goto GetO
etc., etc.
OdrawA:
A = 2
Draw the O there
goto GetX
etc., etc.
Winning messages
That's the outline of my idea. I think it's pretty cool, since like it takes 1^3 or 2^3 for a win to be found, all other multiplied solutions either being a 0, 2, or 4, which the program completely ignores.
What do you think?