I’m not really into action or arcade gaming. I like self paced gaming style like in turn based games, where I have some time to think, where I can slowly build my path to success. Not that I’m against good, fast action, it’s just that I hate when games are frustrating. And, oh, arcades can be frustrating.

So, looking one day at some top 100 games of all time, I’ve found “Prince of Persia: The Sands of Time”. It got some good reviews, it’s old enough for my PC to run it and middle eastern setting and eye candy graphics give it special charm. I won’t go into full review of the game, there are other places on the net for that. But when I stumble across such a good game, I want to highlight the best parts of it. And of course, rant about why is not perfect.

Game well done

From the first sight, it’s obvious that this game is something exceptionally good. Everything goes smoothly: installation, changing settings, playing… In the time when games and patches are shipped simultaneously, what strikes me the most is that 5 years after release, there are no gameplay or stability related patches for “The sands of time”. Only some Nvidia related fix to fill the patches section, otherwise the game is flawless.

When you see a game like this one, you see how wrong is for computer games to try to look photo-realistic. This game looks almost real, but details give it this fantastic touch. It would be wrong to say it’s cartoonish but look for yourself:

this is just beautiful. All these shiny marble, soft tapestries and polished metal are the real eye candy. While characters and monsters are not even near done so well, I must mention the thing about Farah, a female in the game. A compliment to her is that she looks normal. Her shapes and proportions obey the laws of physics and her clothing cover more skin then required for ESRB Teen rating.

Sound effects also add to the atmosphere. Your footsteps and environment sounds echo as you walk through empty, marble corridors. It needs just a little attention to make sound effects right. This game did it.

Combat

Combat. Always a showstopper when I want to play action games. In real life, combat is slow paced affair. You need to step carefully, concentrate on your opponent and focus your strength to only few strikes you’ll get at your opponent. Unfortunately, game developers always want to include combat like in Jackie Chan movies where action is flashing on the screen and he delivers kicks and punches all around himself. Too bad they don’t remember that such movie action is heavily scripted. Whenever Jackie kicks, there is always some face to land his shot on. Opponents close on him exactly on time to receive they portion of punches. Ladders and tables are just where they need to be for Jackie to save the day. If you want that kind of encounter in a game, put it in a cut scene.

In “The Sands of Time”, when you are faced with maximum of three opponents, battles develop very nice. You can do all kind of tricks, jump around and over the foes, striking them while hovering over them, bounce from the walls to surprise them and the game will reward you with slow motion scenes of your exhibitions.

And then you run into six enemies and the whole battle system falls apart. You are always surrounded. Forget about smart positioning and legwork, enemies teleport just behind your back. You quickly lose control of events and you can only watch the Prince as he does the all the cool stuff while you are just mashing the buttons. Replay function could be useful here so we can enjoy the combat too.

The camera hovers somewhere around you and changes it’s position to show the scene. Unfortunately, movement is camera relative so every time the camera rotate, what is front and what is back gets redefined. So, you try to avoid traps and as soon you pass around one of them camera rotates and suddenly you are running back into the trap. It gets even more frustrating in combat. You knock down the opponent and run to him towards him to finish him but camera turns around, enough to put your neck at two handed, double bladed falchion held by giant ogre.

I can’t

Around 25% of the game, I’ve run into a battle I can’t win. I tried to fight fast, I tried to be careful but either Farah or I die in the end. I’ll try few more times, maybe I succeed yet. But frustration is there.

Dune
November 4th, 2008

I rarely play any computer games these days. It’s just more fun to do some work or learn something new then playing the next iteration of some shooter/RPG/RTS/whatever. Fortunately, there are some indie games on repertoire like Mount and Blade which I bought recently, Frayed Knights (not yet released but I played the pilot and generally like it) and a few more that I’m interested in.

Many times, general feeling I have toward the current state of the gaming industry is that games were better before. Of course, such statement is completely subjective. We all look at the past through the pink colored glasses, but anyway, there are many great old games. So, if those games are that great, why nobody plays them anymore? Well, I do.

These weekend I stumbled on Dune. I saw these game even before I had a PC. My friend played it and I was fascinated. And I still am. I started it many times and finished once. I actually do not remember how it ends and that’s the sign I need to play it again. But now I have this blog and desire to write down my thoughts so let’s analyze this game as an example of an old school game.

