Actionscript suffers like many other languages from poor string parsing commands. What would take one line of well crafted perl is… a bit more complex here.

public function hex2dec( hex:String ) : String {
	var bytes:Array = [];
	while( hex.length > 2 ) {
		var byte:String = hex.substr( -2 );
		hex = hex.substr(0, hex.length-2 );
		bytes.splice( 0, 0, int("0x"+byte) );
	}
	return bytes.join(" ");
}

private function d2h( d:int ) : String {
	var c:Array = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' ];
	if( d > 255 ) d = 255;
	var l:int = d / 16;
	var r:int = d % 16;
	return c[l]+c[r];
}

public function dec2hex( dec:String ) : String {
	var hex:String = "0x";
	var bytes:Array = dec.split(" ");
	for( var i:int = 0; i < bytes.length; i++ )
		hex += d2h( int(bytes[i]) );
	return hex;
}

What do these methods do? Well, hex2dec takes a hexadecimal string (and assumes you have a throwaway prefix of “0x” or “#”) and returns a space-separated list of decimal values. dec2hex does the same thing, but in reverse.

hex2dec("0xF00F04") returns “240 15 4″.
dec2hex("240 15 04") returns “0xF00F04″.

Also, the method doesn’t much care if you’ve got 6 hex digits or 60.

There are a few optimizations I could make on this code here, but it’s not getting called that frequently anyway. The performance gains in my application would be trivial.

And just by way of warning, this is AS3 code. It’d need a few tweaks to work reliably in AS2 or (shudder) AS1 environments.

update – may 7, 2008

It has come to my attention that people keep stumbling across this old post. While I don’t have the time or interest to optimize these functions for real environments in any of the several ways they could be improved… I figure I’d take a moment for the benefit of those who are probably just looking for the quick answer.

The easiest way of getting a hex string from an int value is to call its toString() method with a radix argument of 16. Likewise, you can request any integer base from 2 to 36. Results use lower-case letters when outputting in a base higher than ten.

240.toString(16) returns “f0″.
240.toString(8) returns “360″.

Well, today the speed sub groups released the final installment of KyoAni’s 24 episode remake of Kanon. With this on top of yesterday’s Clannad announcement, it’s generally a good day for sappy anime dorks everywhere.

Kanon is… well, originally it was a porn game. But the company’d made one fatal flaw when they released it – the story was too good. So they have since made something like 4 or 5 “clean” releases of the game which have all done phenomenally well (of course, none has ever been commercially translated into English).

A few years back, they also did a 13 episode anime. It was decent enough, if fairly mediocre. I watched it, I liked it, but not enough to have watched it a second time.

The remake makes a lot more sense than the original anime did. I’m generally very impressed. I’m also very impressed with how they dealt with the ending. I don’t think that it could have been handled any better. I’m pleased.

I probably will watch this one over again. I’ll probably even buy the dvd’s when it gets commercially released in the States.

Review? Shrug. I don’t really want to review it. I’m too emotionally fluffy right now to be objective.

But I guess that’s the review right there. The show left me happy. It’s been a while since an anime’s impacted me so strongly. Idunno, it’s not like when I finished Ai Yori Aoshi… I feel more like I did after watching Spirited Away in the theater for the first time.

Animation: 7 | Art: 9 | Characters: 7 | Emotional Attachment: 10 | Humor: 7 | Music: 8
Story: 7 (10 if you’re a fan of the genre)

Overall, it is possible to chalk this up as just another dating sim adaptation. However, Kanon is the mother of all dating games. So a lot of elements that may seem cliche now were originally made popular by this story… so you’ve got to give them a bit of leeway in that regard ;)

They improved dramatically on the art from the game and original anime series. The characters look good, they look much more human and consistent. I’m also pleased to report a complete lack of fan service. The raciest the art gets is the short skirts (which were part of the original eroge character design).

As far as animation goes, there’s a bit of reused footage, esp since the story dwells on past events, slowly replaying them in pieces until you have the whole image. The animation is average and acceptable. Nothing amazing, but I don’t ever remember anything offensively poor quality.

