Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
To Nest or Not to Nest Else
#15
Actually, this exclusionary thinking may be quite useful to consider.   Think of this scenario:

A 20 pointed star spaceship is battling aliens in a space invaders style game.  Pew! Pew!  Bullets and aliens everywhere!

Checking every possible point of impact with those 20 star points is going to be processing heavy...

So why not create an EXCLUSION check first?  If the object isn't within this simple circle distance of the center of my Starship, then skip it.

Now, you're not checking everything against every point of the ship.  You're only checking things that are outside that exclusion zone.

That should run and process a TON smoother!

(08-19-2024, 10:24 PM)TerryRitchie Wrote:
(08-19-2024, 10:19 PM)SMcNeill Wrote:
(08-19-2024, 10:05 PM)TerryRitchie Wrote: That second method caused my brain to get stuck in an infinite loop ... or it possibly divided by 0, I can't tell which, LOL

That's almost exactly what my brain did!   After thinking about it a bit, it makes sense though.  It's just not intuitive to me.

If x < 300 Then 'it's left of the box
ElseIf x > 400 Then 'it's right of the box 
Elseif y < 100 Then 'it's above the box
ElseIf y > 200 Then 'it's below the box
Else 'it's not left nor right, nor above nor below the box... it has to be IN the box!


It works, and I might use it for some code obfuscation challenge, but it hurts my brain to think backwards like that.
The only issue I have with the code is that the IF and all ELSEIF statements must be processed. The method I've always used allows for dropping out of the statements when any of them go FALSE.

Imagine feeding this kind of backwards code thinking to LLMs. Let what appears to be hallucinations along with real hallucinations begin!

Nope.  Think about it a little deeper.

IF x < 300 THEN
   'Do nothing, but we could if we wanted too...
ELSEIF x > 400 THEN  <-- we'll skip this and all other ELSEIF and ELSE statements, if the first condition was true.
Reply


Messages In This Thread
To Nest or Not to Nest Else - by Dimster - 08-17-2024, 03:11 PM
RE: To Nest or Not to Nest Else - by SMcNeill - 08-17-2024, 03:35 PM
RE: To Nest or Not to Nest Else - by PhilOfPerth - 08-17-2024, 11:28 PM
RE: To Nest or Not to Nest Else - by TerryRitchie - 08-17-2024, 06:51 PM
RE: To Nest or Not to Nest Else - by Pete - 08-19-2024, 03:23 AM
RE: To Nest or Not to Nest Else - by Dimster - 08-19-2024, 07:30 PM
RE: To Nest or Not to Nest Else - by SMcNeill - 08-19-2024, 08:58 PM
RE: To Nest or Not to Nest Else - by Dimster - 08-19-2024, 09:08 PM
RE: To Nest or Not to Nest Else - by Pete - 08-19-2024, 09:52 PM
RE: To Nest or Not to Nest Else - by TerryRitchie - 08-19-2024, 10:05 PM
RE: To Nest or Not to Nest Else - by SMcNeill - 08-19-2024, 10:19 PM
RE: To Nest or Not to Nest Else - by TerryRitchie - 08-19-2024, 10:24 PM
RE: To Nest or Not to Nest Else - by Pete - 08-19-2024, 10:10 PM
RE: To Nest or Not to Nest Else - by TerryRitchie - 08-19-2024, 10:14 PM
RE: To Nest or Not to Nest Else - by SMcNeill - 08-19-2024, 10:30 PM
RE: To Nest or Not to Nest Else - by TerryRitchie - 08-19-2024, 10:35 PM
RE: To Nest or Not to Nest Else - by SMcNeill - 08-19-2024, 11:56 PM
RE: To Nest or Not to Nest Else - by Pete - 08-19-2024, 10:53 PM
RE: To Nest or Not to Nest Else - by luke - 08-20-2024, 11:17 AM
RE: To Nest or Not to Nest Else - by OldMoses - 08-20-2024, 12:06 PM
RE: To Nest or Not to Nest Else - by bplus - 08-20-2024, 01:40 PM
RE: To Nest or Not to Nest Else - by Dimster - 08-20-2024, 01:45 PM
RE: To Nest or Not to Nest Else - by bplus - 08-20-2024, 02:08 PM
RE: To Nest or Not to Nest Else - by Pete - 08-20-2024, 04:37 PM
RE: To Nest or Not to Nest Else - by dano - 08-20-2024, 10:54 PM
RE: To Nest or Not to Nest Else - by Pete - 08-20-2024, 11:39 PM
RE: To Nest or Not to Nest Else - by OldMoses - 08-22-2024, 05:28 PM
RE: To Nest or Not to Nest Else - by TerryRitchie - 08-22-2024, 06:45 PM
RE: To Nest or Not to Nest Else - by bplus - 08-22-2024, 05:41 PM



Users browsing this thread: 21 Guest(s)