Posts Tagged ‘programming’

Pentecost programming

Monday, June 13th, 2011

For some reason almost everyone in Norway have the day of on “Pentecost Monday”. Not that I’m complaining, I slept until noon, got up to watch Doctor Who and Game of Thrones, but also managed to get lots of work done on my Startrek Game.

The game is almost ready for a little pre-alpha test which I’ve got about 15 volunteers ready for. Today I completed the final feature that will be implemented before this test, and maybe the most important feature of them all.

Trekwar Ship Combat

It was nice to see those stupid fleets that have been moving around my screen finally do something violent. My technologically superior (I cheat) scoutship blew that poor Klingon while taking almost no damage.

Implementing the combat between spaceships took about 5-6 hours of work today (lots of rules for selecting which ships to fight, calculate if they hit, calculate damage, etc..), so now I can start working on the testing scenario that all the testers will be playing through before the big multiplayer test starts.

I is old.. yay!

Friday, October 15th, 2010

Today I turned 10’000 days old. This means I can has cookie while programming! :)

Scrum tool (Jira vs Toodledo)

Tuesday, October 5th, 2010

Up until recently I’ve been using ToDoList (read my previous post about it) to keep track of all tasks that needs to be done for the Trekwar project.

Don’t get me wrong, ToDoList is very nice, except there are a few drawbacks that made me go look for a replacement.

  • It’s Windows only, so using it from linux would be cumbersome
  • It’s not online, so I have to sync the file between different computers
  • It’s hard to share the list, or make it public (there is html report, but the output is not very nice, and you’ll have to generate the file + upload it) which is a hassle.
  • It’s hard to use this to get a good view of what is needed for a specific release (like to view every task that is needed for alpha, beta or release)

JIRA
I’ve used JIRA a bit at my real job, and it’s pretty good. It’s online, and I installed it on my server to give it a try. I quickly had to abandon that idea seeing that JIRA is extremely bloated.. It uses like 600 MB of ram just starting up, no idea what it uses the memory for, it’s not doing anything remotely fancy that would require that amount of memory.

So I decided to run it from my desktop computer, now I get the same problems as with ToDoList with having to sync files between computers, and difficulty making the task list public. Also the interface itself is pretty bloated and slow, even tough it has pretty nice views for planning and when doing the tasks.

Toodledo
In trying once more to find the perfect tool for managing the tasks of my scrum like development, I tried out Toodledo. I found out about it because minecraft (awesome game BTW) also uses Toodledo as a public task list. Which is good as it lets people following projects get a sense of how much work/time is needed until the next milestone.

Toodledo is a online to do list, and it works very nicely for scrum development. It’s quick and easy without all the bloat of JIRA and gives you pretty much the same information.

It’s very easy to add tasks (subtasks require a pro account which is 15$ per year, well worth the money), and you can create context’s like “alpha”, “beta”, “release”, etc.. and add folders/tags which can be anything. There are lots of different views, I mostly use the main view which has all the tasks grouped by context and sorted by priority. There is also a view for seeing all the tasks in a particular context (like alpha) and the estimated time for all the tasks. (currently 94 hours of work needed before Trekwar can go into alpha).

My only problem with Toodledo is that subtasks don’t show up in the public view, but it should be implemented shortly. Another great thing about Toodledo is the forum, which is frequently visited by the staff/developers.

So if you’re looking for a good way to organize your project, I can definitely recommend Toodledo, and you can try it for free at their website.

For an example you can look at the Trekwar Todo list

Trekwar Fog Of War

Sunday, October 3rd, 2010

It’s been too long since I got any programming done on my Star Trek game Trekwar, but today I managed to implement animation support on the main map, as well as get the sensor system and fog of war working (still needs a bit of tweaking):

I’ve gotten a new job, and been working on another paying project as well (Comicon does not pay for itself you know). But this other project is almost done, and then I should be able to get back to doing regular Trekwar updates.

I’ve also switched over to Toodledo for maintaining the list of features to be implemented, so hopefully you can see the issues under “0.4.0 (Alpha)” shrinking over the next few months :)

Coloring stuff

Wednesday, August 18th, 2010

Seeing that I got nothing better to do, I finished up a half done project of mine the other day.

I wrote this program mostly just because I was messing around with different pathing/filling algorithms and the Java PixelGrabber class.

