Share your repls and programming experiences

← Back to all posts
CyanCoding (1597)

As a fun side project, I built this awesome Tic-Tac-Toe game (with three AI levels) in May 2017.

YuAndy (15)

I beat the impossible level in 4 moves!!!!!!

DavidLi17 (14)

@YuAndy I did it in 3 moves!!!!!!!!!!!!!!!!!!!!

ebest (640)

code warningserrors sure can kill!

and HOW did this get the 5th most votes in ALL the posts!?!?!?


maxballard (4)

It works and all, but no tic tac toe program like this should be 2000 lines long. You can put a lot of the stuff you have into specific functions. You repeat yourself many times, and basically just hardcoded the game. This will work for a simple game like tic tac toe, but if you wanna progress farther as a programmer you need to actually learn how to program.

CyanCoding (1597)

@maxballard Haha, thanks for the tip. Do note though that I made this over a year and a half ago, and it's not even in the same language I use now. But yes, I have gotten over that bad habit.

codingduck (8)

ummmmmm wut:| also scroll bar all that...

maxyang (58)

I was a bit surprised when a tic tac toe program took 2600+ lines of code, no tic tac toe should be that long. Also it generated 646 lines of code, and "Impossible" isn't really impossible(It's beatable in 3 moves)

DavidLi17 (14)

I beat the impossible level in 3 moves!!!!!!

DavidLi17 (14)

I beat the impossible level in 3 moves!
and beat it on first try!

AmazingMech2418 (846)

Impossible mode seems to have lost its right for its name... It was actually very easy to beat...


cool game!


Nice job! Enjoyed playing.

Nanowrimoijk (43)

beat impossible, thats what comes when you play against yourself =(

m_23s (0)


honchkrowabcd (6)

impossible isin't impossible

Spyder101 (4)

Holy cow great job! The code works smooth and he difficulties hold up their reputation...

zacdisbury (0)

well well well that's cool

FiveCubed (14)

Why do you have it look at every spot on the board to test for a win?

CyanCoding (1597)

@fivecubed: This way it can make sure you won, regardless of the win spots.

Jeremiah32556 (0)

This is REALLY cool. I think it would be better if it was more obvious where the player "0" plays because I sometimes can't tell if the bot played in a spot or if it's just the number zero.

glendog (0)

2600+ lines of code :o

RyanBridgforth (0)

@glendog: Just wait until his next project...

AntonAlley (0)

I'm building a tic tac toe AI in PYTHON only 300 lines for the whole game and AI

CyanCoding (1597)

@antonalley: Awesome! Yes, after writing this in C++ I realized my mistake 😀. Can you send me a link please?

s622420 (0)

it would be nice if there was a play again button

CyanCoding (1597)

@s622420: I think that's just the run button 😀

BobJoeIII (19)

I beat impossible mode!!!!!!! (my life is complete)

beginneer (0)

yo code is just insane! KEEP IT UP

J7Luke (0)

Nice simulator! I can always win against impossible if I go first, and I can always tie if I go second.

CyanCoding (1597)

@j7luke: That's a sign of a real pro! As far as I've seen from other users, there's only one-two ways to beat impossible!

TuffeMann (0)

Hi Cyan. That computer is quite polite. It won, with three o-s in a row, but let me place anothr x after winning. So I also got 3 in a row. The computer then told me that I had won the game. REALLY! There must be a bug in this game somewhere...

CyanCoding (1597)

@tuffemann: Yes, I don't know where that bug is, but I've seen it happen before. I just thought it too funny to remove 😄

Govind05 (1)

Why it is tag impossible,I had beat it in my first attempt

CyanCoding (1597)

@govind05: I tagged it as impossible because until I had published it on the I built this challenge, nobody had ever beaten it before. I didn't even know it was possible! Now, I just leave it in there so that people think there's no way and keep trying until they figure it out.

Jeremiah32556 (0)

@govind05: I won too. Lol, I think the bot is not good with that spot

CyanCoding (1597)

@jeremiah32556: Sadly, it isn't that. It doesn't really have a choice since when it goes in the middle, it'd need to play twice to stop you (if you played on the end).

J7Luke (0)

@microwither The strategy used to beat the impossible computer is to choose a corner, then the opposite corner, then a third corner (or the middle if the computer has left it open). The way for a computer to tie a game that opens this way is to choose the corner opposite the one the player chose on the first move. From there, all the computer has to do is block any potential 3-in-a-row moves.

CyanCoding (1597)

@j7luke: Interesting! I'll fix this soon.

SomeRandomGuy (0)

I beat the impossible mode first try. I loved the way you made the game. Great job!