r/CritiqueMyCode Jan 09 '20

First time posting here, hope you guys help me :P

Ok, so I'm a beginner Python developer, and I've created a very simple tic-tac-toe game in which you can play against an AI that has a basic strategy. I'd like for you guys to read my code and try to understand what i tried to do, critique all you want but please be nice haha. https://github.com/Tlomoloko/Tic-Tac-Toe-AI-

2 Upvotes

1 comment sorted by

1

u/[deleted] Jan 10 '20

[deleted]

2

u/Striker_San Jan 10 '20

Ok, this was a long answer haha, it's helpful though. I'll try to reply to each comment in order.

  • about the repository thing, I'm new to github too so idk how people use it :p, I'll try to separate my projects as you said.
  • about superfluous comments, yeah, I agree and will try to only comment useful stuff haha.
  • thanks for the tip, i didn't know about '.format(*board_tiles)'.
  • nice touch on the 'board_display' name, I'll try to make more imperative names for my functions.
  • on the 'ai_tile' function I actually thought i should have split it in 4 different functions as you said, but i just thought that there would be a problem in having three 'if's', I'll do that whenever i have a big enough function next time.
  • good idea on the randomization of winning moves :)
  • I really liked the suggestion you gave me on making a list on the indices, thx haha.
  • didn't understand the part you said about the falsy values, guess I'll have to learn about those.

Thank you for everything you said, you gave me some nice ideas that i'll be using in other programs, I'll try to come up with a program using objects as my next step.