![]() ![]() The chickens always go first and make their. Keep in mind I'm a first year CS student, yet all of my tests seemed to work rather well. IF YOU'RE a birdbrain, there's an Indianapolis casino that bets you can't beat their chickens at tic- tac-toe. While my loop-example would obviously trim it all down - if you combined conditions with “or” instead of “if-elif”-chains, you’d also save yourself repeated code.This is how I went about checking for a tie for the project that I just had to do. Then ofcourse that’s some advanced stuff, but turning it all into an object would be a lot cleaner just by virtue of having a game-object instead of a bunch of functions and global variables floating around. Seems like you already got bored of that because the very first message is different. Like, imagine you want to improve this and add change the win-message - right now you have to change like 9 lines I guess? Given the only actual difference is the index you check, you could put all important index-combinations into another array and have just one function check them and change the winstatus if necessary. But you wrote them out every single time. ![]() You can definitly improve on conditions and loops though.Ī rule of thumb is, if you write the same code 3 times, it propably should be a loop instead.īasically all you win-statements are identical. If board = board = board and board != '-':Įlif board = board = board and board != '-': Print('Please check the input value before playing the game') The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row is the winner. Inp = int(input("Enter the position : ")) Print(board + ' | ' + board + ' | ' + board) Also I am working on adding MINMAX algorithm to this game, so that there could be an AI that tackles the human. Hello everyone, here’s my version of tic-tac-toe using python, there are a few issues. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |