Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

What's your worst case of "how did I not see that?"
Started by XeduR @Spyric Feb 08 2019 03:47 AM

- - - - -
7 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 762 posts
  • Corona SDK

Hey!

I just needed to vent a bit. :D

Several months ago, I created an algorithm that looped through a polygon's vertices and removed any and all cases of self-intersections. For my algorithm to work, I needed to first find a point on the convex hull of that polygon. For that, I implemented something along the lines of this: https://en.wikipedia.org/wiki/Gift_wrapping_algorithm

Now, this is all cool. However, someone just pointed out to me yesterday, that if I just need to find a point on the convex hull of a polygon, any point, then why not just take the vertex with minimum x and y values? Well, because... and at this point I realised that I had completely missed an obvious, easy and guaranteed solution. In fact, it can even be made easier by just looking for a vertex with minimum x value, since that vertex is also guaranteed to be on the convex hull.

So, my fancy solution was replaced by a simple for loop, like the one below:
 

local hullPoint, minX

for i = 1, #vertices do
	if i == 1 then
		minX = vertices[i].x
		hullPoint = i
	else
		if vertices[i].x < minX then
			minX = vertices[i].x
			hullPoint = i
		end
	end
end

I'm still having difficulties with grasping how I failed to see this. :D

But, what's your worst case of "how did I not see that?"



[TOPIC: post.html]
#2

horacebury

[GLOBAL: userInfoPane.html]
horacebury
  • Corona Geek

  • 3,069 posts
  • Corona SDK

This: https://forums.coronalabs.com/topic/74889-get-device-language/

 

:mellow:

 

Not sure I get the problem you were facing in your post, but glad you sorted it out. Ironically, I'm now wondering if I faced the same issue when I was building my 3D engine. That was just ages ago, so I'm not going to obsess.



[TOPIC: post.html]
#3

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 762 posts
  • Corona SDK

The problem that I was facing had to do with my self-intersection removal algorithm. Starting from vertex #1, the algorithm checked for sides of a polygon that intersected and in such an event, a new vertex was created at the intersection point and the vertices inside of the polygon were removed. The algorithm ran into issues if vertex #1 was among the the vertices that were to be removed, so I needed to make sure that the algorithm always started from a vertex on the convex hull, hence my overtly complex solution. :D


  • horacebury likes this

[TOPIC: post.html]
#4

davebollinger

[GLOBAL: userInfoPane.html]
davebollinger
  • Corona Geek

  • 1,337 posts
  • Enterprise

the worst "head slap" moment that I can recall recently was when writing a recursive solver for a peg puzzle game (to verify solve-ability of a given board layout) and my indexing into a table of symmetries had the classic "off by one" error, due to Lua's 1-based indexes -- it's an issue that I am very well aware of, but it bit me nonetheless = doh!  fe

i = ++i%6; // C, increment and module (onto 0,5)
i = i%6+1 -- Lua, increment and modulo (onto 1,6)

  • XeduR @Spyric likes this

[TOPIC: post.html]
#5

Michael Flad

[GLOBAL: userInfoPane.html]
Michael Flad
  • Contributor

  • 231 posts
  • Corona SDK

Probably not my worst one, but one that is really burnt into my brain since ~3.5 decades is a situation when I was a child, I guess I was about 11 maybe 12, and I got my first computer, a C64. Even back then knew I want to develop games but looking back I guess, at this point in my life, I simply was to dumb.
My parents bought me a book with nothing but printed listings of games (which was pretty common back then, just like listings printed in magazines) and I started to type one of the games into my C64, probably 20 pages of code which required me a lot of time as a very slow typer back then :)
 
Parts of the code were pretty strange words that didn't make much sense to me, don't know the exact woring/formatting, but it was something like {CRSR UP} {CRSR DOWN} etc. and I can very clearly remember that it used a type of braces not available on the C64. Nevertheless I decided to use the most similar ones and typed away all those commands ... and finally after probably days of typing, I tried to run the game but it just created a huge amount of garbage on the screen and in general didn't work at all.
 
The core of the problem was, those {CRSR UP} etc. commands had to be replaced by cursor moves because there was a way to type in cursor moves without actually moving the cursor but creating some special characters that, during execution of the code, actually moved the cursor on the text display to control where the printable next characters will appear. I'm not sure but I think it was a special mode active when editing a string within "" but maybe it had to be activated somehow - I remember it created some kind of negative version of the graphics symbols of the C64 charset. After all this work it was a really horrible experience, I checked the whole code multiple times and the results simply made no sense at all.
Instead of fully typing countless of times all those {CRSR UP} etc. commands I should've just pressed the keys to create the special characters. It probably was even explained somewhere in the book but I just started to learn English and in general was not able to read/understand any additional texts of the book and both of my parents only have the lowest possible education so they were not able to help me at all.
 
I just kept trying and at some point around that time everything clicked and I got the core of programming in general - which was a real great experience :)

  • XeduR @Spyric likes this

[TOPIC: post.html]
#6

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 762 posts
  • Corona SDK

So, I was doing some late night programming, wrapping up one last sample project for my upcoming plugin and I screwed up so magnificently that I just had to dig up this thread.

The code speaks for itself (just had to include it as a picture this time). If the player has got the password, then I want to show it in the string.

programmer derp.png

Well, I kept looking at that on my screen for almost 10 minutes, trying to figure out why I kept getting the password even though the variable was false. I guess programming at 2:30 am after an evening out with friends isn't the best combo. :D


  • Michael Flad likes this

[TOPIC: post.html]
#7

sporkfin

[GLOBAL: userInfoPane.html]
sporkfin
  • Contributor

  • 497 posts
  • Corona SDK

OK, I recently had a head-slap day where the physics engine kept crashing and several of my modules were unresponsive at unpredictable times.  After a day of combing through the code, I discovered that one of my modules was loaded from a backup file so anything directed to it had a 50% of causing a problem.  I wasted a whole day on that!  :wacko:


  • XeduR @Spyric likes this

[TOPIC: post.html]
#8

thomas6

[GLOBAL: userInfoPane.html]
thomas6
  • Contributor

  • 975 posts
  • Corona SDK

Well, I just spent half a week debugging my all-of-a-sudden defunct FTP code. Here's what I did, among other things:

 

- painstakingly went through Graham Ranson's ftp.lua code to find the error

- checked out if the socket.lua and ltn12 libraries supported IPv6

- moved to a new FTP server

- upgraded the whole FTP server to something compliant with IPv6 (or better said: tried to do that)

- called tech support of my hosting numerous times to ask about their TLS, SSL and SSH services

- messed around with App Transport Security settings in the build.settings

- messed around with live build settings because my build.settings didn't seem to fix the issue

 

Then, after three days I tried to see if maybe there was a new iOS update that I had missed that might fix my issue. To my surprise my iPad couldn't connect to Apple's server to find new updates. Turns out my iPad had just connected to a strange but open wi-fi network in our building, that did not offer access to the internet!!! Three days of debugging my code, and all I needed to do was check my wi-fi connection! Aaaaaaaaah!


  • Michael Flad, sporkfin and XeduR @Spyric like this


[topic_controls]
[/topic_controls]