Work in Progress

Tic tac toe

3

LowRes Oranges are good 2019-11-10 21:08

So this was a little coding challenge, where I had to make tic tac toe in 30 minutes. I completed the challenge(I did it in 27 minutes). In fact it's really small(400 bytes I think)! But it can't recognize when someone wins! I have absolutely no idea how to this. Could you please help?

Yeti.nx | Open in app
2019-11-10 21:08

was8bit 2019-11-11 05:50

After every move, GOSUB to a routine that checks for wins,,,

Here are your wins...
123
456
789
147
258
369
159
357



LowRes Oranges are good 2019-11-11 14:03

But don't I have to check the entire board?


was8bit 2019-11-11 17:54

These are the ONLY possible combinations that can win...

3 of (horizontal in a row)
3 of (vertical in a row)
and 2 of (diagonal)

Only 8 possible conbinations that can win...


was8bit 2019-11-11 17:57

To check the top horitontal, you can do...

C$=A$(1)
IF C$=A$(2) AND C$=A$(3) THEN GOTO GAMEWIN
.....


GAMEWIN:
PRINT "PLAYER "+C$+" WON"
END


was8bit 2019-11-11 17:59

So, if "X" is in the top 3 spots, then "X"wins..
If "O" is in the top 3 spots, then "O" wins..


LowRes Oranges are good 2019-11-11 22:46

Ok now that makes perfect sense. Maybe tomorrow I'll implement that! Thanks.


was8bit 2019-11-11 23:24

Cool, glad i could help :)


Log in to reply.