The Liberated Pixel Cup! – Dev Blog 2

It’s been a slow start, but hopefully things will start to move a bit faster. I am on vacation for the week and I have managed to get some work done.

I spent several days trying to figure out the best way to represent Actors on the world maps where the player can walk around. The Actors walk one tile at a time, fitting to the grid, rather than having “free” movement where Actors can move by any increment. It is much easier to implement free movement (which is what I’ve done in the past) than tile movement. I re-wrote the code that handles all of this several times before I found an implementation that was clean and functional enough.

In this screenshot there are several randomly spawned Actors that have walked to random places on the map. They do this by using the A* pathfinding algorithm I talked about in the previous post. There is an Action class that actually performs the walking animation. This Action is smart enough to re-route upon collision with another Actor.

The player can touch/click on a map tile to walk a path to it. For desktop users or certain Android devices, the D-pad can also be used to move the player around on a tile-by-tile basis.

I have also started work on an interaction and dialog system. In the screenshot, the text box shown is a result of the player interacting with the sign on the building. Right now the text box only displays one string of text, multiple strings and maybe even branching dialog paths still need to be done. Item chests are on the to-do list as well. Hopefully I can get them done soon.

The Liberated Pixel Cup! – Dev Blog 1

Image

The time is finally upon us. The art portion of the Liberated Pixel Cup has reached its deadline, which means that the programming portion of the contest has begun! The competition is a month long in which us code monkeys need to use the art assets that were generated to make the best possible game that we can. Since this pixel cup is “liberated”, all of the source code will be available under the GPLv3.

