May 24th: Bitwiser

After testing out the bitwise operator I made some improvements. Testing with a million-bit long set, performance seems really good. A million get operations takes about 17ms over the control function, and a million set operations takes about 33ms. That’s high enough that I could do a million set operations for each frame, which I probably won’t need to but it’s good to have that headroom.

Earlier tests weren’t quite so favorable, and I made a bunch of optimizations to get it where it is now, so the current code of bitset follows:

class BitSet
{
public var length(default, set):UInt;
public var contents:ByteArray;

public function new(length:Int)
{
contents = new ByteArray();
this.length = length;
}

private inline function set_length(val:UInt):UInt
{
contents.length = val >>> 3;
return length = val;
}

public inline function get(index:Int):Bool
{
return (((contents[index >> 3] >>> (7 – (index & 0x7))) & 0x01) == 1);
}

public inline function set(index:Int, val:Bool):BitSet
{
contents[index >> 3] ^= (val ? 1 : 0) << (7 – (index & 0x7));
return this;
}
}

Much terser now, though a bit hard to read if you’re not super familiar with bitwise operations. I think this is about as efficient as I’m going to be able to make this.

Aside from the bitset, I went ahead and added more pseudocode to the rough game project. Tomorrow I’ll see if I can get the update loop up and running: This is going to be the trickiest part, so it may take me a while and become very frustrating. We’ll see.

EverEnding-wise, the left-facing run animation continues to be a work in progress. I thought I’d finish it today but it’s still got a little ways left to go I think.

Advertisements

About problemmachine

What is the nature of your problem? Can we modify the nature of your problem? Can your problem be touched? Eaten? May we eat your problem for you? May we eat your soul for you? Would you like a replacement problem? We make problems. We eat souls. We crap solutions. We are Problem Machine.
This entry was posted in Animation, Daily Update, Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s