Paul on Dune Planet Arrakis

Gameplay

Dune is combination of adventure and real time strategy. You don’t build bases, produce units or research technology as in modern RTS games. Instead, you explore the world and talk to people like in adventure games. You can hire Fremen you meet to work or fight for you. Every now and then, some of the important Fremen will provide you with new options, units or technology. Of course, you don’t just collect them, they will be available to you when you became important enough.

You interact with the world in two ways. First, you travel around the world and directly contact the people. Second, you have telepathic powers so you can contact the Fremen at distance, progressively, from short range to planet wide.

Although the game is over when you win the last battle, you have several different tasks and goals.

  • Spice harvesting. Emperor sent you to Arrakis to harvest spice and he expect you to deliver. He is interested only in spice and wants more and more.
  • War. Harkonnen’s fortresses are just north. They are cruel to the Fremen so you need to lead them and fight back.
  • Terraforming. Yes, the Fremen dream is vegetation on the planet. Later in the game, you can send ecologist units to plant the vegetation.
  • The Mahdi. When you raise your charisma enough, Fremen will start to believe that you are their messiah. You’ll became one if you drive out Harkonnens from Dune and plant the vegetation

Innovativeness

It’s interesting to note that in todays terms, Dune is a hybrid of adventure and real time strategy. But when the game was released, RTS genre didn’t existed yet. It was defined later by the Dune’s successor, Dune II.

Micromanagement

The thing I love and hate at the same time. What happens in many games is that at the start of the game micromanagement is fun but as you progress and build your empire or fast food chain it becomes a burden and you lose more and more time to ensure that all production is optimized. Not that Dune solved this completely but I like how interaction changes as you progress. At first, you must fly the Ornithopter and personally visit the sietches to issue orders or view the troop status. After some time, you are given a map so you can view regions and troops but you still must fly to every sietch. Then, you get psychic powers to communicate with distant leaders. With time (and accomplishments) your power increases so you can contact them at greater distances and finally over the entire planet.

What’s so good about the game?

It’s very easy to get yourself immersed in this game. Step by step, it introduces you to the world. At first, your job is to go and visit the Fremen to convince them to work for you. Then the Emperor drops in to remind you that you are sent to Arrakis to mine spice, not to flirt around with Fremen girls. Now you must ensure a shipment of spice every week. You have to manage the production and regularly deliver the spice to the Emperor. When you get into the harvesting business, your father becomes uneasy with Harkonnens on the north and you have to organize the army. Fremen will fight for you only when you find their leader. When your soldiers are trained, you can start attacking Harkonnen’s fortresses. Now you need to juggle the spice production and war efforts. In the midst of fighting you get another revelation: there’s water on Arrakis and Fremen have a dream: vegetation on the planet. When you find Liet Kynes, the expert ecologist, you can start terraforming the planet.

There are no dull moments in the game. You know, the part when you are strong enough so there is no real threat anymore and everything is researched but you still must manage the economy and build units so you can take the enemy territory, part by part. In Dune, when you know everything you should know about the planet, there’s only final battle left.

If you are interested in this game, you can download it from Abandonia and run it under Dosbox.

Dependency in software
September 7th, 2008

Paul W. Homer on his blog, The Programmer’s Paradox, posted an article about dependencies in software solutions. I constantly fight with this issues: old code vs new code, introducing a dependency or writing your own. I wanted to comment on his blog but I just couldn’t summarize everything I wanted to say in one comment. So here are some of my experiences with the dependency issue.

It’s interesting how you always think something is a good idea until it turns against you. So, if you don’t want to write the code somebody already has written, you’ll find out that this code is slow/ugly/buggy/heavy. If you, on the other hand, are smart and write your own code, you may find too late that it will took too much resources and it’s not as simple as you though it is and some functionality you just can’t implement on time.

Maybe the worst code is the in-house code that works good but is based on old presumptions about hardware, requirements or interoperability. I find such code hardest to evaluate. It’s a burden if it’s model is not extensible enough but you must stick to it because any replacement requires big investments.