I am working with someone that I only through IRC (#liberatedpixelcup on Freenode) with the nickname of fr33mind. We will be making a Pokemon inspired game where you control monsters to use in combat. The actual gameplay details will get fleshed out more as the competition goes forward.

We are using libGDX to make the game. LibGDX is a fantastic Java library that allows us to write a game that runs on the desktop (GNU/Linux, Mac, Windows) and on Android devices with very little platform specific code.

Above is a screenshot of my experiments with libGDX. Here you see a path of ghosts that was generated by my implementation of the A* pathfinding algorithm. It took a long time to wrap my head around it but it is a crucial element to the game considering that users will move across the map not only with arrow keys, but by touching/clicking areas on the map (my Android phone has no D-pad). This makes decent pathfinding a must have so I wanted to try to get it out of the way early. The code performs well on the desktop but for some reason takes about 3 seconds to run on my Android phone, which is a serious problem. My choice of data structures or too much memory allocation could be the problem and I need to investigate who the culprit is. I’m using a PriorityQueue and a HashMap to maintain lists, and a Pool (in libGDX) to minimize memory allocation, yet the problem persists.

I’m going to try to keep this development blog going over the course of the month with screenshot updates. Let’s see if I can manage to actually do that.

UPDATE:
Turns out the performance problem was because of how I was drawing the path on screen and NOT the algorithm itself. I have since abstracted away the things that are dependent upon a specific tile map implementation and have a rather generic set of classes to use for pathfinding.

Life Updates

I haven’t posted here in awhile and I would like to attempt to blog every now and then. I don’t know if anyone in the CS department besides the fabulous Karl Wurst reads the WSU CS planet feed, but if any of you undergrads are reading this: good for you. I like you.

Now that I have graduated (yay!): What’s next? I’m still working as an intern at Cyberonic but I think it is time to move on. I have gotten a resume together finally and posted it on Monster and Indeed yesterday and on my way into work today I got a call from a man who had 4 job offers for me. Not bad for one day, eh? A lot of the job opportunities that I have been seeing are for web developers, particularly Ruby on Rails developers. Now, I have dabbled with Ruby on Rails in the past but I don’t know much about Rails or Ruby. I’ve always been a Python guy. So, if you’re an undergrad reading this: LEARN RUBY. DO IT NOW. A lot of programming jobs in Massachusetts are in Boston so I need to try to move east a bit and close to the highway to ease my potential commute to work.

I have started to contribute to some FOSS projects finally. I am starting to become involved in the GNU MediaGoblin and GNU FM/Libre.fm communities. They are both free as in freedom web applications that I want to see mature in order to bring more free culture to the web. MediaGoblin is a YouTube/Flickr/SoundCloud/etc. replacement for hosting different types of media files and it is AWESOME. GNU FM is a last.fm replacement for streaming music and “scrobbling” your played tracks to your online profile. Currently the main GNU FM instance is Libre.fm, featuring lots of freely licensed music to stream. Both services have a goal of becoming “federated”, meaning to have a distributed network of instances that talk to each other. I have a vision of glueing the two services together somehow to make a free as in freedom service for musicians (such as myself) to share their music, pictures, videos, podcasts while giving regular users a place to follow the musicians and scrobble their listening habits. Maybe someday.

I’m also getting involved with Liberated Pixel Cup. A game development competition with the goal of making more freely licensed games and artwork. Many thanks to Creative Commons, OpenGameArt.org, and the Free Software Foundation for making this all happen. The art competition is taking place this month and the programming competition begins in July. First prize is $1500 and second prize is $500. I’m hoping that I can make a fun game and just maybe win some prize money if I am lucky.

Finally, my punk rock band, Get the Fear, has been doing well. We’re playing some very cool shows and are writing more original material in hopes to record a full length album before the year’s end.

All in all, things are going well. That said, I can’t wait to take a week off from all of this work in July when I go to Maine.

CS401 – We Have Liftoff! (and other news)

Took long enough, but we now have a working cloud!!! It’s been a real struggle to learn the proper way to configure and install things to get the whole system to work properly. Applying what I learned from Andy Grimm and taking his advice to install Eucalyptus 3 via packages rather than building from source, I was able to start fresh and have a functioning cloud in a little over an hour. I was filled with joy when a classmate succesfully launched a VM instance and logged into it via SSH.

Too bad that the semester is nearly over now. Oh well. I need to finish up my documentation for how a newbie can create a Eucalyptus cloud. I was really hoping to get into some source code before the semester was over but that is just not going to happen. Even though I haven’t written a line of code this semester, the course has been invaluable. I am now far more comfortable interacting with software developers via IRC. I have learned a good deal about Linux system administration through failing over and over again. I still hate writing documentation, but now I have gotten a little practice at least. 😉

Hopefully I can wrap up my documentation project soon and get working on the final assignments for the course: an ethical analysis of Eucalyptus and a slideshow presentation about the work I did over the semester.

In other news, the WSU programming team (of which I am a part of) got 4th place out of 27 at the competition held at Quinnipiac University! We solved 4 (nearly 5) out of the 6 problems. I wasn’t expecting such a high so it came as a pleasant surprise to see that we got 4th. This was my last year on the team so I’m glad we performed well for my final competition.

Oh, before I forget: after this semester is over… I’m done with undergrad! Which means I need to find work, preferably developing FOSS. Just need to finish my resume. So, who wants to offer me a job? 🙂

CS 401 – Quality Time with Andy Grimm

On Thursday, the 19th, Eucalyptus developer Andy Grimm paid WSU a visit. Other students and I ate lunch with him and our department chair Karl Wurst. Our lunch bill is being paid by Red Hat, so even if I never work there and get a pay check from them, I can at least say that I had lunch on them one time. 😉

After lunch, Andy and I spent the next 3 hours trying to resolve the various issues that were keeping our cloud from functioning properly. The good news is that I learned a lot about how Eucalyptus works, networking, and some neat command line tricks. The bad news is that our cloud is still not functioning.

As I pointed out in my last post: networking is hard. It is especially hard when working on the university network whose topology is pretty much unknown to me. The first big mistake that I made when I set up the network for the cloud was split the LAN into 2 subnets. The CLC, SC, and CC were on one subnet, while all the NCs were on their own subnet and the CC acted as a router for them. I had misread some networking documentation and mistakenly thought that having the NCs are on their own subnet would make things easier for later on. Andy set me straight about that and I “flattened” the network out so all of the NCs are now on the same subnet as the other Eucalyptus components. Next, we set up ethernet bridges for virtual networks that will be needed for the virtual machines. That was mostly straightforward but through some slight misconfiguration I encountered Red Hat networking hell involving a renamed `eth0` which Andy resolved for me by messing with udev.

I thought that I had a recent enough kernel installed on all of the machines to avoid the kernel bug that breaks Walrus. Turns out I didn’t. So no matter what we did the cloud would never function until that was resolved. A `yum update kernel` and a reboot took care of that. Then, for some strange reason, PostgreSQL processes wouldn’t start. Andy started them manually and things seemed to work just fine for subsequent reboots.

Despite fixing all of these issues and making a ton of progress in such a short time, we were still unable to run a VM instance. Andy and I ran out of time (he had a train to catch and I had to return to work) but he suggested that I essentially start over once again. This time I will be using the Eucalyptus packages that are available from the Eucalyptus repository.

So, another week goes by without a working cloud… but I learned a lot. Many thanks to Andy Grimm for making me a better system administrator.

CS 401 – Networking is Difficult

So I haven’t posted here in awhile. In CS 401 I have been trying unsuccessfully to create a working Eucalyptus cloud. At this point the basic system is in place: The core services are running. Users can sign up for an account on our cloud. Users can upload kernels and OS images. However, when a user tries to launch a virtual machine instance everything falls apart. The instances are forever stuck in the “pending” state.

I was using the “managed” networking mode for Eucalyptus. However, upon testing if the network was “VLAN clean.” I followed the instructions here and alas, the VLAN was not clean. It seems like more of a headache to get the VLAN to function than it is to switch to the “managed-novlan” networking mode.

The “managed-novlan” mode required me to manually configure an ethernet bridge for Eucalyptus to use. I followed the instructions in the Eucalyptus 3.0 Installation Guide and everything seems to work (running `service network restart` shows no errors), but now the Cluster Controller cannot communicate with the Node Controllers. This means that there are no available resources advertised for VMs. So now I cannot even try to start up a VM instance. 😦

I only have basic networking knowledge so these issues have been a real headache for me. The fine folks on the #eucalyptus IRC channel have been helping me out with everything but everytime we eliminate an issue there is another one to take its place.

In other news, Eucalyptus project member Andy Grimm will be visiting WSU this week. I’m looking forward to talking with him and hopefully I can convince him to give me some on-site assistance with the servers.

Tutorial – Installing GNU FM

I recently heard about a neat little site called libre.fm that provides a last.fm like service for listening to and sharing your musical interests. Libre.fm, however, runs on free software, respects user privacy, and includes only freely licensed music. The software that powers libre.fm is called GNU FM. I installed it on my home server just to check it out. This post explains what I had to do to get a working installation. The GNU/Linux distribution that I am using is Debian Squeeze. Hopefully this guide can be of help to someone.

Prerequisites

This guide makes the assumption that you already have a functional web server (Apache, nginx, etc.), PHP 5, and database server (either MySQL or PostgreSQL).

Setup Database

I made a MySQL user specifically for GNU FM

CREATE USER 'gnufm'@'localhost' IDENITIFIED BY 'yourpassword';

Create a database

CREATE DATABASE gnufm;

Download Source

GNU FM uses Git for version control. The source is available from gitorious. Clone the repository with the following command.

git clone git://gitorious.org/foocorp/gnu-fm.git

Install Gnukebox

From the gnu-fm directory, copy the server application, gnukebox, to the web server directory.

cp -r gnukebox/ /var/www/

From your web browser, go to http://yourwebserver/gnukebox/install.php. It’s quite straight forward. Enter the information in for your database server like the database name and the user that you have created.

If the web server cannot write to the directory in which you installed gnukebox, you will see a page that prints out the configuration code that you will need to manually insert into the config.php file in the gnukebox directory.

Install Nixtape

From the gnu-fm directory, copy the web interface, nixtape, to the web server directory.

cp -r nixtape/ /var/www/

From your web browser, go to http://yourwebserver/nixtape/install.php. You will enter the same database details as you did for gnukebox and give your GNU FM server a name.

Once again, if the web server cannot write to the directory in which you installed nixtape, you will see a page that prints out the configuration code that you will need to manually insert into the config.php file in the nixtape directory.

Nixtape requires some extra PHP libraries to be installed along with it. Please note that the version numbers of these libraries may be different depending on how far you in the future you are coming from. Which means that copy/paste’ing the commands I give you will not work, but you’ll probably only have to change the version number in the command to make it work.

Install ADOdb

ADOdb is a database abstraction library for PHP. Installing the library takes just a simple apt-get.

apt-get install php5-adodb libphp-adodb

Install Smarty

Smarty is a PHP templating library that nixtape uses for all web pages. There are packages available in the Debian Squeeze repository, but GNU FM does not work with them. The problem is the result of a slightly different path to the files contained in the Debian package. Since the GNU FM repo has a .tar.gz archive of Smarty within it, we’ll just install that instead.

From the gnu-fm directory, cd to the external_dependencies directory.

Extract Smarty and the Smarty text plugin.

tar zxf Smarty-2.6.22.tar.gz
tar zxf smarty-gettext-1.0b1.tgz

Copy the needed files to the nixtape directory.

mkdir /var/www/nixtape/smarty
cp -r Smarty-2.6.22/libs/ /var/www/nixtape/smarty
cp smarty-gettext-1.0b1/block.t.php /var/www/nixtape/smarty/plugins

Create a templates_c directory for compiled templates and make it writeable by the web server user.

mkdir /var/www/nixtape/themes/gnufm/templates_c
chgrp www-data /var/www/nixtape/themes/gnufm/templates_c
chmod 775 /var/www/nixtape/themes/gnufm/templates_c

Profit!

At this point I was able to have a working GNU FM installation. There are still plenty of things left to do such as add music, add a new theme, etc. Maybe once I get around to doing those things I will make a follow-up tutorial. Anywho, I hope this has been of some use to you folks out there in Internet land. Still having a hard time setting up GNU FM? If so, head on over to #libre.fm on irc.freenode.net and ask the developers for help. Oh, and don’t forget to leave a comment if there’s an error or something you would like me to improve in this tutorial. You can also leave a comment and say what a great guy I am. 🙂

Take it easy.