Gruepal – Lurking Horror Bug Fix

Just a quick update for those following along – I had a bug when running The Lurking Horror that would put the game into an endless loop upon pressing one of the buttons on the microwave.

The issue was an honest problem with one of my algorithms. Objects in z-machine games can have properties that tell the game things about them (things like descriptions and exits). Well, I wrote my code to assume that all objects have at least 1 property, when it truth they don’t necessarily, and it bit me in this case. The loop ran past where the object ended (since it was looking for properties where none existed), and general mayhem ensued. Fixed now. I can now cook things in the microwave.

A Thought on Efficiency

WARNING
This borders on a rant – I get into moods where I like to rant, and this is one of them. Treat it accordingly ๐Ÿ˜‰

A (semi) quick thought before I go to bed. There are times in my technology filled life of smart phones, streaming, bluetooth, web 2.0, multitasking, scheduling, interoperability, synchronization, single sign on, and coordination that I honestly just get sick and tired of being efficient all the time. I understand the theory in that by working smarter, not harder, you can get more done – but what’s the point?

People have a lot of reasons for being more efficient – one of the major points: getting more done in a shorter amount of time. The theory is that we either don’t like doing crap, or there is a reward for doing crap, so we devise ways of doing more crap in less time so we have a bigger reward – this reward being the extra free time we saved from doing the crap quickly, or a payment we received in exchange for doing the crap.

The Fisherman

One of the problems that comes into play is we usually take the time we’ve saved by being efficient and put it back into activities surrounding the crap again – either working more or devising even better ways of being efficient for work in the future.

My friend Leah had read me a story once, and I’ll do my best to only semi-misquote it here. It concerns a business man talking to a guy fishing on a beach. The conversation goes a little something like this:

Businessman: Why don’t you go get a job, you lazy fisherman?
Fisherman: Why should I get a job?
Businessman: So you can make it into a career.
Fisherman: Why should I have a career?
Businessman: So you can climb up the ladder, make a lot of money
Fisherman: Why do I need a lot of money?
Businessman: So you can invest it, build up a retirement fund
Fisherman: Why do I need a retirement fund?
Businessman: So you can live out your final days relaxing, fishing on a beach somewhere

Obviously the story leaves out any points of the fisherman having a family, responsibilities, or supporting himself, but the point is still there. The dig here is not against business, but the attitude of the businessman, this “prerequisite of happiness” thing where you’re constantly working to get to somewhere that can be reached without doing all that crap in the first place. The bigger paycheck, the larger office, and the faster car always seem more appealing from far away, but when you’re actually there, they give no happiness compared to the proverbial sitting on the beach and fishing. And if that truly is the goal, then why not cut out the middle man?

The Driving Force

We live in a nation of bigger, better, faster, compete, win, more, more, more. It’s driven into us in a number of ways – we must excel in all that we do. Our country’s finances operate on capitalism, and it’s a survival of the fittest game. And while this drive pushes us to achieve amazing things and delivers us glory, does it truly make us happier in the long run? Especially considering new abilities are often paired with new issues?

All this is the subject of a much more detailed and lengthy article than I could write, and I’m definitely not arguing against progress. But there are many times in my life when I want to unplug – when I’d rather hand write a letter to a friend than send them a Facebook message, or give them a call on the phone instead of text messaging them. There are times when I don’t want to be the fastest or the best, I don’t want to be connected wherever I go – I just want some quiet, some peace, and some happiness.

I think what it really comes down to is needing balance – it’s something I’ve been working on quite a bit the last month or so. As odd as it sounds, I need to put more fisherman into my life.

Playstation Home Initial Thoughts

Like many PS3 owners, I didn’t waste any time trying out the new open beta of Playstation Home when it went live a few days ago. Due to large influx of users when the service initially opened up, I was unable to get on right away, so I spent some time on the net reading the initial responses of those lucky enough to manage to get connected early on.

I found the typical mix of those screaming about how much the service sucked, what has Sony been doing for the past couple years, why do I have to pay 40 cents to buy custom clothes, Playstation Home is the anti-Christ and should be destroyed, etc – and those defending the other side saying it was still in beta, it’s a free service, shut up, etc.