The choices of what to animate, however, were very well done. So the overall visual experience bumps my score up a bit.

I liked the music. I wouldn’t mind adding the soundtrack to my collection. The characters are standard dating sim characters, but again, they’re some of the original dating sim characters. This adaptation led me to appreciate several of the minor characters much more than I used to – they have more depth in this new 24 episode series than they ever came close to in the earlier version.

The story itself isn’t terribly amazing, but the way it is told is masterful. I like the way they interwove the different stories together into one much more cohesive whole than the previous version did. Episode 23 in particular was a wild ride when I watched it last week – I actually paused halfway through to talk to speculate on which direction they were going to take with the show’s ending.

And the ending, while it could have been a bit more straightforward… is happy, and I certainly liked it better than the ending of Air. It’s a good ending that resolves loose ends and ties the story together neatly… something that is all too rare in major anime releases these days.

Overall: 8 (10 if you’re a fan of the genre)

Will it fly off of the shelves if it ever gets licensed and translated commercially? Probably not. At least, not in any exceptional numbers. It’s still a niche interest show (hence my doubts of it ever being acquired). Thankfully, I belong quite happily to the section of the populace who is happy to watch a story about sad girls in snow remembering how to be happy again :)

Well, not much to say about this, really, but at 10am this morning, my primary video card kind of exploded here at work. So I’m stuck using the spare (GeForce 4 series) PCI vid card that I’d bought from across the street back when I was flirting with 3-head (mentioned briefly here). Being reduced to one monitor is not cool. I’m gonna fix this… soon, I hope.

I snapped a photo with my phone, but it didn’t come out very well at all. Here’s what I’ve got after attempting to clean it up some:

Video Card Go BOOM!

You can barely make out the little Vivi plushie sitting on top of the monitor that used to be powered by the exploding card. Well, at least, you can kind of see his hat.

I have also been reminded that it’s fortunate I didn’t die when this happened ;)

This is the first in what I hope will be a 3-5 part series on my predictions/guesses/vain hopes for future major changes in the World of Warcraft universe. Obviously, these ideas are the spawn of my own fevered imagination and have very little, if any, basis in reality or probability.

Since I’m starting something pretty big here, I figure I may as well start off with a big idea.

Prediction: The Horde and the Alliance will be broken

Now, I do not mean that they will be dissolved entirely. But I do believe that some shuffling of factions is in order. Both major factions will continue to exist, but as much less finitely established entities. This will not happen with the next expansion (that’ll be Northrend), but I hope for it in the one following.

The current roster shows:

  • Alliance – human, night elf, dwarf, gnome, draenei
  • Horde – orc, troll, tauren, undead, blood elf

Now of these large factions, there are several races that don’t really fit in with the original Orcs vs Humans conflict. They have their own ideologies and their own agendas.

The biggest of these differences of agenda is in the relationship of the Forsaken with the rest of the Horde. They are downright hostile to life in general. They are openly evil. The only reason they’re in the Horde is because Thrall is very… open-minded and accepting. I do not suspect that he will kick them out, they won’t stick around long enough to give him the chance. I predict that the Forsaken will betray Thrall. This will precipitate things on the Horde side.

The undead have plenty of motive and plenty of opportunity to turn. Once the Scourge are finally dealt with, they have nowhere else to expand… They also have a very ready potential alliance in their new neighbors, the Blood Elves. Belfses have literally no history of alliance with the Horde, so it stands perfectly well to reason that they would be willing to jump ship when the corpses do – especially if they see more magic to be had in the bargain than if they stick with Thrall. Perhaps their deal might be that the Blood Elves get Outland + Quel’Thelas and the Forsaken get the rest of Azeroth?

The betrayal should occur as an unannounced major world event preceding the release of an expansion. The expansion’s name should be announced as one thing up until this point and then a change of name alluding to the Betrayal should be revealed.