In any case, you depend on something you can’t easily fix if something goes wrong so you have to be very careful when introducing new dependencies in your software. Of course, you always depend on something, like operating system, database and framework. But every time you add more to this dependency stack, you exponentially increase the risk for something to go wrong.

Story about third party component

I had to maintain and extend a document management solution in which images could be attached to a document. User could view an image inside the application and do some simple manipulation on it like rotating, scaling and moving. A typical scenario where you entrust specific set of problems to a third party library.

I raised some question about size of this component. Also, it was pretty memory heavy and was leaking in some cases but nothing was serious enough to think about replacing it. The only problem I saw about this component was abstract to others: we were using it for image viewing but the component was designed for image editing: conversions, effects, filters and annotations. Displaying the image was only smart part of it’s functionality. Sometime ago, we allowed the users to edit this document but nobody was using this feature. And why should they? If someone wanted to edit an image, he’ll use the right tool for the job, not document management software.

As the component was part of our library for some time, team started to use it in more and more cases: generating thumbnails on the server, drawing reports or generating images from metadata. We had deep dependency then, disaster waiting to happen.

Of course, problems came immediately. First, we wanted to make a lite version. We did it but imaging component took a third of the installation size. Then Microsoft made SP2 for XP and included a firewall. For some reason, component failed to load on one of three machines providing us only with some general error. We never discovered what was wrong but after some patches from Microsoft error was gone. Sometimes, the component didn’t work if PC wasn’t connected to Internet.

When two of our most important clients decided to upgrade our application, component finally gave us a good reason to kick it out of our software. Upgrades were succesful, but new installations didn’t work at all. Application hung at startup without an error. We couldn’t reproduce the error at home so we spent some time to organize debugging at customers place, something I don’t want to repeat again.

It turned out that imaging component failed to initialize. But instead of throwing an error, it just hung up and we couldn’t do much about it. We striped the component out and temporarily used version that opened images in an external application. It did the trick but the incident hurt our reputation.

Now we have our own component for image display, nothing fancy, just zoom and rotate. When our own component is not enough, we have a plug-in for image manipulation based on FreeImage. But important is, we don’t have deep dependency anymore.

Software design rant - Notepad ++
September 5th, 2008

When using software product while you work, the best product is the one you don’t notice. And today I’ve noticed one: Notepad++.

Notepad++ is a great text editor and I’m using it instead of classic Windows Notepad. It starts as fast as Notepad and it’s design is minimalistic but it has features like syntax coloring, hex editing and tabbed interface. I have many tabs constantly opened with very different content in them. Some tabs are just scratchpads where i write notes, phone numbers or names. Others contain xml or html documents I’ve edited of viewed or maybe pieces of php or javascript code. One tool, one window, everything conveniently accessible.

So, today I’m talking on the phone and a client wants to give me his IP address. I’m kinda sad when in this situation some of my colleagues start to search frantically between papers on their table for a pen and paper instead of writing the number somewhere on a PC they sitting behind. I’m always ready to write a note or two in conveniently opened tab in Notepad ++, but today when I wanted to write a client’s number, Notepad++ shown me a modal message:

Don'be scared, it's not real. That's only a screenshot

So, now I’m in a situation where I must quickly write down a phone number and one of my favorite software forces me to make decision which will definitely result in lost data and I need to decide what’s more important: something I wrote or something some other application wrote in the same file, and all that, of course, while I’m trying to remember a sequence of 12 numbers. It’s interesting how well this application defended itself from my attempts to write a few numbers in it. New tab? No, message box is modal. Existing tab? No, message box is modal and blinking. Then I tried to open a new instance. No way, only one instance is allowed. I’ve ended asking the client to repeat the number and writing it in Visual Studio somewhere between Catch and Finally keywords.

Sometimes it’s only an inconvenience. Another time you want to put your fist through this message box. But definitely is a proof how you can spoil a good software as Notepad++ and a good concept as tabbed interface with a careless design. I shouldn’t be able to write in the file in question until I resolve the conflict, but this message box is important for only this tab, for only one document. There is no good reason to prevent me to use every other tab. By the way, i should be able to save both versions of this document, but this is another story.

The same problem is with browsers. Click this link. and see what happens. See? My worthless but egoistic message disabled your complete browser until you read it or at least click on it.