Reality is usually somewhere in between (though I side more with the “shut up” people – those who honestly complain that much about a free, beta service are in need of a serious dose of life-priorities), and eventually I got online and was able to gauge things for myself.

Visuals

The first area you encounter when logging in for the first time is your apartment, which you can decorate with different furniture, wallpaper, devices, etc. It overlooks the sea and its pretty serene. The graphics, as have been commented on, are fairly good – definitely not the best of what the PS3 can pump out, but considering the CBE is taking care of processing a complex, semi-unpredictable MMO environment, they are very good. In other areas such as the mall and movie theater, Sony has incorporated videos onto screens, and they are clear and crisp.

Speed

With all the nice visuals and player processing, the PS3 does remarkably well with little lag (that I saw). The only time I noticed lag was first entering into an area when I’m sure initial setup was going on. Past that, running around the square or the mall, everything was very smooth.

Communication

Home supports keying in text from the controller, using a USB keyboard, or a USB microphone. I tried both the controller and a keyboard. Keying in things from the controller is definitely a huge pain and limits the amount of communication that can go on. There are some preset messages that help a bit, but they only get you so far. After hooking the keyboard up, I definitely had a lot easier of a time talking to the couple other people I could tell had a keyboard hooked up, but I’m guessing the majority of people (for now) are only using a controller. I did hear a few people voice chatting in the game, and that seems like a great option as well for people who don’t mind having their voice heard. I may try with a headset next time.

Entertainment

I personally am not so big on chatting – I rarely use AIM during my personal time, and prefer email or non-real-time messaging such as Facebook. So while talking to people was enjoyable for a little while, I was looking more at Home for other entertainment it provided like online games, such as bowling, pool, and video games found in the bowling alley. The arcade games available include a break-out clone, echochrome, and dropping blocks/match up style game called “Carriage Return”. They were fun for a bit, but I probably enjoyed bowling the most. Up to four people can play per lane, the interface isn’t too bad, and you can chat/heckle while playing, its pretty fun all in all.

Overall

Home is interesting – I hesitate on making any final judgment since its in beta and a lot of content/areas aren’t available yet. For me, I think if Sony opens it up more, adds more consequential interaction/games it will be more enjoyable. I don’t see myself using it too much until that happens aside from bowling every once in a while. Dancing in the music area is kind of funny to watch (as 50 people line up and do the running man), but even that gets old after a while. I think Sony could do a lot of things with home, add parks with chess/checker boards, add go-kart arenas with racing, minigolf, etc – I think that could be a lot of fun. We’ll see how it goes. All in all, its a neat experience for now, and holds a lot of potential – I definitely don’t see it being the travesty a lot of other, less forgiving PS3 owners do.

Website updates

Hi All –

I made a few updates to the site to hopefully make things a little more informative/usable. I’ve added the following:

  1. A comment subscription plugin, so when you leave a comment, you can sign up to be notified via email if anyone else comments (either a response from me or other users commenting). These comment subscriptions can be managed and removed if desired. I did this as there is no real way right now of knowing if someone replied to your comment without constantly checking back at the site.
  2. A project page for my Drupal z-machine project, Gruepal. It describes the project so far, goals, and has links to the devlog.
  3. A link on the main page that shows all posts, newest first. This is a shortcut from going to each month’s archive.

As always, thanks for reading, I hope I’ve provided some helpful information/entertainment through my posts over the past year.

DrupalZM – Bug fixes and name update

First off, I’m renaming the DrupalZM module to the “Gruepal” module (ala Grue from Zork mixed with Drupal), thanks to Seth Cohn for the idea. Subsequent posts with be prefixed with Gruepal.

Also, a few bugs squashed, two of these took a while to track down, a lot of sloshing through zcode assembly –

Planetfall Endless Loop

While Planetfall would start fine, whenever I tried to do anything (move, look, wait, anything), the game would go into an endless loop. Upon tracing through an execution dump, I noticed that it kept comparing variables that were initialized from the random number opcode. For the loop to end, it needed to NOT match a range of numbers, but it was always matching, so the loop continued forever.

