Log in


Kef's Mirror of Darkness

About Recent Entries

JavaScript is bullshit Jan. 20th, 2012 @ 06:35 pm
I started making a JavaScript clone of the NES game Spot (a.k.a. Ataxx, Boogers, and several other things). I managed to throw together a version that used a 3-ply minimax search (albeit an incorrect one; I fixed it the next day I think) within 24 hours. It plays reasonably well and can often beat me, though it occasionally makes moves that seem strange, so it may or may not be buggy. I'm trying to improve it with alpha-beta pruning, but that's taking a while and I'm giving up because I'm tired of dealing with JavaScript's BS. All the good things about JavaScript that made it easy to throw this thing together have been undone by this point. I'll revisit this project when I rewrite it in something more sensible, if ever.

Here's the thing. In a game like Spot (or checkers, chess, etc.), the AI often needs time to think. The naïve way to code this — and the perfectly sensible way of coding it in 99% of programming environments — is to just call a function called "findBestMove" or "doAI" or whatever. Well, JavaScript doesn't like that. If you call a function that takes too long to execute, the page will freeze and, if it takes too long, the browser pops up warnings about the script possibly being frozen. (IE pops up a warning after only a second or two!) You're supposed to work around this by using setTimeout to do a little bit of processing at a time, but this sort of workaround was definitely not written with recursive tree traversal algorithms in mind!

So one way you can work around it is using a thing called a "web worker", which is JavaScriptese for "heaping pile of shit". The message-passing system it uses feels like it came straight out of WinAPI. I understand the idea is to make it easy to code multithreaded stuff correctly, but I think this isn't the right way to do it. At the very least, they could have had the messages invoke on____ handlers instead of only a catch-all onmessage handler that requires you to use a switch statement to distinguish between different kinds of messages.

Now let's suppose your web worker code (i.e. game AI) has a bug (which mine does). Well, you can't use a function like console.log to try to find it because workers don't have access to the console. So you have to write a workaround using message passing. Joy. So let's say you do that and it isn't good enough to find the bug. You need to step through it in a debugger like Firebug. Guess what? Firebug can't debug code inside a worker! Chrome's debugger supposedly can, but y'know what? I'm tired of messing around with this shit.

By the way, did I mention IE9 and below don't even have web workers? So kiss IE goodbye if you want to use them.

And all this is without even going into the stupidity of, say, having variables global by default (which bit me several times until I learned about "use strict" — the use of which can introduce compatibility problems of its own). Honestly, I don't understand how people write complete apps in this thing. A language where you have to jump through a million goddamn hoops just to write something similar to a chess program? Pretty goddamn pathetic.


Please select time zone Jan. 16th, 2012 @ 07:15 am
Tell me, what kind of moronic software developer came up with the idea of having the user specify their time zone by naming an allegedly nearby city? Ubuntu, CentOS, and the website mygengo.com all have this problem. Ubuntu at least lets you type "Central" (but you have to type it instead of clicking on the map, and there's no pulldown list), and CentOS lets you specify UTC-6 (but I wonder if it's smart enough to handle DST in such a case). mygengo doesn't let me specify either. I have to choose between Chicago and Mexico City. Which is the right one? Heck if I know. Chicago is a bajillion miles away and Mexico City, while pretty darn close in longitude, isn't even in the same damn country. Why not use the name that every American will recognize, "US Central"?

Oh, and I can't seem to look this stuff up, either, because if I just ask Google what my time zone is, it'll say US Central. Yeah, thanks. Why don't you tell these idiot developers that?

Sudden Cat Death Syndrome Jan. 10th, 2012 @ 10:51 am
Don: I guess I'll take him into the emergency vet...

Me: I don't think it's that bad, is it?
The question I forgot to ask myself here is, "How hard will I be kicking myself in the morning if it turns out I'm wrong?"