So, if you are a programmer, don’t be a self-centered, selfish bastard and let people use their tabs. Don’t write alert(”), MessageBox(”"), msgbox(”") or raise any other modal window until you are completely sure that it won’t interfere with anything other then your humble corner of the users screen.

Return to D&D
July 26th, 2008

My D&D hobby was on hold for long. It’s hard to find new players, stores with equipment are rare and tabletop roleplaying is not very popular these days. But the planets aligned in a way that new D&D edition is out, students returned in town and even some kids grown up enough to do some roleplaying.
Thank to Amazon, I got three core rulebooks fast and cheap. I’ve spread the word about new rules and exciting play and gradually got hooked enough people to start a new campaign. Now, after full two sessions I have some credibility to comment on new rules.

Why bother to comment the rules? Well, before the books came out I saw many previews and when they came out and before I had chance to play, I saw a lot of reviews. Most of them were very negative and think only one where author thought of 4E as progression. In my opinion, such distribution is very unjust. General opinion I’ve read on other blogs, forums and D&D newsgroup is that rules got simplified and that game is now only combat oriented.

Simplification

To me, rule simplification is a good thing. You see, when there is rule for every detail, I can’t make my own. I have a feeling that everything must be done by the book. I need only core rules to be described. When you know the basics, it’s easy to make new rules on the place.

Let say, forgery skill from 3.5. It’s interesting skill to have but it can be used only few times in whole campaign. Except if character wants to be a professional forger, training this skill instead of some which will be used daily like diplomacy or thievery just doesn’t make sense. When party want to forge something it’s easy to derive their skill from Intelligence and knowledge about the subject of forgery. Profession and craft? Come on, we are adventurers. Leave this to NPCs.

It’s similar with equipment. I’ve read on newsgroup about how 10-foot pole is missing and I quote: “Was the 10-foot pole really one of the sacred cows that needed to be slaughtered on the altar of 4th Edition? ” I thought it was sarcasm, but people are serious about this.

This rule simplification reminds me of LEGO bricks. When you have only simple pieces in different colors, you can build anything you want: car, house, people, animals… whatever you want. But if you buy LEGO truck with included tires and windshield and set you can build very nice truck. And only truck. Similarly, simpler rules make more diverse game, if you handle it properly.

Combat

Although game as such isn’t any more combat oriented the before, we actually fight more with new rules. Not because somebody forced us, it’s because combat is fun. First level party with their small set of powers and without wizard and warlord, already presented memorable battles. Every combination of race, class and chosen class build gives a unique combat tactics. Division of monsters to minion, normal, elite and solos make battles interesting. Even if party fights three goblin groups, their roles make them different every time.

It’s easier for a DM to set up the encounter. Challenge ratings are gone and with them too easy and too hard encounters. CR is replaced by a more linear and natural system of monster levels and you know all the time which challenges a party can handle.

Only problem we had in combat was tracking marks and bonuses. Characters can mark monsters to give them a penalties or can provide bonus to allies. Bet when 5 person party fights against 10 monsters, tracking those lines can be really difficult. I’m yet to find a best way to handle this.

Ubuntu - a new level
May 18th, 2008

Last six months my main operating system is Ubuntu. I got used to the Linux file system, command line, Debian packages, compiling from source, customizing, scripting, KDE and Gnome.

For a time I was in a some weird newbeesh state where I could use operating system but I was full of questions and lost whenever something didn’t work in the way I thought it should. Fortunately, it didn’t last long. I’m ready now to write short series about Ubuntu. There are some problems after installation and I want to write them down on one place. As Ubuntu is highly customizable it’s very important to change ant tweak some setting so you can be more productive or just more comfortable.

I tried everything I need and it’s time to do a clean install. Formatting the primary partition would also be a great test for my backup system. Installation is nothing to remember, it’s simple and after choosing a target and language it doesn’t need any attention. Also, installer found that i have Windows installed and has enabled a dual boot. After the first boot you have functional system with Open Office, Firefox 3 Beta 5, Gimp, Evolution and Pidgin. Now, let the customizing begin.

Ubuntu series:

XAMPP on Ubuntu
May 18th, 2008