The Alliance will also splinter apart. The two problem races on the Alliance side are the Night Elves and the Gnomes. I believe that the gnomes will separate relatively peacefully, finally having built up enough resources to re-establish a new city over the ruins of their old capital. There will be nothing personal in the separation, just a differing of opinions and a desire to get back to their own lives – and out of the war.

The Night Elves aren’t very nice people. They’re also not very well grounded in the subtleties of reality. They have their own major agendas and eternal hatreds to pursue. I suspect that with the undead/belvish betrayal happening, with the gnomes withdrawal from the Alliance, and with whatever else is happening in the game universe at the time, the night elves will become fed up with Stormwind and Ironforge’s general lack of action. They will want to strike out on their own and escape the constraining influence of the other peoples’ religions.

I suspect that the Tauren will also become fed up with the warchief’s poor judgement in admitting any and all strays. They will separate from the Horde in a similar manner to the gnomes’ departure from the Alliance. Thunder Bluff will maintain friendly ties with Orgrimmar, but will no longer war against people like the Night Elves simply because Thrall says so.

The three splinter races (gnomes, cows, and nelves) will probably become something like the goblins. Actually, I wouldn’t be surprised in the least if Undermine opened and goblins became a playable race at this time. My prediction remains the same whether or not this happens, but it’s more fun if it does, so I’ll just assume that goblins become playable ;)

Balancing The New Factions

With the events of the Betrayal and the more peaceful splinterings of races, we wind up with a list that looks something more like this:

  • Horde – orc, troll
  • Alliance – human, dwarf, draenei
  • Betrayers – undead, blood elf
  • Non-aligned – gnome, tauren, night elf

Now, there are some pretty big balance problems with this. The Horde is reduced to a single capital city and the Alliance keeps three (even if Ironforge’s population drops somewhat).

Population-wise, the current division is 57% Alliance, 43% Horde characters. If the faction lines were redrawn right now, the new numbers would be 33% Alliance, 12% Horde, 23% Betrayer, 32% Non-aligned. Now, these numbers fluxuate wildly between different servers. Terenas (my current server), is 75% Alliance, but Sargeras (my original server) is dead even, and Detheroc (spin-off server from Sargeras where I lived for a while) is actually 65% Horde.

PVP servers in general are the ones that would have the most problems from a wild imbalance in faction makeups (for obvious reasons). At present, however, PVP servers are slightly imbalanced in favor of the Horde (51%). The new faction devisions would have a very interesting effect on these servers: 27% Alliance, 14% Horde, 28% Betrayer, 31% Non-aligned. Tells you something about the general psychology of people who play on PVP servers, ne? They’re all steenking elves and corpses :P

Now, one way to smooth this imbalance out a bit would be to also remove the Draenei from the Alliance. After all, they live on another continent and are only connected to the mainland through a Night Elf harbor and they’ve not got a long history of friendship with the Humans and Dwarves (whose cities are very tightly connected together and may as well be one big town anyway). Moving them would account for 7% of the population on PVP servers (8% across all servers). This puts the imbalance on PVP servers into a much more reasonable 1.4 to 1 ratio of Alliance to Horde – especially when you consider the large number of crazy elves and zombies who’re not part of either “core” faction.

But really, the conflict between the Horde and the Alliance ceases to be very interesting on a grand scale at this point. The real interesting conflict is Betrayers vs EVERYONE. They’d have a similar imbalance, with 3 Alliance/Horde characters for every 2 Betrayers on PVP servers, but the only places where world PVP really matters are chaotic madhouse gankfests where the general server population doesn’t come into play very heavily – Throwing a 3rd contender into all world PVP objectives isn’t difficult at all. Horde would still win with roughly the same frequency, and Alliance would probably lose a bit more often.

I hope for (but realize the improbability of) some way for the newly weakened Horde and Alliance to become slightly less aggro to each other. Perhaps allowing members of the opposing factions to achieve “unfriendly” status with each other.

New battleground games would evolve specifically for the purpose of Betrayer vs Horde and Betrayer vs Alliance action. There should possibly also be a new Betrayer vs Everyone battleground (put 15 of them them in the middle of a map they must defend against 10 Alliance on one end and 10 Horde on the other – Horde and Alliance would be unable to attack each other on this map).

