Skip to content
← Back to Community
Tic Tac Toe AI
Profile icon
richtan

https://repl.it/@richtan/Tic-Tac-Toe-Python-3
I made this a few months ago during my free time. Not sure if this counts as a bot, but you can also play with another human.

Voters
Profile icon
ElleAdele
Profile icon
loudoh16
Profile icon
davidyu9
Profile icon
studentAlfredAl
Profile icon
MiercolesJajaja
Profile icon
DulceVillagomez
Profile icon
ZayxHex
Profile icon
SimerSingh
Profile icon
Noob_vn
Profile icon
ChrisHill
Comments
hotnewtop
Profile icon
ch1ck3n

image

Profile icon
richtan

I feel so autistic talking to myself like this.

Profile icon
studentAlfredAl

2 years later and I find this. Wonderful game! :)

Profile icon
richtan

if there are any bugs, please tell me and i will do my best to fix them.

Profile icon
richtan

I'm 90% sure there is a bug SOMEWHERE because the last time I tested it, it had a major one.
Edit: Found it

Profile icon
coder92708

WOW!!! this is AWESOME!

Profile icon
richtan
Profile icon
mariogreco

Found a bug. On impossible mode, if computer goes first, it tends to place its marker on the same location as its previous turn, at least once per game.

Profile icon
richtan

@mariogreco: oh ok I will go check that out. sorry about that!

Profile icon
richtan

@mariogreco: could you send me a screenshot? that would be helpful when debugging

Profile icon
plutonium21

nice job :D

Profile icon
richtan

@plutonium21: thanks

Profile icon
forfree

very nice AI, fun to play, too! i like it. :)

Profile icon
richtan

@forfree: thank you

Profile icon
richtan

and also, just asking, whats slack?

Profile icon
TimmyChen1

@richtan: https://slack.com/ productivity chat app :)

Profile icon
rorymills1

on impossible, it missed ago and i won

Profile icon
richtan

@rorymills1: can you do it again and send me a screenshot? i will try to fix it!

Profile icon
richtan

If you want to use any of the code, you may use it, but please give credit.

Profile icon
katiewinton

@richtan: um just saying it's a little confusing because when the computer goes first on medium it chooses the center piece and it looks like a zero not an o

Profile icon
richtan

@katiewinton: well there is no zero on the board, so...

Profile icon
[deleted]

I got an error ;(. I'll write it over here:
Traceback (most recent call last):
File "python", line 456
elif int(self.ct1) - 1 in [0, 2, 6, 8] and not self.board[{0:8,8:0,2:6,6:2,1:"X",3:"X",4:"X",5:"X",7:"X"}[int(self.ct1) - 1]] in self.xos:
^
SyntaxError: invalid syntax"

Profile icon
richtan

@matti12: sorry i was adding something at that time. it should work now

Profile icon
XaBras

It is extremely glitchy! I mean, against the bot

Profile icon
richtan

@xabras: what do you mean by glitchy?

Profile icon
richtan

i am debugging right now pls give some time

Profile icon
richtan

I think i fixed one of the bugs, you can try if you want.

Profile icon
richtan

Please upvote if you like it.

Profile icon
Itai52

I won against it in "Impossible" mode, you should upgrade it.

Profile icon
richtan
Profile icon
richtan

I will be adding back the impossible mode as soon as I get it to work properly.

Profile icon
AlexanderPaige_

This is a lot cooler than I expected. Nice job!

Profile icon
richtan
Profile icon
richtan

Added what seems to be working Impossible mode. Report bugs if you find them :)

Profile icon
richtan

I also added jokes if you do the quit command.

Profile icon
Calamari1

This has kind of a retro touch doing it like this. It's just like the good ol' days when we played stuff via telnet :D

btw: small bug in the end: the quit command asks for (Y/n) but it does not accept uppercase Y.

Profile icon
richtan

@calamari1: oh ok I fixed it now thanks!

Profile icon
richtan

@calamari1: also noting, the uppercase also means default yes is no answer, in case anyone asks

Profile icon
fbasso

Best game ever bro!!!

Profile icon
arjunpy2

epik

Profile icon
richtan

Added even more color to make it easier to know who is who.

Profile icon
AlvaroHabet

That is amazing!

Profile icon
richtan

@alvarohabet: thanks!

Profile icon
LightninMcQuade

Works Great! you should make it where when you are done with a game and type y to play agai it throws you into another game with the same settings and add a function with all of the menus in it so if they type settings you just call that function if they type n sys.quit and if they type y just clear the board and start another game

Profile icon
richtan

@quadeg1: yeah i was thinking about that too, i will add soon

Profile icon
richtan

@quadeg1: aaand I'm done, I added it

Profile icon
richtan

admins hate me project lol

Profile icon
NotVexed

Hi richtan,

I love your game and was testing it for bugs when i found this. It says, 'Please enter a valid input. That spot is may have been taken. If so, please choose another spot.

I am not sure if you wanted the "is may" part, or the "If so" part because it is obviously taken.
image

Profile icon
richtan

@notvexed: ou yeah thx a lot!

Profile icon
richtan

fixed thx dude!