needing help for a console game
https://paste.mod.gg/eovangifthsv/0
in this code m is a solution i used for debugging so that it prints the point of the code it reaches, but it reaches only the m = 3 step. a person told me to use a debugging tool but i don't know what that is
BlazeBin - eovangifthsv
A tool for sharing your source code with the world!
35 Replies
What do you code in? VS? Rider?
VS
see that white dot? hover your mouse in that location on the line you want to pause the code at
click it. it will turn red and stay there
i don't have any dot
next time you run your code in debug mode (see below) the execution of your program will pause at that location
oh now i see it
should look like this
you can have as many of these as you want
if you use different dots what do they do?
same thing: the code will stop at that point
one stops the program, the others?
they all do
but they dont "stop" stop it
they halt it
ok gotcha
you can resume, or step
stepping is SUPER POWERFUL
it lets you move one statement at a time
and see exactly what your code does, and what variables change to what values etc as you go
using the m i found anyway where the code stops working
i just don't know what's the problem
i guess it's something with the switch
your switch only has one case
so uh
I dont see what else it would do?
i wanted to add the second one later on
btw, I highly suggest you invert your code
what you have now is unreadable as hell
it doesn't work with the first one in the first place
invert?
wdym?
1 sec
yeah sure
instead of nesting 3 ifs, you can just invert the if and return
this keeps indentation levels down and makes it easier to see whats going on
why should you return nothing?
it stops the method
look at your current code, this does the exact same thing
except it doesnt have 4 levels of nested ifs
okk ty
i’ll study this
good
as for why your code doesnt work.. use the debugger to go through the execution and see where it goes the wrong way
okk thank you dude
also, what’s “indendation levels”?
i am not british/american as you can guess
these vertical lines indicate an indentation level
it gets really hard to read code when its ~10 levels indented
makes sense, thank you again
so basically if those conditions are not satisfied the code stops, if instead they do the code runs the last statement
yeah, code is very straight forward
it will do what you ask. so if you instead of saying...
you can say
gotcha
seems much better
@Pobiega after debugging i found out that the value of the element in the array becomes 0 before the switch statement
i don't get how tho
https://paste.mod.gg/vsipyolkpise/0
i stopped the code after every console.writeline function in the MovePiece() function
BlazeBin - vsipyolkpise
A tool for sharing your source code with the world!
using "1" and "7" as the column index and row index this is the output
10101010
01010101
10101010
00000000
00000000
0-10-10-10-1
-10-10-10-10
0-10-10-10-1
1
1
0
10101010
01010101
10101010
00000000
00000000
0-10-10-10-1
-10-10-10-10
0-10-10-10-1
and you can see it's 1 two times and then it becomes 0