Hunting NaNs

•November 19, 2019 • Leave a Comment

2019-11-19 — Space Nerds in Space — Hunting NaNs

What are NaNs? A better question might be what aren’t NaNs. NaN stands for “Not a Number”, and NaNs are special floating point values that can occur when you attempt to do things like divide by zero or other “impossible” mathematical operations. Most typically in my experience, NaN generation due to dividing by zero happens when you attempt to normalize a vector with zero magnitude. Once NaNs are generated, they typically spread through any calculation in which they are used, corrupting all sorts of calculations and causing weird behavior for anything depending on those calculations (most typically, NPC ship movement.)

Since Space Nerds in Space seems to work pretty well for the most part, I sort of presumed that NaNs weren’t really something I was bumping into much — that my code was correct enough that I wasn’t generally dividing by zero much if at all. And I suppose that must have been mostly true — mostly true in that the game did work well enough, seemingly. But then I tried actually taking a look to see whether any NaNs were scurrying around down in there.

Oh my god… So many NaNs! So the way that you figure out whether you’ve got NaNs is to enable floating point exceptions to terminate your program and produce a core dump. The code to do so looks like this:

feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);

Then you compile everything without optimization and run it, and see what blows up. Well things blew up *immediately*, leaving a core file for debugging. For a day or so, this cycle continued: Compile, run, explode, debug, fix. Many NaNs knew what it was to be roasted in the depths of the core that day, I can tell you!

After awhile, I slew enough NaN generating bugs that things no longer exploded immediately, but required several minutes of running before exploding. Now, I think I only have one NaN bug left (that I know of). And I have a fix for that one, I’m just not certain my fix is really right, so I want to think about it some more before I commit it (or some better fix).

In any case, if you’re interested in the gory details, you can check out the bug report on github: https://github.com/smcameron/space-nerds-in-space/issues/236

Adding Interactive Fiction into Space Nerds in Space

•August 3, 2019 • Leave a Comment

2019-08-02 — In thinking about how to make Comms more interesting and fun, taking into account that it is almost completely a text based interface, the idea had occurred to me to put some interactive-fiction like elements in. For example, maybe there’s a mission in which you find a derelict ship and you send a robot over to investigate, commanding it via Comms in the manner of Zork and those old infocom games.

Now I already have a Zork-like parser built into the game for “the computer”, however that’s in C, and I don’t want to build it into the game just for a particular mission. And exposing that to Lua seems like a lot of work. Like more than I want to bite off. And not really knowing Lua particularly well, the idea of writing interactive fiction in Lua directly seemed somewhat daunting and unappealing. So, for a long time, I just kind of shelved this idea as being sort of “not worth it.” But lately I started thinking about it again, and thought, well, maybe I should dig into Lua a bit. So this morning I started looking at an old and very small toy project I had done in python that implemented some basic interactive fiction features. I had done that project as a way of learning python. I decided to see what it would take to do the same thing in Lua. Turns out Lua’s tables are not all that different than python’s dictionaries, similar enough that porting this python code to Lua was actually pretty straightforward, and the resulting code is surprisingly similar to the python code. You can see it here: smcamerons-lua-adventure The python one is here: smcamerons-python-adventure.

So with that under my belt, It should be totally possible to write a Lua mission script that incorporates these interactive-fiction ideas so I can make this concept of Comms directing a remote robot around on a derelict ship a reality. Probably want to keep it short, maybe break it up into several different segments, I don’t want to make a mission that amounts to “Drive the ship over there and then play Zork for 3 hours,” but I think this idea has a lot of potential to make Comms more interesting, and it’s good for me to get a little more proficient with Lua.

And after a day or so more tinkering, I have a proof of concept working with COMMS. You can try it out by building and running the latest Space Nerds in Space code and typing “testintfic” on the DEMON screen, then switching to COMMS, and changing the channel to 1234.

Here’s a pic (click on it for embiggening):

Ubuntu 14.04 stopping network-manager

•July 21, 2019 • Leave a Comment

2019-07-21 — Just writing this down in case I forget.

I wanted to set up a private 192.168.1.* network with some laptops not connected to the internet for reasons. No problem, let’s manually configure some IPs. Go to network manager, and… I can put in all the stuff, but it won’t let me save. Google around a bit, oh, I have to set ipv6 to ignore. Nope. There doesn’t seem to be any way to save a manual configuration?

Same problem on both Ubuntu 14.04 and Mint 13. How the fuck did this pass QA?

Ok, fine, let me use ifconfig to set up my network.

ifconfig eth1 up 192.168.1.1

Ha, that seems to work fine. Oh, wait, no it doesn’t, here comes network manager to clobber it and shut off my newly ifconfig’ed network interface.

Ok, fine, how do I stop network manager?

Internet says:

/etc/init.d/network-manager stop

Nope, that doesn’t work. That says that I should use:

service network-manager stop

And that doesn’t work either:

stop: unknown instance

And it seems there’s a bug for this and it’s just totally FuXOR’ed.

Arggggggh!!!

Ok, time for the big hammer:

cd /usr/sbin
sudo mv NetworkManager NetworkManager.orig
/sbin/init 6

Now let’s see if network-manager can do jack shit when systemd or whatever the fuck can’t even find network-manager.

And now I can ifconfig in peace, without network manager sabotaging my equipment every few seconds.

And when I want my laptop back to normal, I can just mv NetworkManager.orig back to NetworkManager and reboot.

God damn, network manager is a piece of shit.

Typical Christian

•July 11, 2019 • 1 Comment

2019-07-10 — Got this comment yesterday…

Typical ignorant cowardly Christian fuckwad. “I’m a Christian bitch”, lolz. Either he’s too illiterate or too in the closet to put a comma in there.

Banned in Pakistan

•December 9, 2018 • 2 Comments

2018-12-09 — Banned in Pakistan

Hello,

A Pakistan authority has demanded that we disable the following content on your WordPress.com site:

scaryreasoner.wordpress.com

Unfortunately, we must comply to keep WordPress.com accessible for everyone in the region. As a result, we have disabled this content only for Internet visitors originating from Pakistan. They will instead see a message explaining why the content was blocked.

Visitors from outside of Pakistan are not affected.
[…]
— Begin complaint —
Dear WordPress Team,

I am writing on behalf of Web Analysis Team of Pakistan Telecommunication Authority (PTA) which has been designated for taking appropriate measures for regulating Internet Content in line with the prevailing laws of Islamic Republic of Pakistan.

In lieu of above it is highlighted that few of the web pages hosted on your platform are extremely Blasphemous and are hurting the sentiments of many Muslims around Pakistan. The same has also been declared blasphemous under Pakistan Peal Code section 295- B and is in clear violation of Section 37 of Prevention of Electronic Crime Act (PECA) 2016 and Section 19 of Constitution of Pakistan.
[…]

Oh noes, I have hurted someones feelings.

Lolz. Guess I won’t be visiting Pakistan any time ever.

Rocket Launch as Viewed from Space

•November 24, 2018 • 2 Comments

November 24, 2018 — Rocket launch as viewed from space.

via metafilter.

Six Years of Space Nerds In Space

•November 3, 2018 • Leave a Comment

November 3rd, 2018 — Six years ago I began working on Space Nerds in Space as a hobby project, little knowing what it would become.