XAMPP is a software bundle consisting of Apache web server, MySQL database server and PHP hypertext processor. XAMPP is the easiest way to start with web development. It’s easy to install, just follow instruction on it’s web page. Unfortunately, on Ubuntu it doesn’t work immediately. When starting, I got some error message:”<code>arch: command not found</code>”. Lampp expects this command to be available but it isn’t in Ubuntu. Instead, you can use Uname command.

  1. Create fake arch by typing: “sudo gedit /bin/arch”.
  2. As content of the file write “uname -m”.
  3. Save and exit from gedit.
  4. Type “sudo chmod +x /bin/arch” to make the file executable.
  5. Now you can restart the xampp with “sudo /opt/lamp/lampp restart”

There’s one more thing about XAMPP. You can start it after login if you put it in startup in session manager. But to start server with system, before anybody logins, in file: “/etc/rc.local” add line “/opt/lampp/lampp start”.




When I installed Ubuntu I couldn’t find any backup tool with features I wanted. I also wanted some exercise in Python so I wrote a backup tool and called it PySync. In meantime it became obvious to me that there is much better way to backup under Linux. As always with Linux, there really isn’t any full featured tool but with little time and knowledge you can modify everything to suit your needs. Combining rsync, bash script and cron, now I have backup system which does everything I need.

Features I wanted:

  • Daily backup
  • Only copy changed files
  • Write a log with list of changed files
  • Read a list of directories and synchronize them one by one
  • Way to exclude some files or folders

So here’s the procedure.

1. Write a script

The script contains a list of directories that will be synced. Log is created in a subfolder, one file for every day. I’ve put the script in ‘/usr/local/bin/backup-all’ file.