It turned out that the RANDOM z-machine opcode is inclusive in its range. I misread this originally, I thought if you specified an upper bound of, let’s say, 8, it would generate a random number from 1 to 7 (e.g. up to 8), which is the C programmer in me, everything is 0 based in an exclusive range (e.g. 8 would be 0-7). I did the see the part about it starting at 1, but not about including the upper bound of the range. In the Planetfall case, it was passing in an upper bound of 7, but I only generated 1-6, and the code was looking for a 7 to exit out of the loop, so it never did. I increased the range to be inclusive, and life was good. Which is good, because Planetfall rules, and I found myself playing quite a bit when I was supposed to be debugging. ๐Ÿ˜‰

Take All Endless Loop

Another issue I noticed was in any game, when I typed “take all”, it would go into an endless loop. This was a REAL tricky one, because the loop wasn’t a tight one, it covered about 100 operations before looping. I nailed it down that the loop wasn’t exiting out when comparing the return value from a function that reported back the index number of the item number in the room to take (e.g. if there were 5 items, it would loop through 1 through 5, taking each item. But in my case, it would just get stuck on keep trying to take 2 over and over again because the iteration counter wasn’t increasing).

The reason is, there’s a little gotcha in the standard CALL opcode which, again, I did know about, but only implemented half of (by mistake). Normally a call statement is for calling a new subroutine – it saves all the information of the current call onto the stack, then (in my implementation’s case), creates a “call record” which has the return address once the subroutine exits and some other info.

Well, normally CALL has the address of the subroutine to set the PC to. However, there’s a gotcha that if its called with 0, it simply returns FALSE and doesn’t actually perform a call. This is to make certain operations in the game easier I imagine, when you need to dynamically call subroutines, and 0 indicates end of list – the false would stop the loop from going. Well, while I did return false, I unfortunately still overwrote part of the call record (which would happen if it was a normal call). But it overwrote the current call record instead of a new one, which could have caused any amount of havoc – in this case it just caused a loop. But I fixed that, and loop is gone.

Kill Me Bug

This one was easy. When I typed “kill me”, it would say “What do you want to kill the me?” instead of the correct “What do you want to kill the me with?” – e.g. it left the “with” out. Leaving words off I’m sure came up in other places, this was just how I found it. The issue is – there are a few opcodes that print to the screen, maybe 5 or so. 1 of them was passing the array with the output buffer by value instead of reference, so even though it was adding the word “with” to the output buffer, when the function exited that would be lost. Just a typo of one character, after adding a & for pass by reference, life was good. This was the bug I thought was having to do with zscii conversion, but it wasn’t!

New Found Bugs

A few more bugs to squash:

1. In lurking horror, using the buttons on the microwave puts the game into an endless loop. I have no idea what’s causing this yet without looking through an execution trace.

2. In Moonmist, when asking the user for their favorite color, it puts a weird symbol before the color repeated back to the user. I’m guessing this is a zscii/zchar issue.

Fun fun!

DrupalZM – Status Line

Unfortunately I came down with a nasty cold yesterday, but did manage to finish up the AJAX functionality tonight, including the ability for the page to redirect instead of displaying content (in the case of when the game is restarted/quit – in these cases the browser redirects to another URL which resets the game and sends the user back to the game description screen if they’re quitting).

Also, I implemented the status bar and got that working with both normal page refreshes and via AJAX. Additionally, the current room, score, and moves is now stored in the machine state database entry, which means that its possible to see where everyone online currently is and what the high scores are for all games.

Here’s a quick screenshot of a Zork I screen with status bar. You can see the beginnings of the save/load block as well, though more functionality and cleanup will be going into that.

DrupalZM Screenshot 1

DrupalZM – AJAX

Just a quick post, I have most the AJAX functionality done. I need to clean up a few little things like making sure the output window is always scrolled to the bottom, and handling when the page needs to redirect (in the case of game restarts/quits), but otherwise it works well.

TFNN – Virtual DNA

