Profile cover photo
Profile photo
Thomas Green
I wasn't aware I needed a tagline...
I wasn't aware I needed a tagline...

Thomas's interests
View all
Thomas's posts

Post has attachment

So tonight I finished a class project that I guess I could consider my next greatest accomplishment in becoming what I would consider a real programmer.

In the last week or so, I spent every spare moment programming a model of a chessboard. It was for my AI class. Previously we were solving 8-puzzles, and I had designed a simple model of an 8-puzzle that you could use to check valid moves, and to make a duplicate of itself in its next set of valid states.

It made state-space tree traversal extremely convenient, and it stored all its data in a flat string that looked like this '12345678_'. Took me a good hour or two, but it was simple and effective.

This chessboard model on the other hand was a bit more complex. So far this is probably one of the few times I've worked in a team in college and it was more of a help than a burden. So, one of the four other guys I am working with spent a few days to write routines for generating movement masks for a bitboard setup.

In case you're not familiar with bitboards, it's not too rough. A binary representation of a chessboard, divided up by team by piece type, so twelve in total, are stored in sixty-four bit integers. Sixty four bits is enough to hold in binary representation all sixty four squares on a chess board.

So all the rules, instead of being stored in code logic, are derived from these masks; piece location, movement masks, and some ray-casting trickery to make the sliding pieces work properly. We've since dumped and hard-coded all these masks.

However it holds no state information, so moves like en passant and castling are off the table. I'm not sure why, but it seems to be the way the framework that we'll be using works. So it does this all fresh, all generated from the board we're given, and the last enemy move.

About a thousand lines of code later, and I've written a whole bevy of functions that end up to doing some neat tasks for the part of my crew that will go on to write the AI for the thing. You can move pieces around, indiscriminately, with limitless(memory limited of course) rollback capabilities. This is designed for speed as you want to be able to move as quick as possible for traversing state-space trees. It all also has very little bounds checking, so we have to trust what we do to pass the proper parameters.

It can also check for any valid move or attack from any active piece. You can check to see if any particular square is under threat, or of course whether a team is in check. The final culmination of all this is a single function that will take its cues from the current board configuration and generate all available moves for all pieces on whichever specified team.

If there are no valid moves generated, check-mate.

... and it does all this incredibly quick. The data it retains and can generate for any move is very thorough. I've incorporated six different attributes other than just source and destination locations. Things like whether the move is a capture, does it take you out of threat, or put you in it? It will all be used to weight each move in order to pick the most advantageous.

Which is good as we will use our AIs to go head to head with the nine other teams in my class. Only one of which did a bitboard configuration, and from discussing it with some of their team-mates, I'm not sure they're gonna pull it off.

OH! Finally: one of the kids on my team does nunit testing for his job, and... I have to say again, everyone on my team is sharp as a tack, and I can't tell you how lucky I was to get who I did... Anyway, he's already generated thousands upon thousands of unit tests and we've weeded out enough bugs where I'm pretty sure we're gonna win...

Post has attachment
Revisiting this today. The guy who made this is a mad genius, literally.

"TempleOS is an x86_64, multi-tasking, multi-cored, public domain, open source, ring-0-only, single-address-map (identity-mapped), non-networked, PC operating system for recreational programming."

...and my favorite line...

"I capped the line-of-code count at 100,000, so it will never be ugly. Currently, it is 81,047 lines of code.  God's temple must be perfect, so backward compatibility is not promised."

If you are interested, check out his youtube channel too -

It runs in a VM superbly. I have this man to thank for my interest in low-level coding.

Post has attachment

Post has attachment
Zachtronics has released another genius game. I always hate sounding like I am advertising for someone else's product, but for those of you who ever wondered what it's like to program in Assembly, this is the puzzle game for you.

Billed as, "The assembly language programming game you never asked for", TIS-100 gives you a Turing complete instruction set and then presents you with puzzles to to solve with it. 

I know what you're saying. "But Thom, given enough lines of code for any Turing complete language, I can do anything..." Well there's the catch. The catch is you have to do it in a series of 'nodes' that pass data back and forth. And you have only 1 register, and a backup register per node.

Each node only allows for so many lines of code before you have to offload the work onto the next node in the chain. You'll be given problems like, "Take input from input.a, a zero delimited string of numbers, and output only the largest, and smallest number."

Here's an example of a function I wrote that returns the absolute difference of two values.

#ABS(x-y) =

Short explanation by line #.

1. Anything beginning with a # is a comment.
2. Move any port input to the Accumulator(register). 'S:' is a label for jumping and for me it stands for Start.
3. Subtract the input from the accumulator coming in on the same port(last).
4. jump to 'N' if the result is lower than zero. (JumpLowerZero)
5. Move the accumulator (also the result!) to the output
6. Jump to 'S' or start.
7. N: Negates the value because we need a positive answer.
8. move the negated result to the output.

From there the instruction pointer returns to the top and is ready for the next set of numbers.

Okay, gotta admit, I really, really miss OneNote. I wish the Mathematics plug-in was LaTex, but other than that it was fantastico. If only it worked in Linux too.

If anyone has a good suggestion for a decent, equivalent piece of note-taking software, I'd surely appreciate it. It doesn't have to have Equation support like LaTex or MS Mathematics, but I should be able to past images in that I generate from other LaTex applications like EqualX.

Oh, cross-platform is a bonus. Linux support is a must. I just got done abandoning Zim Notes, CherryTree, and right now I am trying out BasKet.

Post has attachment
A little obsessed with ASCII and text at the moment.

Post has attachment
This one is mostly for Monty, but music buffs will find it interesting too...

For a while I was obsessed with this song. I'd become acutely aware of it being a notable part of my childhood about ten years ago. Over the period of about 4 years, I had the song bouncing in an out of my awareness, only able to glean parts of it from my memories.

During those four years I went from thinking I imagined this song to knowing who performed it. I remember having it go in and out of my memory for about a year, then one day I was in an Albertson's and they played it over the PA system. I spent the next two weeks trying to figure out who it was. For a short time, until I verified that it wasn't, I thought it was a McCartney song. It did sound a lot like Wings.

Anyway, I saw this on Reddit today, and it made me realize just how amazing this one song is. I'd explain how amazing it was, but that would negate the point of the watching the video. But I will at least mention this:

The most amazing part; the backing chorus. For the longest time I thought it was a synth. But they actually made a musical instrument out of a 16 track recorder using multiple vocal tracks layered. So what you're hearing, is three people singing, per note represented by one track looped repeatedly. Sixteen notes, and to play each note, they simply used console faders to drop the one being played, and slid up the one they wanted to play next...

Genius, and one of the most unique sounding tracks released in the 1970s. I hope you enjoy this as much as I did.

Post has attachment
I doubt there is anyone interested in game programming that hasn't heard of this book... but for those who haven't, read it. It's the game programmer's interpretation of the Big Four's more popular patterns.

Oh, and it's free online.

Post has attachment
In case anyone is interested, not trying to advertise for them, but Black Sabbath's newest album... the first studio album with Ozzy, Tony, and Geezer, (Ward couldn't make it due to contractual obligations) in 35 years... It's absolutely fantastic. It's like they took up right after Vol. 4, instead of declining in to the bickering and eventual break up they did. I suggest if you are remotely interested, give it a listen.
Wait while more posts are being loaded