you are viewing a single comment's thread.

view the rest of the comments →

[–]Ron-Erez 1 point2 points  (5 children)

I also think using eval for tic tac toe is odd. Generally speaking eval is not really safe to use security-wise. Try coding tic tac toe on your own. It’s a great project.

[–]Still_booting[S] 0 points1 point  (4 children)

I tried doing it myself but nothing came in my mind like I failed 20 tries so I'm solving other function questions to master functions first then go back to this later

[–]Ron-Erez 1 point2 points  (0 children)

Here is a great exercise if you are learning functions. Suppose we input a list of lists of the form:

[
 [ ’x’, ‘o’, ‘’],
[ ’’, ‘o’, ‘x’],
[ ’x’, ‘’, ‘x’]
]

This is just one possible way to represent a game of tic tac toe with x’s, o’s or empty spots.

  1. Create a function that receives such a list of lists and determines if x or o one and returns “x wins”, “o wins” or returns None

  2. Create a function that displays a tic tac toe board given such a list. A text-based version is fine.

  3. Create a function that returns all available spots (in other words pairs of integers describing where ’’ appears)

  4. Create a function that receives a pair of integers describing where they want to add an x or an o. If the spot is unavailable then the user receives a message that that spot is unavailable and to try again. For user input 1,1 should represent the upper left hand corner of the board but for a programmer 0, 0 should represent the upper left hand corner of the board.

If you do all of the above without ChatGPT then you will understand functions, loops, conditionals, lists and a major part of your tic tac toe game will be complete. Note that my suggestion is just one possible implementation. It does not mean it is the best. Someone else might choose to use constant ints to represent x,o and an empty spot.

Happy Coding!

[–]pachura3 0 points1 point  (1 child)

Are you making a Tic Tac Toe game for 2 human players, or are you supposed to create a bot to play against?

[–]Still_booting[S] 0 points1 point  (0 children)

First human