You may be wondering what TFNN is – it stands for Temporal Frame Neural Network, an artificial intelligence project of mine to accurately simulate the biological brain. Sadly, I haven’t worked on it in a few years for a number of reasons – reasons that were good at the time (and I wouldn’t change, the whole learning experience thing), but ones that aren’t so important now.

What the Heck Happened?

Jumping off topic a bit, but relevant to why I’m starting back up again, I realized a few weeks ago that I’m not really happy with the way my life is going. I mean, don’t get me wrong, overall things are great and I’m doing okay, but there is definitely something off. There are a few reasons, but one of the biggies was I was always doing things I felt obligated to do and never did things for fun anymore. I was always taking on a project to advance somehow, and never did it for the art or to enjoy it. I was always working hard, but honestly not really wanting the outcome, so it would never really go anywhere. I’m not a business man – I don’t like or want to play the game (There’s another article in here about not always turning your hobbies into something you get paid for, but that’s for another day). There’s nothing wrong with being a business man mind you – I’m just not one.

So I made the decision to just stop worrying about “succeeding” in these classic ways that are good for some people, but not for me. I learned something big from Shredz64 – I will never make any money off the project, but I had an incredible amount of fun doing it, and I have made so many connections with people because of it – it’s just amazing. I want to keep doing that all the time – I want to make things – not worry about marketing or selling them – I just want to create and share. I’ll save the rest of my thoughts for another post, but the bottom line is, I’ve already started working a ton more on my projects and I’ve been much happier because of it.

Back to Virtual DNA

SO, that being said, I recently made a 10 hour drive to and from Toronto, and it gave me a lot of time to think. Some of that thought was dedicated to the TFNN project. While the “neurophysiology” of the TFNN works great on a neuron and connection level, the overall issue remains in how those synaptic connections are made. Their configuration. Biology has a great thing going for it with DNA that controls neural development – during the neurulation phase when the neuroectoderm forms a lot of things happen, but at the end of the day through migration, axon paths and some other tricks, neurons are placed into their proper locations and form appropriate connections. Regardless of the nature vs nurture argument, there is definitely prewiring that is done. It’s the reason why a cat will never develop the ability to speak Romanian and why rabbits breathe without being trained to do so – it’s millions and millions of years of neurological evolution packed into a double helix.

Therein lies the problem – I have the materials with TFNN, but no blueprint I can use to construct something. I can make very small and specific networks, or very large, random ones, but neither of those will accomplish the goal of creating animal intelligence. So a blueprint is needed. Life has DNA, but what does TFNN have?

Use Real DNA?

My first idea to conquer this issue (as outlined on the project page) was to use some of the sequence databases that are available online – there are a couple species that have a very full nucleotide sequence documentation available. I won’t even bother mentioning all the reasons why this was never going to work, because the biggest reason is, I’m not a molecular geneticist, and while I have a good understanding of how DNA works, I don’t come close to having enough understanding to use DNA sequencing information to form a TFNN. It’s another project that I would love to start one day to build my understanding of the process, but not right now.

Let the Turing Machine Do What it Does Best