The program lets you color different motives (animals, people, vehicles, etc..) and I’ve probably spent more time coloring dogs and bunnies than actual programming :)

Kolor with Kribsy

Download Kolor with Kribsy

Kribsy BTW is a poorly drawn imaginary bunny with self esteem issues and a knack for painting stuff :)

Lady Java (Javazone song)

Friday, August 13th, 2010

Check out this awesome music video for JavaZone

I guess we CAN make cool music that’s not Black Metal. Haven’t felt such a surge of patriotism since the good old days.

The song says what I’ve been saying for years (except I’m usually not as polite): “Some people prefer other languages, and that’s OK if you’re retarded I guess”

Debug poem

Thursday, March 11th, 2010

Today I wasted two hours locating and fixing a trivial bug:

“Spent hours debugging my code, fixing hacks
but somehow mistook Math.min() for Math.max()”

Today I wasted 5 minutes trying to think of something that rhymes with “Math.max()”

Trekwar cargo system

Sunday, March 7th, 2010

Today I mostly finished the Trekwar Cargo system, so now it’s possible to collect resources and bring them back to your starsystems.

Also included 4 images from the design and implementation of the UI:

Read full devblog post at trekwar.org

Trekwar sensor system

Thursday, February 18th, 2010

I haven’t had much time working on Trekwar lately, but I’ve recently made a prototype of the sensor system:

I’ll have to add this, as well as fog of war when I’m done with the fleet management tools which are almost ready.

> Read the whole devblog post @ trekwar.org

Using WeakReference to confirm/find memory leaks in Java

Friday, September 4th, 2009

I recently had a memory leak in my Trekwar game, and to find it (or at least confirm it’s there) I used the WeakReference object in Java..

This is how I proceeded in locating the memory leak, this method could easily be adapted to other programs.

Trekwar is turn based, so each turn the client downloads a Galaxy object from the server. There are many references to this objects inside action listeners, threads, etc..

WeakReference
To make a long story short, a weak reference is like a normal reference, except it will not prevent the object it points to from being garbage collected.

This means that is you  have a normal and a weak reference to object A, the weak reference will be null if you remove the “hard” reference.

1) In the client main executable (the class that holds the method that updates the map from the server). Import, declare and make a list of weak references

import java.lang.ref.WeakReference;
private ArrayList<WeakReference<Galaxy>> weakRefs;
 
weakRefs = new ArrayList<WeakReference<Galaxy>>();

2) Find the place in your program where a new object is being added, in my place this is the localGalaxy object. Create a weak reference to this object, and list all your weak references.

localGalaxy = (Galaxy) objStream.readObject();
weakRefs.add(new WeakReference(localGalaxy));
for(int i = 0; i < weakRefs.size(); i++) {
System.out.print("ref # " + i + " = ");
try {
Galaxy testG = (Galaxy)weakRefs.get(i).get();
System.out.println(testG + ", tick = " + testG.currentTick);
}
catch(NullPointerException npe) {
System.out.println("null");
}
}

And you’re done!

Now when you run the program, you should see something like this each time the method is called

ref # 0 = org.aakretech.trekwar2.common.Galaxy@11ed166, tick = 37
ref # 1 = org.aakretech.trekwar2.common.Galaxy@9801f4, tick = 37
ref # 2 = org.aakretech.trekwar2.common.Galaxy@1c5d81c, tick = 38
ref # 3 = org.aakretech.trekwar2.common.Galaxy@101f8f4, tick = 39
ref # 4 = org.aakretech.trekwar2.common.Galaxy@1ed1e7e, tick = 40
ref # 5 = org.aakretech.trekwar2.common.Galaxy@e0a7ea, tick = 41

Unless you want to wait until your GC decides it’s time to go, use a tool like VisualVM to force the Garbage Collector to run.

After the GC has run, the output should look like this:

ref # 0 = null
ref # 1 = null
ref # 2 = null
ref # 3 = null
ref # 4 = null
ref # 5 = null
ref # 6 = org.aakretech.trekwar2.common.Galaxy@2b3c91, tick = 42

Now, this means that the object IS being garbage collected, and there is no memory leak.. If you run this and the object you are monitoring (in this example the localGalaxy object) is not GC’ed because of stray references, you can tell because none of the references will point to null.