❔ Synchronous function result problem
I have a synchronous function that runs a couple of for and foreach loops that generates a matrix that is returned at the end of the program. The problem is that my program returns a matrix with a random length between 0 and 1 (including) when it should be returning a matrix with length of 16.
Code (sorry about the formatting, weird pasting issue | please ask if I am missing any information, I am knew to this stuff):
9 Replies
oh gosh what kind of formatting is this
Do you know how to operate a debugger?
I think it's fairly hard to think into this code
But you can debug along and figure out where things go wrong for you
Im so sorry for the formatting, thanks for the suggestion, I will look into using a debugger
I am new to dotnet programming so excuse my lack of experience
I used a debugger but it didn't reveal any underlying issue I didn't see before
pastebin of the code: https://hastebin.com/yozisazogo.php
Hastebin: Send and Save Text or Code Snippets for Free | Toptal®
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
why casting to double and flooring? that's what integer division is for
integers can also do ceiling division
yeah this is definitely a candidate for a debugger. Set a breakpoint at your first
for
loop and see what rbottom
is. It's based on a parameter and then you do some math on it so you should confirm that it's actually going to loop the requisite amount
You also really shouldn't be using nested lists for this. This is a perfect candidate for a matrix (something like var walls = new bool[maxX, maxY]
and the same for cells
)Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity./close
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.