#๐Ÿ”’ Help with a tic tac toe project

28 messages ยท Page 1 of 1 (latest)

cerulean vortexBOT
#

@sharp root

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

sharp root
#
def is_victory(icon):
    return (board[0] == icon and board[1] == icon and board[2] == icon) or \
           (board[3] == icon and board[4] == icon and board[5] == icon) or \
           (board[6] == icon and board[7] == icon and board[8] == icon) or \
           (board[0] == icon and board[3] == icon and board[6] == icon) or \
           (board[1] == icon and board[4] == icon and board[7] == icon) or \
           (board[2] == icon and board[5] == icon and board[8] == icon) or \
           (board[0] == icon and board[4] == icon and board[8] == icon) or \
           (board[2] == icon and board[4] == icon and board[6] == icon)
#

this is my way of making it

#

I don't know how to make it like he suggested

#

because going over every possible instance is slow and just not a good way to check the winner

coral crypt
#

well technically you are not checking every single condition unless they all fail

#

we have something called short circuiting in modern languages, if you have a condition like x == 5 or x == 6 and it finds that the first one is True it wont evaluate the second one at all

sharp root
#

he asked: what if you wanted to show me who won mathematically, how would you do that?

coral crypt
#

hmm are you storing integers in your board? what is icon

#

he might mean boolean arithmetic, where you do math using bools

#

!paste sure

cerulean vortexBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

coral crypt
#

yeah I'm not sure what he means pithink

sharp root
#

same

#

ill delete him

#

and just

#

ask him for the answer lol

coral crypt
#

lol

sharp root
#

thank you tho!!

#

btw

#

uh

coral crypt
#

np, good luck with your code

sharp root
#

oh alright thanks! cya around

fast trench
#

please share the answer

sharp root
#

i will

cerulean vortexBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.

#

๐Ÿ”’ Help with a tic tac toe project