What I decided on the car ride was instead of using real DNA, it would be more realistic (relatively speaking) to create a virtual (accelerated) environment where evolution could take place and form virtual DNA. The TFNN already has rudimentary functionality for building neural networks from a list of instructions, so this is doable. Here’s the very lofty plan:

  1. Flesh out the matrix class inside of TFNN to construct neural networks as defined by encoded, segmented bit sequences. This will be some work but I have a good idea of how to accomplish it. There are already class members that control size, synaptic density, geography, and even connection specific formation within the neural matrix – the bit sequence needs to drive these member functions. The purpose of something encoded like a bit sequence as opposed to human readable scripts is to allow for easy engineering of mutation capabilities necessary for evolution
  2. Find a lightweight, open source graphics/physics engine. There are a few of them out there for games – it doesn’t need to look good or even come close to being the most advanced one available, it just needs to support a number of attributes common to our world such as mass, gravity, displacement, etc. The key is lightweight as possible, we don’t want to eat up CPU maintaining the world, we need all the cycles we can get for TFNN processing
  3. Engineer a method of recharging a lego NXT robot (Bit, my little LEGO robot will be the subject in these experiments) that can be initiated and completed by the robot itself. There are a number of ways to accomplish this, something tactile is preferred to force movement. Something like a magnetic connector with DC current. It would also need to produce a distinct stimulus to indicate it was a source of “nourishment” so to speak, such as producing an audible tone at a specific frequency .
  4. Create a VDNA (virtual DNA, easier to type) sequence to form a neural network that dictates motor control to guide robot to its “feeding station”. It doesn’t need to have any logic outside of a straight path for the source. I’ve created simple neural networks like these before and it is doable.
  5. Within the physics engine, model an environment that very simply and basically models a real world environment. The goal is by no means to have every possible physical scenario that could exist in the real world, its to offer enough obstacles and stimulus that evolution can take place, while using obstacles that are common to the environment the robot will operate in. Also include feeding stations
  6. Build an engine to generate instances of TFNNs using VDNA sequences and process them. Connect them to virtual robots modeled after the NXT lego robot and place them in the virtual world. Also include functionality to take the VDNA of a specific instance and spawn a new instance of the virtual robot. We could do this asexually or start with a neural configuration that drives two robots to touch in a manner that shares VDNA for virtual reproduction – I haven’t decided on this one yet. Regardless, new VDNA is subject to random mutation or corruption in the bit sequence
  7. Build in parameters that cause death in the virtual robots as well as prevent premature reproduction – most importantly that reproduction doesn’t take place if nourishment isn’t obtained.
  8. Run this simulation until results are obtained
  9. Take VDNA from successful virtual robot, generate instance of TFNN, connect to Bit and watch the fun

I can’t complain about being bored, that’s for sure – I will post here as I go. It may lead nowhere, but I’m extremely interested to see the results – even if it completely fails, it will still be fun science.

DrupalZM – Save and Restore

Things have been a bit hectic lately – with the massive cooking and cleanup of Thanksgiving, and preparing for the TPUG WoC expo (and driving to and from Toronto to get there), I haven’t had a ton of time to do much coding. I did manage to slip in a couple hours last night and finished up the save/restore code.

It was actually pretty easy – what’s nice about DrupalZM is since it’s being driven from the web, it needs to save the state of the z-machine to the DB every page refresh. The save/restore code simply copies the current state of the machine to a save slot. Specifically, the table that stores the state of the zmachine now has a “slot” field associated with each record. Slot 0 indicates the current state, while slots 1-9 are saved games. Anytime a game is saved, DrupalZM simply copies the record in slot 0 to the desired slot, and restoring does vice versa.

I’m implementing a simple block to allow for easy saving/restoring. Classically one would type “save” or “restore” during gameplay, but typing these commands out in DrupalZM instructs the player to use the functionality in the block. The block will make saving/restoring much faster, plus an added bonus is the screen buffer is completely stored during the save process, so when a user restores a game, it shows them all the text on their screen exactly how it was at the time of saving.

To Do

Most of the zmachine is functional for versions 1-3 of zcode, but the following is still left to do (not necessarily in order of how I’ll tackle it):

1. Debug current issues (picking up “all” items seems to fail, zcharacter->ascii translator is still missing small bits of functionality, out of the 3 games I’ve tried, 2 work but 1 gets caught in an endless loop processing upon issuing the first command)
2. Finish all opcodes for versions 4-8 of the zmachine
3. Implement an AJAX interface
4. Finish the save/restore block
5. Implement room location/moves status bar (as well as exporting this with scores to be used elsewhere on site (e.g. location of currently logged in users, high scores per game, etc)
6. Experiment with extra functionality (quasi-multiplayer, automapping, integrating zmachine objects with drupal nodes/fields)

Shredz64 – TPUG’s WoC tomorrow, demoing Shredz64

Just a reminder, if you’re in the Toronto area (or have a sick obsession with driving long distances like me), TPUG’s World of Commodore expo is tomorrow (12/6/08) starting at 10. I will be demoing Shredz64 and will have a few PSX64s available for purchase. Also, there are a lot of other neat demos going on by some talented guys, lots of stuff to buy, and good conversations to be had, so stop by if you want to join in the retro fun.