games and code code it, play it
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.

Adventure games
February 15th, 2008

I got my hands on one of the latest quality adventures produced and one of the few I didn’t play yet: Monkey Island 3: The Curse of Monkey Island. I enjoyed playing this adventure but after I finished it I spent some time thinking about adventure games in general. Question I asked myself number of times is: “Why do I like adventure games?” I remember great moments playing adventures and that’s probably the main part of my answer but there are also frustrations when some stupid bug or illogical puzzle prevents me from going on and further discovering the story.

Adventure games always got special treatment from me as a gamer. I like to explore well created environments, discover a new locations, talk to a interesting characters and resolve problems a game is putting before me. Mostly they allow the player to consume the game on it’s own pace and to spend more time on details he’s most interested in. That’s the reason why adventure games produced long lasting memories.

As opposed to today’s games which all looks similar, adventure games used variety of different graphics techniques to set up the atmosphere. Early technology incapable of presenting realistic graphics was a medium on which the designers expressed it’s ideas. Be it cartoonish , realistic or fantasy, hand drawn or prerendered, presentation was part of the game.

Adventure games genre began to die off in the late nineties but I wanted more of them. Especially after I played Gabriel Knight 3 which had a great story and a 3D engine which was actually improvement over 2D. The engine kept a point and click style but allowed free exploration of the scenery. You could freely move the camera around, quickly exploring the scene, without needing to guide the main character around. If you executed some action, character just appeared on the place without waiting for him to walk over. If 2D adventures were live comics, this kind of 3d engine is movie where a game producer is screenwriter while player is in a role of the director, choosing angles and making cuts.

Compared to the Grim Fandango and Escape from Monkey Island, 3D adventures from Lucas Arts, Gabriel Knight 3 have 3D engine more suitable to the adventure games genre. While in Lucas Arts games you need to control and direct the main character with keyboard which feels like playing some arcade game, Sierra’s point and click 3D engine is more in the spirit of adventure gaming. When I saw it I naively thought that industry found the recipe for 3D adventure games and that I can expect more adventures from them. Unfortunately, reality was quite different.

You can look at Postmortem of GK3 where one of the developers talk about what went right and what went wrong in the production. Game wasn’t too successful and with all described problems company didn’t want to invest in the adventure games any more. With that, Gabriel Knight 3 was the last adventure game from Sierra. It is a pity, this was only playable 3D engine for adventures. Modified FPS engines just don’t cut for the adventures.

Searching for some insights into “why they don’t make adventures games any more?” I didn’t find an answer. Except for some random mussing about how most gamers are too stupid for complex plot lines and how evil companies want quick money instead of quality products, I’ve highlighted one answer which I don’t like but it is very true: Nobody killed Adventure Games. They committed suicide. This article summarizes the main problem with adventures. Player is not allowed to solve the problem, he must follow a path a creator carved for him. There is usually only one way to solve the problem and sometimes the solution can be just silly. While humour is appreciated, dumbness is not. I liked the Monkey Island game which inspired this article but I couldn’t solve some puzzles without some tips from the walkthrough. Here’s the example:

To persuade an ex-pirate to come with you you need to show him some treasure. There is no real treasure on the island but you can take a gold tooth from restaurant owner and he’ll come along. Getting the tooth is another story. You need to give him a jawbreaker to loosen his tooth and then a chewing gum. When he blows a bubble, pop it with the pin and the gold tooth will fly out of it and you can take it. You can’t leave the restaurant with the tooth, owner will see it in your pocket and stop you. So, use the gold tooth on the chewed gum, inhale some helium and chew the gum with the gold tooth. The gum will fly out of the window and you can exit the restaurant. You can find the tooth in the nearby mud puddle, so use the pie pan to pick it.

This is a series of stupid things you need to do in order to progress in the game. In humorous games like Monkey Island it’s barely tolerable but in serious games this nuisances stick out and break the atmosphere. If you are experienced adventure gamer you get used to them and fail to notice stupidity in them but every new player will be frustrated with this puzzles and will probably hate the game and whole genre.

Return to Might and Magic
January 25th, 2008

While reading some article one day, I’ve remembered the Might and Magic games. I’ve spent much time playing the “Swords of Xeen”, a game from 1995 and “For the blood and honor” from 1999. I’ve read from few sources that sixth part, “The Mandate of Heaven” is the best in the series so I’ve decided to try it now.

The whole series have characteristics which I seek in most RPG’s. The artwork is done beautifully, monsters are very diversified and world is a really nice place to be a hero. World is composed of maps, every map has a city or two and many interesting locations like abandoned temples, ruins or dungeons. Every location is filled with all kind of items. There is great variety of weapons and armor, plain or enhanced in every possible way.

Thing i like the most in the “Might and Magic” games is skill system. It have optimal number of skills, not too much, not too few. You can always create four different characters and every one of them is really important to the party. Every character can learn almost every skill and such system can bring many interesting combinations. Of course, to progress in the game, characters should specialize in skills. They can spend experience points on skills and then find the teacher to become expert or master.