Luna is one with the back yard now. He was a "he", despite his name; we initially thought he was a she, and the name stuck. We often called him "loony" anyway, particularly since it fit him all too well. He is far and away the strangest cat I've ever met. He was so skittish I took to nicknaming him Perry (for "paranoid"). He often ran away if you suddenly walked up to him, but he'd come up to you sometimes (and if you were really lucky he'd sit in your lap; I wouldn't be surprised if he'd sat in mine less than half a dozen times in the few years we had him). If you pet him, he'd usually accept it, but he'd pace about nervously, his tail flailing about like crazy. He often isolated himself on a particular high perch in the back room, but he wasn't hiding in the manner of a typical sick cat. I think he was just usually a loner and maybe paranoid about the other cats. He'd have periods where he'd come out and be more sociable (though often still preferring high places), then he'd go back to staying on his usual perch in the back room.

So last evening we got signs there was something seriously wrong with him. He'd make meowing and whining noises like he was in pain and then he'd stop, and he'd do this throughout the evening, maybe once an hour. (Normally it was quite rare to hear him speak.) His breathing seemed OK. He threw up at least once, but cats throw up all the time, so that didn't necessarily mean anything. He was also docile. He'd move around a bit, but he didn't run away or even react much if you walked up to him, which was unusual for him. His stools were runny -- at least I assume the runny ones were his. (He'd always done a bad job of covering up in the litterbox.) But aside from these symptoms, nothing was obviously wrong.

So we thought, OK, we'll keep an eye on him for tonight and take him into the vet tomorrow if he doesn't improve. And we'll take him in sooner if anything particularly alarming happens.

Well, when something particularly alarming finally happened (my stepdad said he made a strange noise while in the litterbox), it was too late. He was already dead by the time he could get him in the car.

There's no need to sympathize for my loss; really it's my stepdad who's distraught about it. But I wonder what the hell could have happened.

BEEP BOOP BEEP BOOP BEEP BOOP Jan. 4th, 2012 @ 05:27 am
So, here's why I was running the chkdsk. Last night I had to kill power to my compy. Well, sort of. I was testing my 65816 assembler and I put in a really dumb parsing algorithm, but I was curious just how slow it was. Well, after letting it run for upwards of ten minutes (which was already way too long; I was only assembling 1 million random instructions), my computer's temp alarm went off! So I killed the program and the alarm ceased. ("Alarm" is a good name for it. It's so loud and insistent, when it goes off, you are most certainly not unalarmed. Very paranoia-inducing, in fact!)

Well, a minute or two later, the alarm went off again and the assembler wasn't even running. I tried to shut down Firefox, since FF hogs my CPU at times, but it didn't seem to be helping. I realized I needed to shut down the compy or I might risk frying something. But a proper shutdown would take too long and it might stay too hot all the while... so I panicked and held the power button until the compy shut off. (In retrospect, it was probably SETI and Rosetta that tripped the alarm again. I should have tried closing them first and then doing a proper shutdown if the alarm stopped. Oh well. You can't really think clearly while a computer is going BEEP BOOP BEEP BOOP at you as loud as it can.)

I think I hosed my Firefox preferences in so doing; apparently it hadn't finished shutting down when I cut the power. When I started FF this morning it seemed to have forgotten many of my preferences, though it remembers things like history, passwords, and bookmarks. Hope nothing else is broken...

I still wonder why the temp alarm went off, especially on a cool winter day. My CPU is pegged at 100% (both cores!) all the time with SETI and Rosetta, so I don't see why my assembler could be any worse, no matter how inefficient the parsing algorithm was...

Dumb and dumber Jan. 4th, 2012 @ 04:30 am
Dumb: User schedules chkdsk to run. Full chkdsk on three hard drives takes a total of 11 hours. After successfully completing the scan, the computer reboots (as expected) and... begins to run chkdsk again. WTF? I did schedule three scans -- one for each drive. I didn't schedule any of them twice. So why on earth did it start scanning again?

Dumber: There is no way to cancel chkdsk if you miss the 10-second window before the scan begins. A 10-second window that presumes that, y'know, I'm actually watching the goddamn computer. And it's not a good idea to 'cancel' it by rebooting the computer, so I had to wait for it to scan the E: drive all over again. Thankfully that's my smallest drive, and I think the fact it's FAT32 instead of NTFS (which surprised me; I thought all three were NTFS) made the check go faster. But still, WTF? How many man-hours have been lost because MS was too goddamn lazy to make it a cancelable operation?

In conclusion, fuck Microsoft.

Oh yeah, and fuck LJ or Google (whichever is responsible) for the textbox widget in LJ's Android app, too. I first wrote this post on my phone because the second, unwanted chkdsk was still going. While I was doing so, I found that LJ reset the text cursor to the end of the text after every second or two of inactivity. If I wanted it there, I would put it there, thank you very much.

Battletoads Dec. 17th, 2011 @ 07:24 am
The gameplay isn't the only thing hard about Battletoads. I went to extract the script so I could make an LLTVG entry and I found after a while of reverse-engineering that the text was Huffman compressed! I've never done anything with Huffman before, though I already knew the idea behind the algorithm -- that's why I was able to recognize it. If I'd known from the outset that the game used Huffman, I wouldn't have touched it! But I was already too deep into the reverse-engineering and I eventually managed to get it all.

TooManyTabs Nov. 20th, 2011 @ 06:31 am
Thank God somebody recommended the TooManyTabs extension for Firefox. Now I can have as many tabs as I like and not worry about FF eating up all my CPU and RAM. And I can even leave NoScript off!

In other news, I'm currently converting my two websites (furrykef.com and LLTVG) from Apache to nginx. I tried to finish that last night, but it wasn't in the cards. Then I went to bed and dreamt about server administration... ugh.

Fukushima Sep. 12th, 2011 @ 02:07 am
I translated this image for the hell of it.

It's too big, so here's a link.

Gahhhh. Jul. 22nd, 2011 @ 08:40 am
I'm trying to write a novel. (The details are secret for now.) I have somebody who I might coauthor with, and I'm in need of a word processor -- my old copy of MS Word 2002 is buggy, and LibreOffice stupidly omits a "normal" or "draft" view, making it extremely irritating -- and with Google Docs I thought, hey, two birds with one stone! Google Docs's interface seems to be good enough and it doesn't have the problems I'm having with the others, and I can collaborate! And it keeps track of changes! Sounds like a win-win all around. Except, unless I'm mistaken (and I don't seem to be), there is a very stupid omission in their Revision History feature.

You can't jump to changes.

Hello? I'm writing a novel. A document that will eventually consist of some 300 odd pages. Do you expect me to hold down the Page Down key and look through my entire manuscript trying to find the bits of green or orange text that indicate changes?

Did Google really leave out this basic and necessary feature? What the hell are they working on that's so much more important than this?

EDIT: Oh, great. Apparently Google Docs used to have a more useful revision history feature that, for instance, allowed you to compare two arbitrary revisions instead of having to compare between one revision to the previous revision. In other words, they made things prettier at the expense of making them shittier. This was a year or so ago and they still haven't bothered to restore the lost functionality. I'm getting off Google Docs as fast as I can and moving to a service run by people who weren't dropped on their heads as children. Provided that one exists.

A hilarious Tenacious D Jul. 16th, 2011 @ 09:03 am
This is one of the funniest things I've seen in my life. It's also one of the most obscene things I've seen in my life, so be careful with this thing.

(In case you're unfamiliar with Tenacious D, the two characters here are the members of an acoustic metal duo. Yes, I said acoustic metal, though that's irrelevant in this short...)
Top of Page Powered by LiveJournal.com