#!/bin/bash
# backup procedure by Hugo Riley, www.gamesandcode.com
BACKUP_LOG=/usr/local/bin/backup-log/backup-log-$(date +%Y%m%d)
EXCLUDE_LIST=/usr/local/bin/backup-exclude
echo "************************" > $BACKUP_LOG
echo "System backup with RSync" >> $BACKUP_LOG
date >> $BACKUP_LOG
echo "************************" >> $BACKUP_LOG
FILES=(
'/boot /media/backup/filesystem'
'/home /media/backup/filesystem'
'/opt /media/backup/filesystem'
'/media/data/Dokumenti /media/backup'
'/media/data/Music /media/backup'
'/media/data/Projects /media/backup'
)
ELEMENTS=${#FILES[@]}
for (( i=0;i<$ELEMENTS;i++)); do
folderpair=${FILES[${i}]}
rsync --delete --delete-excluded -av $folderpair --exclude-from=$EXCLUDE_LIST >> $BACKUP_LOG
done
#end of script

Script must be executable to work so it needs to be chmoded:

chmod +x backup-all

Files and folders can be excluded from backup. Just add some filters to backup-exclude file:
.trash
Trash
Cache
.thumbnails

2. Make a schedule

To enable daily backup, you need to add it to the Anacron. It can be modified in ‘/etc/anacrontab’. I wanted my backup to start every day, ten minutes after Linux is finished booting (login is not necessary). After the editing, my anacrontab file looks like this:


# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# These replace cron's entries
1	5	cron.daily	 nice run-parts --report /etc/cron.daily
7	7	cron.weekly	 nice run-parts --report /etc/cron.weekly
1	10	SystemBackup	/usr/local/bin/backup-all
@monthly	15	cron.monthly nice run-parts --report /etc/cron.monthly

While reading an article at Twenty Sided i got hooked on one phrase: “Real Time Logistics” game.


As Real Time Strategy game advanced, they became more and more complex. At first, simple “tank rush” strategy was enough. Rock - paper - scissors relationships of later games created a more balanced and easy to understand games. But every recent game (recent as last 5 years) added new layer of complexity. I didn’t really played them much, but games I played were like that. Warcraft III added hero units, Age of Empires III included Home City concept and most games added neutral races like native tribes in AOE III or creeps in Warcraft III. In reviews, those concepts are named as innovations but to me they are just complications of the original concept.

There’s also use of the word strategy, a misnomer because RTS games are actually combination of tactics and logistics. You start on empty map and create some buildings and produce units. That could be strategy but what makes a difference between players are their logistics skills. Organize peasants to work on different resources and balance them between different sites, watch for depleted resources and send workers somewhere else immediately, build storage spaces near resources… These is logistics. After some time you need to switch accent from supply units to military. When you have the army, use your tactics skills to divide or flank the enemy, exploit opponents vulnerabilities and use advantages of terrain and abilities of your units.

In such games i don’t enjoy in combat part. I find logistics part far more interesting. Building a base, exploiting resources, advancing through ages… I wish i could just send supplies to some other guy who prefer to destroy things and hates the building part. Can you imagine this scenario? It could be a multiplayer game where what is now one player is divided in two: builder and warrior. Every team starts with one scout and one settler.

Warrior: I use the scout unit to quickly inspect the surroundings.
Builder: Scout discovered some nice flat land so I use the settler to build a town center.
Warrior: I try to discover nearby resources and explore as much terrain I can without fighting.
Builder: I produce some peasants in town center and start to exploit nearby resources. When I have constant inflow of resources, I build some basic military units and send them to rally point.
Warrior: Finally, I got some new units. I attack wild animals I’ve discovered and allow the builder guy to reach all resources without casualties. I mark some places for the builder where he should put watchtowers.
Builder: Village is growing nicely. We advanced to next age, raised some watchtowers and sent new military units to the warrior. He requested more archers so I’ve sent them; we have enough wood.
Warrior: My army has found enemy mine protected with the watchtower. We killed some workers but he already upgraded his towers and it would be suicide to attack it with archers. I request some catapults!
Builder: Stone is scarce here. Warrion requested some expensive units but we don’t have that much stone. I’ve managed to build some catapults but without upgrades. He’ll wait until next advance.
Warrior: We destroyed the watchtower and killed peasants and some guards near them. We had too much casualties because gay at home didn’t send me all catapults i requested. Stupid farmer.
Builder: Shit, we’re under attack and stupid warrior is chasing chickens at enemy farm. Get the hell over here! Send knights immediately. I have only some pikemans here and he came with axemans.
Warrior: Damn, so that’s why he didn’t retake this mine. Knights are returning to town. Build some catapults down there and I’ll attack them from behind. My catapults will terrorize his village and try to destroy his stables.
Builder: We stopped their attack but they destroyed our farms.
Warior: Send me more fire throwers! We got him now!
Builder: I can’t, we don’t have food. I’ll create some more workers first.
Warrior: No, no, no. Build some fire throwers and we are the winners.
Builder: Wait a little.
Warrior: Argh, it’s too late now. He upgraded his stables now. He’s too strong now. Upgrade us, now!
Builder: I have no money for upgrades. I spent everything on fishing boats.
Warrior: How the hell will this boats defend you from knights? Will you splash them or what?
Builder: But we need food.
Warrior: We need castle.
Builder: I didn’t research it yet.
Warrior: Build many pikemans then.
Builder: Shouldn’t we save the gold for upgrades?
Warrior: No, we’re doomed. He’s coming with knights and catapults.

WE LOOSE

Builder: You didn’t have to attack so soon.
Warrior: If you sent me what I requested we would won.

Design documents
March 1st, 2008

Design documents are such a hurdle. Why couldn’t I just sit at the computer and write the code? Hey, isn’t the software made from code? Shouldn’t the code be the best way to create a concept and test an idea? After all, when you’re done with the planning you’ll have some code ready and you can continue building from there. It’s a time/money saver.

I suppose that such view on a software design process is very common. There are many reasons why programmers think like that:
- Whenever a project has a short deadline, designing is the first thing to fall out of process to save some time.
- Design document can look as overkill when project is developed by only one or two programmers. It’s easy to think that he or they wouldn’t need a design document because they are making the standards themselves.
- Project can be too small to have it’s own design document. What’s to design when project have only three windows and few self documenting functions?

Those reasons are often used to skip designing the project. They are actually good reasons to save time and immediately start coding. Only problem in them is that projects happen to look different when they begin and after some while. What was one guy project in the beginning, soon can be developed by a whole team. Small projects can serve as a base for a larger ones. Without clear standards they can only be base for troubles.

So, what should a hard-working, deadline-pressed programmer do regarding the design document? Only smart thing you can do about this is not to distinguish projects to those which need the design document and those which do not. Rather, for small projects make small design documents. Few pages with goals, ideas and important names and terms are better then no document at all.