small issue
im making a game of tic tac toe but i have 0 idea as to how i implement the system that checks whether 3 crosses or zeroes have been added..
37 Replies
here's the code
I suggest you check the suggestion if you hover
=
will set a variable to a value
==
will check whether something is equals to a valueoooh yeah yeah youre right
fixed it
Also, you should not use semicolons after if-statements as that makes it ignore the if-statement, same with while-loops, etc.
oh
thank you
do you know how i could add like an actual system of winning tic tac toe??? like i know theoretically i just check to see if 3 of the same value has been added in a row or in a column or diagonally but i dont actually know how to implement that
Just check the neighbouring tiles
or the whole board if it's small
For such a small board, I'd just check the whole board
so i just run a for loop that checks the entire board
and um
if it has the same value
diagonally, horizontally or vertically that person wins?
i mean i guess i can try it
I assume this is homework?
yeah...
this is me attempting to not just copy from a youtube tutorial and do it myself
I highly suggest to read the logic out loud for yourself
That might make you understand what you are doing and what you are going to do to implement said thing
alright
Learning how to debug is the biggest and most helpful thing for a programmer
$debug
Tutorial: Debug C# code and inspect data - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
A debugger allows you to step through the code and inspect the values, and so much more
mk mk
so uh
i tried something
but there r a lot of issues
nvm this is horribly unoptimised and wont rlly work
i rlly do need a tutorial
Remember what I mentioned above
No!!
If you copy a tutorial blindly you will never learn
Buddy
=
will set a variable to a value
==
will check whether something is equals to a valueQuoted by
<@203166497198047232> from #small issue (click here)
React with ❌ to remove this embed.
oh i forgot to add the == for the 0 part mb
im trying a few different ways its just all rlly bad
id have to manually check every single combination
for every row and every column
and then check for each diagonal combination
and then repeat that for 0, after I do it for X
Why? You don't need to be checking if every combination wins when there's only 1 piece being placed at a time
oh
how did i not think of that
but wait
how would the program know im going for a row and not a column
evene if its only 1 piece at a time
id still have to check for both right??
and in order to check for a row id have to check every row because there could be any piece in any of the three rows
1 2 3
4 5 6
7 8 9
You place a piece in 8, what are the possible winning combinations?
258 and 789
but like
lets say i pick 8 on the first round
then 5
then 2
havent the winning combinations now been opened up to every piece on the board???
because all the program knows
is that there are values in each one
456 isn't going to win as a result of placing ap iece on 2 no matter what the configuration of the board is, if 456 was a winner it would have won when the last piece out of 4, 5, or 6 was placed
so only the last piece matters?
if the last piece entered is, as an example, 1, i only check 147 and 123
i mean that might work but wouldnt it still be very cluttered?
because each combination for each number would still take a very long time to check over manually
even if there are only two
yeah im gonna leave this for another day im literally losing sleep i started this at 1am and its 4am
Time as in having to write the code for going through the row, the column and the diagonal? That's complexity inherent to the problem, you will have to write that code
no time as in literally writing every single possible combination
what combination?
for every single position an X or an O could be in, it checks the 2 places next to it
use a loop
but yes that's right
you need to do that
maybe going by rows and by columns separately would be easier to think about
ive tried a few
but they all like
required a minimum of like 20+ lines
and well that would be fine
but each line is riddled with errors that i dont know how to fix
but idk i havent touched it since last night
ill prob just restart
well that's just a skill issue
learn the basic syntax