But what of the non-aligned races? They make up a substantial percentage of the population after all.

I propose that they still be allowed to interact amicably with members of their former coalition – achieving exalted status among those factions and that members of the factions likewise still be allowed to achieve status with the splinter groups. However, I also propose that they be allowed to achieve friendly status with members of the other coalition (and vice versa). Non-aligned races would be allowed to max reputation with each other.

What is the trade-off, then, for non-aligned races? They lose the ability to participate in world PVP events (ie, no cows running Halaa), but that’s not much of a loss. They should lose the ability to participate in BG’s unless they personally side with one side or another. You can pick a side and as your rep increases with one side, your maximum rep with the other side decreases.

“Non-aligned” players start off at neutral with their former allied races and at 1500/3000 hostile with their former enemies. At this point, they have a potential maximum rep of exalted with former allies and honored with former enemies. Every rank increase with one group decreases maximum potential rep with the other. Thus achieving friendly with the former enemy factions will actually decrease your rep with the other side down to a maximum of friendly. If you progress into honored with either one, your rep with the other side will drop down to neutral, etc…

Non-aligned players who wish to interact with both sides must be careful not to advance too far with either faction or risk losing friendly status.

Players of different races must be at least friendly with each others’ respective home factions if they want to party together. Guild registration will take some major thinking to iron out ;)

The blood elves and undead are something of a problem. They used to be hostile to the Alliance and vaguely tolerated by the Horde. They have done nothing to endear themselves to the Alliance and everything to put themselves onto the Horde’s blacklist.

I think they should be capped at unfriendly with members of both sides and at neutral with all non-aligned races except goblins.

As mentioned before, I think they should get their own BG’s. But there’s also the issue of Arathi Basin – which is really an undead vs humans conflict. Similar concerns exist with night elves and WSG, but that one’s easier to resolve. I think that it should be possible for all-Betrayer teams to participate in the horde side of AB and for all-NE teams to sign on to the alliance side of WSG w/o necessarily earning rep with the alliance. AV isn’t as much of a problem since it is dwarves vs orcs. Eye of the Storm is draenei vs blood elves, so I think allowing all-Betrayer teams in the horde slot there works as well.

Conclusion

Guilds are the biggest potential casualty from a shakeup like this. Every Horde guild in the game would become severely gimped and most Alliance guilds wouldn’t fare much better. There would be a coup, people would go on hunger strikes, and marches would be organized. They can’t afford to break guilds up.

No, Perhaps this would be best as an entirely new server type – especially if they were very magnanimous with their character/guild transfer policy. It’s more interesting than the way EQ2 handles cross-faction/alignment guilds (which is by simply ignoring that there’s an issue) and far more interesting than a generic ‘coop’ type server (cf DAoC). Cross-server BG’s probably mean that even if you’re undead on a 3-faction server, you can still play with Horde in AV matches.

But whether or not you agree with me… Blizzard is heading in that direction.

  • Blood elves and undead are neighbors, they start off neutral with all other horde races except each other. In life, the leader of the Undercity was an elf from Silvermoon…
  • They’ve been promising us language skills forever now…
  • PvP objectives have moved the bulk of the interesting fighting off into self-contained (controllable) arenas…
  • We’ve had events like the opening of Ahn’Qiraj where the Horde and Alliance cooperated against a greater threat…
  • As you get further and further into the game, you encounter more and more factions that aren’t divided along racial lines…

Could it work? Probably. Will it happen? Probably not. But I still wish it would. It’s hairy enough of a gambit that it just might breathe life back into the game when it starts looking dated and running out of steam 2 years from now.

I love these. I take the screenshots whenever I can. Today’s major web server crash was brought to you by the letters O, O, and M.

Flex API OOM

Coldfusion + Oracle = silly.

Hehe :)

Ok, I’ve not formally announced on here yet, but we have a new house. We’ve been living there for a few days now, the vast majority of our stuff has been moved over from the apartment. It is good. We’re happy. I’m lucky to have had James & Scott to come help me in addition to family when we did the big furniture move on Saturday (3rd).