Unfortunately, beautiful world, diverse monsters and great skill systems are all hindered by boring combat system. Wherever you go, most of the time you are facing a hordes of enemies who throw themselves at your swords. Exploring the world is full of such encounters. Every time when leaving the city, you are faced with this picture:

Image Hosted by ImageShack.us

A RPG with great skill system then becomes a bad FPS. Wouldn’t be much better if faced with few stronger monsters rather then horde of weaklings? And to make bad things worse, they re-spawn after some game time so when you return ten levels stronger you’ll be faced with enemies which fall after first shot. Every time I’m faced with that hack and slash party I have less and less will to finish the game.

When the game doesn’t surprise you with new stuff anymore but continues to throw more and more of the same hurdles at your path it’s just to boring to finish it. It should end when it’s best, not a million fallen monsters later.

Completing hobby projects
January 14th, 2008

I have a long line of unfinished projects. I like to start a new project, explore, learn and finally move on to something else before I make something visible. Sure, there is much code left, most of the time it’s reusable but i don’t really have some showcase, some folder with finished projects, with executables. Instead there is only an “Old projects” folder, some made it to the the black triangle phase and some are just an unorganized pile of code. In contrast with hobby projects, most of the past projects on my workplace are packaged and ready to run. The project life cycle is completed.

When doing hobby projects, somehow I don’t have the urge to finish them. When i learn what I wanted to learn, I feel I’m done with that project. I’m sorry now that I didn’t invest a day or two more on some projects and made some final touches. Most of them are in a half finished state where most features are almost done but aren’t visible yet. To finish them now would be too much work. They’ve been made in older versions of development environments, they use components and libraries I don’t have anymore and are written by a much worse programmer then myself – a few years younger me.

To stop this unorganized behavior and make a change for the better, I have made an effort to finish my current XNA project. I’ve compiled everything I’ve learned in this project and created the “Ball roller”, a simple showcase of all techniques encountered while studying XNA. I hope this will be just the first in a longer line of my showcased projects.

VSS to SVN
January 6th, 2008

I’m trying to add my projects to SVN (subversion), open source source control system. Installing and working with it is typical experience when using open source tools. There is no “download – install – use” procedure. As with other open source tools, you need to study it for some time, read some tutorials and guides and prepare yourself to work with it instead waiting for it to do work for you. And it’s used from command line, naturally. With some patience and additional tools like TortoiseSVN it’s not big deal to install and use it.

I’m writing this as VSS (Visual Source Safe) user. My team at work is using VSS and although we are aware of problems other teams had using it, I don’t think we’ll switch to something else in the near future. Somehow we’ve grown with VSS, using it for years without problems. I’ll try to use SVN at home, and write about experiences so i could eventually be ready to set it up for my team at work.

File locks

In VSS, if you want to edit a file, this file will be locked for every other user. If somebody else is editing it, you can only read it, editing is disabled. Of course, you can remove read only property from file, edit it anyway and merge it later, but this isn’t the recommended procedure and it’s discouraged.

In SVN, procedure is completely opposite. Everyone can get latest version and edit it as they want. If somebody already changed the file you want to commit you are asked to merge the changes.

What is better? Though question. In my opinion SVN’s style encourages you to talk to your coworkers and plan your project’s resources. Let say, you have a project with 100 source files and 20 programmers. If every coder want to work on few files, there’s big chance that only half of this twenty programmers can lock all their files while they working. That’s the point where SVN’s style is better. Team should organize their work before they start to write any code. When they agree and stick to the plan, there could be no problems with merging.

File sharing between projects

This is the most problematic part in transition from VSS to SVN. In my team, file sharing is extensively used. We have many projects and some of them share modules or classes. Common set of functions is in external class library, where it should be, but for some functions it’s more convenient to just share them between projects. Second case when we share files is when we customize the project for some special case. We don’t modify the main repository, rather we create the new project and branch only the files which will be different and share all other files. If we find some bug in shared file and correct it, both projects will get the updated version immediately. If such behaviour gets into your habit, it’s easy to think about it as the right and only way.

I was somewhat dismayed when i saw there is no file sharing in SVN. How could that be? If it’s better then VSS, how can it miss such an important and convenient feature. We’ll could never work without file sharing, whole team is relaying on it. Then i started to think about it. Once, we agreed that enumerator names needs to be changed. When it was convenient time for me, i changed them in my project, checked in the changes and inform everybody about it. When other programmer got the last version or his project, it was broken all over. Sooner or later, whatever source control system we used, he would need to take this changed enumerators. Day before some big release was really bad time to worry about broken namespaces. If we worked in SVN and did not used this feature, he would take the changed version after the release, with more time on his hands. It can be said i chopped down the tree while others were standing on its branches.

So it’s not about worse or better way, to have file sharing or not. It’s about organizing your team about provided features. File sharing is very nice feature but it can bring big problems when one wrong step is immediately propagated to every project. Working without it requires more work and team collaboration but you’ll always have the versions you really want.