From noob: explain this code's purpose, please

No context and missing information. No way anyone could make more than a guess as to what it is for other than something to do with manipulating some text.

Pretty pointless post

1 Like

Can you please add more context to the OP? Even I have absolutely no idea where you got this from.

3 Likes

Looks like maybe something to do with drawing ASCII line art using a set of coordinates.

But there are variables referenced that are out of scope of what is presented.

What gives that away to me are the references to odd and even elements in the array (j modulus 2), the - | and + type symbology and the references to lines and gradients/coordinates (i think thatā€™s what m.x and m.y are).

Itā€™s fucking hideous code though and whoever wrote it needs to be fired.

5 Likes

part of a riddle bot someone wrote. i canā€™t make anything out of it personally. pretty pointless post i guess. sorry to bother u all and thanks for your insight.

Its a join message array for an ascii image.

Shouldā€™nt this post be in the Code section of the forum?

1 Like

Since the variables are all one letter, I hope this was minified.

No it if was minified there would be no whitespace or formatting.

2 Likes

Unless the code was minified and then prettifiyed by OP to make it readable :wink:

doubt that, its a screen shot and not a paste.

Probably some tool to generate a random map design in a RTS game. Or some way to write sequential data to a tape, output might suggest different (yet similar by pattern) things.

The code displays an ASCII maze. See it in action here. See also this post on Stack Overflow.

If you knew from the off without searching, Iā€™m impressed.

The use of ASCII symbol 197 ā”¼ (coupled with the use of j and k as indexes) was a dead giveaway that the code was drawing a two-dimensional text maze. I remember doing that on a Commodore 64 in the early 1980s.

As far as Iā€™m aware .verti isnā€™t a method/function in any computing language, so I figured it must be a custom array name. ā€˜vertiā€™ is also a very unusual contraction of ā€˜verticalā€™ ā€” far more-so that ā€˜horizā€™ ā€” so that made for a nice/rare search term.

Plug ā€œā”¼ maze vertiā€ into DuckDuckGo and the Stack Overflow page was literally the second hit.

2 Likes

Goes to show how badly that code needed comments.

Because most of us didnā€™t understand the intent unless we had prior experience.

They should make IDE assistant you explain your code to and it comment it for you. Imagineā€¦ ā€œOK, rubber duck, hereā€™s what this method is doingā€¦ā€