Warning: The following post contains a detailed account of suffering and death on the part of helpless little animals that many people (myself included) would likely rather not read. You have been warned.

The night before the big move (Friday the 2nd, Penny’s and my 6th anniversary), we saw a mouse. Can there be a greater proof of home ownership than an immediate attack by vermin? :)

Now, I’ve seen mice before. I’ve helped exterminate mice before. But I have NEVER seen a mouse so tiny and cute and adorable as the one we discovered last Friday night. I felt bad about looking for implements of furry little death, but it wouldn’t do to let the critter have free run of the place. Nor could I simply catch and release – he’d just come back inside the same way he managed to get inside in the first place.

Saturday, we sealed up the most likely point of access (clothes dryer vent wasn’t sealed very well) and I laid out the first of the traps – some standard issue poison. Now the poison promised results within a few days. And frankly, with just one adorable little mouse, I didn’t mind it taking a while before it killed him.

Shortly thereafter, as I was helping unpack and move some furniture around the house, I lifted the case to our Gamecube and saw two mice together at the same time. This added a bit to my urgency and I decided to go back to the emporium of death and acquire something a bit faster.

When I got to the store, they were completely out of traditional spring traps. The only things they had were more poison and glue traps. I’d heard that glue traps were amazingly effective so I took a look at the box. The traps claimed to have some anesthetic in them as well… so I figured I’d give them a go. After all, it was only two mice. Two adorable little mice.

I set one of the traps next to the refrigerator and went in to watch the Robin Hood series premiere. After the show was over, Penny went in to get something to eat and discovered that a mouse had already been caught. I took a look and he did seem to be quite sedated. I didn’t pick it up yet because I was kind of squeamish (he was still alive, after all), and because I really had nowhere to dispose of him. A few hours later, as I got a drink of water before bed, I discovered that the mouse was still alive. I got over my nerves and grabbed a plastic bag to wrap him in. He tried to struggle free as I picked up the trap…

The following morning, I set another trap behind the television where we’d seen the two mice together. By Sunday afternoon, the second mouse had been caught. He was a bit tougher than the first one and squeaked occasionally. After an hour or two, I decided that he wasn’t going to go to sleep like the first mouse so I wrapped him in plastic and removed him from the house as well.

The nezumi defeated, we resumed our lives free of the fear that something would join us in bed or crawl up legs or simply infect the house with some exotic disease. It was peaceful, the suffering of the two little mice was almost forgotten.

Then on Monday night, Penny thought she saw a 3rd mouse. Corner of her eye sort of thing. But it was late, she was tired and had been looking for mice for two days straight already. I dismissed it. Eventually, she did too.

Then yesterday she saw the mouse again while I was at work. I set out the remaining glue traps – one by the unpacked computers in my office and one next to the poison in our bathroom. I placed a little cookies in the poison tray. All that evening, I never saw the mouse. Then, at ~11pm as I washed my face before bed, I saw that the trap in our bathroom had worked.

The mouse had gone around the trap, into the poison, grabbed the cookie, and tried to escape across the glue. Naturally, he got caught.

With his little cookie.

When I saw him, he was still actively struggling to get free.

But I was tired and I had nowhere to dispose of the body (we’d been left a present of a completely full trash can by the former owner), so I left the mouse to calm down a bit as I had the other two. I forgot about him and went to bed.

At 2am, I woke up to his cries of distress. I don’t think the anesthetic really worked for him.

This morning, I was a bit late getting out the door, so I didn’t take the time to do something about him as I ran out to work.

At 3pm this afternoon, Penny informed me that the mouse was still alive. Still squeaking. Still struggling to get out of the trap.

Still in possession of his little cookie.

I am never using glue traps again. They may be amazingly effective… but… I like to think that I’m a bit too human to voluntarily do something like that to another mammal again.

Maybe live traps aren’t such a bad idea after all. I can always take them to the park before letting them go.