Saturday, June 14, 2014

Out of retirement!

I had given up on writing a variant.  The usual excuses prevailed: work, the code is insane, I discovered Kerbal Space Program, etc, etc.  But, I'm taking a break from Kerbal Space Program because of an ATI graphics driver bug that has been driving me crazy.

But, I'm out of retirement!

I was in the middle of a solid game, playing as a female human rogue, and had stumbled across some very good luck: two magic lamps (both resulted in wishes), two bags of holding, etc, etc.

Then I ran into a bug that almost resulted in my character's death (by starvation).  I was very lucky to be saved by a puma's attack, and quickly #prayed (I was fainting at this point), killed the puma, then saved the game.


The main reason I was lucky about surviving is that I was able to save the game and copy the save file so I can reproduce the bug easily.  Whatever your feelings might be when it comes to copying nethack save files, I guarantee I'm more passionate about having solid test cases for bug reproduction and bug fix verification.

Anyway, a while back I blew away my Arch Linux installation because the folks over at Arch started doing crazy things that broke everything for me, so I switched to Debian.

I've never successfully built the nethack-3.4.3 code on any OS other than Arch and FreeBSD.  I'm running Debian now, and I can get the source with a simple apt-get source nethack, but unlike the OS's with ports trees, it doesn't come ready to rock.  I still have to figure out all the crazy config options and, traditionally, I get frustrated and give up before working through all the errors (please leave a comment if you have easy steps for compiling in Debian).

So I dusted off my old piece of junk $110 desktop computer (brilliant buy, I love this thing) that has FreeBSD installed and will work on the fix there.  Yes, I did actually have to dust it off, please don't make fun of me for that.  I'm updating the system now, and then I'll work on the fix.

Once I have a fix, I'll write up and post my root-cause analysis along with the patch and the saved game that triggered the bug so others can verify the fix.

--------------------------

Update: I figured out how to build nethack in Debian.

Sunday, July 21, 2013

GAHHH_NEW_POST!

Now that I'm sure everyone has stopped visiting this blog, I am back!  I was very busy for a while at work as we had a very important deadline approaching for a couple of months.  But that deadline was reached, and good news abounds!  My tiny little start-up was very recently acquired by the best possible company that could've acquired us.  Everybody's happy.

Now, back to nethack.  I haven't played in so long that I've forgotten a lot of the little nitty-gritty spoilers I used to know.  I once again have to look up specific prices of scrolls, potions, rings, etc.  Of course, I'll never forget that my three favorite rings, slow digestion, free action, and levitation (in that order), are all 200 Zk.  Regardless, I'll probably need a little ramp-up time to refamiliarize myself with the little details of the game, as well as the intricacies of the gameplay, before I can jump back into the code.

What's important to take away though, is that this blog is not dead.  It was just wearing an amulet of live saving (ugh, I know, awful joke.  I'm here all week).

Secondly, what's important to take away is that I finally finished my tourist game.  Tourist is one of the best roles in the game.  The early game is very difficult, but the quest artifact is arguably the best in the game, and the quest itself yields tons of loot.

One fun little stupid thing I like to do is chat with Death.  The background is that there are four Riders of the Apocalypse, explained in great depth in The Book of Revelation.  It's a great read, and if you haven't read it, it's probably one of those things you should read aloud to your children at bedtime.  In the words of my boy TJ (Thomas Jefferson), it is "merely the ravings of a maniac, no more worthy nor capable of explanation than the incoherences of our own nightly dreams."

On the Astral Plane, in nethack, you will find three of these Riders: Famine, Pestilence (also know as Conquest in the BoR), and Death.  If I am able, I always make a point to chat with Death, because he gives some insight into who the fourth Rider is:



This actually makes a lot of sense.  You spend the game going through a dungeon killing thousands of creatures.  I can't really think of a better definition of "war" than that.










Wednesday, April 10, 2013

busy busy busy

Sorry, updates are going to be slow for a little while.  My company is in crunch mode for our next release, so I'm just writing to let y'all know, I haven't abandoned the blog, or my variant.  I haven't abandoned nethack either, even though I haven't played my awesome tourist game in ages.  The PYEC is such a good artifact.

In the meantime, my mouse's wheel click has started pasting text when it opens links in new windows, as opposed to before when it would open links in new tabs without pasting.  All my searching so far has told me that is default functionality in X, and unless I want to hack X (a possibility...), I'm going to have to deal with it.

I wonder why it didn't paste before?  It doesn't on my Arch Linux system, which is running X, just on my Linux Mint system.  Maybe some update got me.  The nice thing about minimalist distributions is that they don't get cluttered with unwanted stuff.

Wednesday, March 27, 2013

Next Steps

I've been slow to update recently, since my company is releasing a new version of its software at the end of the week...

But!  My next step is to merge struct you with struct monst, or rather, take out redundant data, like location, alignment, intrinsics, etc, etc, etc, etc, etc.  I want to treat monsters and the player more equally, though I realize there will be some things that are specific to struct you.  the game has a global struct you u, and a global struct monst youmonst, and in some cases, it seems arbitrary which one is used.


On an completely unrelated note, I stumbled across this gem the other day on one of those 'horrors of coding' sites:


    static boolean isTrue(boolean b) { 
        HashMap map = new HashMap();
        b = ! !b;
        if (!(!(b == !b)) == false) {
            map.put(false, !(!(b != !b)));
        }    
        return !map.containsKey(b) & (!true | !false);
    }

I believe this is Java code.  It may also work in JavaScript but, fortunately, I'm not familiar with JS.  It may be the most amazing piece of code I've ever seen, maybe even better than x[strlen(x)] = '\0';.


Friday, March 22, 2013

sporkhack

I was inspired by the subject line of a co-worker's email: "+1 Gauntlets of Coding".  It was just an email with a link to wrist braces for carpal tunnel syndrome, but I really like the sound of Gauntlets of Coding.  I_have a couple ideas: when wearing Gauntlets of Coding, you movement speed will increase only when using the travel command.  Or, it gives you jumping.  Both are pretty big stretches at puns about using goto statements to either travel faster, or jump through code...  yeah...  I'll probably make Gauntlets of Coding a compile-time option, defaulting to not include them.

Moving on...

Sporkhack!  I've been spending more time playing sporkhack, and I have to say, what a fucking brilliant game.  So many changes.  From partial resistances, to sacrifice gifts based on XP level, to chaotic Knights, to variable telepathy range, to new items like gold dragon armor, shield of light, Dirge, etc... fucking brilliant.

Where some variants put a lot of effort into nice ncurses interfaces, sporkhack is all about gameplay. I'm seriously considering ditching the slashem source as my code base for my variant and starting with sporkhack instead, since there are just too many features from sporkhack that I like, and most of them are the bag of poo:



I do have two gripes about sporkhack, and they are very, very minor.  One, I don't like the new character creation screen.  When I start a new nethack game, I know what I want to play as, so I just run: $ nethack -u greg-rog-hum-fem for example, and the game starts.  Even if you do that in sporkhack, you still get taken to this screen:


So you have to press "." to start playing.  I realize how this starting screen can be helpful to new players, since it lets you know what combinations of role, race, and alignment are allowed, but I guess I'm just old and stubborn and like the vanilla nethack character creation system better.  Also, I sometimes run into a bug where, when starting a new game, I get stuck in a corner with no map.  I even tried starting as an archaeologist to see if I could dig my way out, but no dice:




Has anyone else run into this?  I'm using the sporkhack-svn package from the Arch User Repository, so it's possible that this bug is specific to that code.

...

When it comes to debugging, my strategy revolves entirely around printk (printf if I'm in userland).  I don't use gdb because I don't know how.  I've always wanted to learn... but it just seems too daunting of an exercise.  Sometimes I'll resort to objdump or readelf in a bind, but mostly, I just print out whatever things I'm curious about.

Is there a good way to dump debugging messages in nethack, other than using the pline function?  If not, I'll write a patch that will log debug messages to a log file.  Then anyone could just call something like nh_trace( LOG_WARNING, "blah blah blah %s, blah %d", ... ) instead of using pline, which interferes with gameplay.

Tuesday, March 19, 2013

Girl Power!

Who doesn't love numbers?  Well, sadly most people, and yet they still remain the best way of measuring things.  Go figure.

Special thanks to NetHack 4's maintainer, ais523, for the data.

These numbers do not include games that were started but never finished.  The player either had to die, ascend, die, quit, die, escape, die, or be killed.  There were 2788 games in total.

First, let's look at starting role vs. max xp level:


Okay, nothing too surprising here.  Valkyrie remains a solid choice.  Wizard has a tough early game but can become very powerful in the mid and endgame.  Tourist did remarkably well, meaning there are quite a few badass NH4 players out there.

One thing I'd really like to point out is that the Monk dominates the early game.  Lots of people dump on the monk, I don't know why, because they're not bad.  Only drawback, of course, is that they can't wear Gray or Silver Dragon Scale Mail unless at a high enough level to get over the big to-hit penalty.

Role vs. points is pretty similar, no surprise there, so I won't bother with the graph. How about ascensions by role?


Once again Valkyrie, Wizard, and Tourist take the lead!  More importantly, I'd like to see role popularity, because that will clearly affect the number of per-role ascensions.  (Thanks to the HockeyblogAdventure for pointing out the typo in the below graph title.  I'll maybe fix it when I get home from work).

This confirms one of my theories about Barbarians: they're boring to play.  Wizards are always interesting, though it's sad to see a lack of love for my favorite role, the Rogue.  It also confirms that Valkyries are strong role.  They are relatively unpopular (perhaps because they are so strong) yet have the most ascensions.

Also interestingly, people prefer to play Male characters, but Females have more wins.  Only ~24% of the players used female characters, but they accounted for ~64% of the ascensions:


I usually play female characters because I figure that if I polymorph into an egg-laying monster, like a dragon or cockatrice, I can make myself lots of awesome pets.  On the other hand, if an egg hatches in a male character's inventory, there's a 50% chance of it being tame.  On one hand, I don't use the egg-laying trick in most games, but on the other hand, when I do use the trick, I get lots and lots of pets out of it.  I'm curious what other peoples' preferences are.

Anyway, this post was just about some fun with numbers.  Let me know if there are any other interesting or more complicated stats you want to see.  I use the R project for a stats program, and it is superb.  Here are the fields with which I have to work:


"points"    "deathdnum" "deathlev"  "maxlev"    "hp"
"maxhp"     "deaths"    "deathdate" "birthdate" "uid"
"role"      "race"      "gender"    "align"     "name"
"charname"  "death"     "conduct"   "turns"     "event"
"carried"   "starttime" "endtime"   "gender0"   "align0"
"xplevel"   "exp"       "mode"


Also let me know if there are questions about what the fields mean.  I think the most confusing one might be align0 and gender0 which refer to starting alignment and gender, where as align and gender refer to alignment and gender at the game's end.  I don't know what the event field is.

Thursday, March 14, 2013

code restructuring, again

I applied the CK patch my kernel last night to give the Brain Fuck Scheduler and Budget Sector Queue I/O scheduler a try.  I'm more interested in the I/O scheduler since disk access is much slower than context switching, though in theory, BFS should give me ~2% better performance... 2%... yay!  Also, I know more about storage than CPU architecture, so I have a better idea about what's going on.  I gotta say though, I'm impressed with how quickly BFQ hits my external drive.

Moving on...

It's a sad day in Boston.  The Pats traded Wes Welker.  Everyone's pissed.

Moving on...

I came up with a better way to do code restructuring.  First, techniques can stay in their crazy switch block.  You can only do one technique at a time anyway, so there's no point in using function pointer madness.  However, none should return inside their case, rather, they should just break out instead and a single return will be placed at the end of the function.  Each should also specify their own timeouts.  Some do, some use the timeout at the end, some don't even have timeouts:



This is true of techniques and magical effects in general.  Being effects, all they do is modify data, so they can return void.  If it matters whether you succeeded or not, you can always check the condition after it returns.  Instead of linked lists for weapon effects, it will just be a dynamically sized array of effects, and I can loop over the switch blocks and apply each effect in turn.

Tuesday, March 12, 2013

random thoughts

I haven't had much time lately between a Bruins double header that started last night and heading up to VT to ski last weekend.  By the way, don't get stuck in chest deep powder, it fucking sucks.

Anyway, some ideas:
 - Weapons dipped in potions of sleep have a chance of putting a non-sleep resistant monster to sleep on a hit.
 - Weapons dipped in potions of acid do some acid damage on a hit.
 - Weapons dipped in potions of paralyze have a chance of paralyzing a monster for a random, short duration on a hit.
 - I'm sure there are some other cases.

 - Lenses of Infravision
 - Sunglasses (Lenses of Shade?) that would protect against blinding light-based attacks, and maybe give you +1 charisma when worn because they are so cool.
 - Artifact lenses that give you some sort of gaze attack when invoked at the cost of some magic power.

 - Shields of fire, ice, acid, whatever, from sporkhack, have a chance of doing passive damage to a monster if the monster does not hit you and you get the message that you deflected the attack with your shield.

Soldier role:

Soldiers can reach expert in firearms, saber, and maybe skilled in long sword and a few other weapons.  They would start with a pistol, as well as typical soldier gear: low boots, leather gloves, saber, dented pot, leather armor, tin whistle, and a few K or C rations.

I can't think of a good first sacrifice gift.  I don't just want to make it a gun because you'll have plenty of opportunities to pick up a gun later.  Maybe a magic magazine, base item bag, that generates a random number of bullets when invoked... but then again, you also have plenty of opportunities to pick up bullets throughout the game.  Maybe a special gun, a Magnum, base item pistol, that does more damage than a pistol and has a chance of stunning and/or knocking back an opponent like a monk's stunning strike.

The quest artifact would be The Holy Hand Grenade, generated blessed (since it's Holy), and the base item is a stick of dynamite (it's already in the code, not randomly generated though, so you'd need to wish for one).  Instead of the long fuse sticks of dynamite have, an armed Holy Hand Grenade would detonate in 3 turns, "One... Two... Three..." or sometimes 5 turns, "One...Two... Five!  I mean Three!"  Detonation would not destroy the Holy Hand Grenade, i.e., it can be reused, however, monsters can throw it back at you, of course.

The Holy Hand Grenade would grant some intrinsics when carried, but I've yet to figure them out.  I thought maybe fire resistance, but then you could just arm it in your inventory and become a suicide bomber...so you'll have to find another source of fire resistance if you want to do that.  Maybe extrinsic telepathy and half physical damage, or drain resistance (since it's Holy?), or something along those lines.  I'm open to suggestions.

The quest nemesis would be The Killer Rabbit of Caerbanno, base monster would be a rabbit.  It would be fast, or maybe very fast.  Would have stoning resistance and maybe some other resistances, but not fire.  Maybe I'll give him an extra bite attack or two, or a slim chance (5%) of his attack causing instadeath.

Thursday, March 7, 2013

code restructuring: technique

Before I talk about the restructuring of the technique code, I want to extend a big thank you to Finland, which is the source of the majority of my blog views, per capita (USA wins out in overall quantity).  In honor of your Finnish dedication, I will add a new comestible to my variant: lutefisk (please let me know if this is the wrong term in Finland).

My current thought is that it will behave similarly to royal jelly, but when eaten, will give the message: "This tastes like the worst thing you've ever tasted!"  I may change the message for the case when confused by a potion of booze, as I once read a guide to eating lutefisk online, and the first step was "get so drunk that you can't taste it."

...

Moving on, I'm almost done with restructuring the technique code.  Instead of a long switch statement, I'm using a function pointer for each technique.  This will allow for the potential of techniques having more than one effect, as the new tech struct can have a linked list of function pointers, where each function is called in serial.

For example, say we want a technique that deals cold damage and stuns the target monster, and a technique that deals fire damage and stuns the target monster.  The two techniques can share the stun code, so the first would have a linked list containing two function pointers, one to fire damage technique code, and one to stun technique code, whereas the second would have a pointer to cold damage technique code and a function pointer to the same stun code as 'fire-stun'.

Why restructure?  Part of the reason is because of shit like this:


A closer look:



This unreachable break statement appears all over tech.c.  My guess is that someone made the mistake early, when writing tech.c, then copy and pasted the mistake in several more places.  It doesn't make the game not function, but it's ugly.

With the new system I'm implementing, there could also be hybrid/random techniques that randomly select from a couple of the technique function pointers (they'd have to be compatible... combining bless and raise zombies doesn't make any sense).  These random/hybrid techniques could potentially be granted as sacrifice gifts, which would add an interesting dynamic to sacrificing.

As a next step, I'm going to take on the scroll/potions/spell effects... i.e., the type of stuff that can be broken up pretty easily.  Once again, the new structuring will allow for craziness like scrolls/potions/spells with multiple effects, etc, if I, or someone else, decides to add that in the future.

The point of all this is to make the code much more loosely coupled to make expanding and modifying the game easier.

Monday, March 4, 2013

"oh the beauties of C type declarations"

If you can figure out what I'm referencing in the title, you win a FREE download of the original nethack-3.4.3 source code from www.nethack.org!

...

As I mentioned in a previous post, the psion role is one of the motivations for making a nethack/slashem variant in the first place; the other being, why not?  Basically, the dominate ability will allow a player (or a psion) to willfully control another monster.

When you dominate a monster, you get to control it's moves and actions for, say, 25 turns, plus or minus some random amount.  I realize this can be too powerful in many ways, like walking a tough monster into lava to get rid of it, causing a nymph to drop your precious magicbane, or potentially, having a dominated monster on the astral plane zap a wand of teleport at pestilence to get him away from you.

Anyway, I've had some page views since I shamelessly (shamefully really) plugged my blog on the nethackwiki, so I'm hoping you guys can give me some suggestions.  For example, I can't decide whether to make it a technique or a HIGH level enchant spell.  On one hand, a technique makes sense if I want to restrict it to psions.  On the other hand, do I want to restrict it to psions?  And on the third hand, in implementing the dominate power, I will allow for the possibility of dominating more than one monster at a time.  There is a problem with the third hand though; it will slow down game play... no travel, no run, etc, because you have to control each dominate monster (plus yourself) individually, each step of the way, one step at a time...

Monsters would have a chance to resist, and there'd probably have to be monsters on the no-dominate list--shopkeepers and temple priests, special quest folk--but you'd definitely get a bonus against foocubi.

I've been hacking around the already hacked to death slashem code (I'm very guilty of returning early in functions as a shortcut, but does a function really need 30 return statements?).  I'm pretty close to a functional dominate within the current slashem code, but after going through monmove.c, I decided I need to re-prioritize.

The current game engine cannot support the dominate ability (as I envision it) without gross hacks and workarounds.  Originally I figured I could steal some of the polyself.c code and use gotos in the moveloop in allmain.c; in other words, gross, gross, despicable hacks.

This is about the state it was in when I decided to re-prioritize (the cursor to the northwest is just to show that it's a selection thing.  Nothing new there.  Eventually I'm going to move the cursor over to the kitten):




And then I moved him to the left... or tried.  The kitten is actually one place to the left, but I didn't get the screen drawing/updating working before I temporarily pushed the dominate implementation to the back burner.


Since I plan on restructuring parts of the code anyway, I'm going to do restructuring in parallel with hacking around with new ideas because the current code is too rigid at present for what I want to do with it.

I plan on breaking apart some of the monolithic functions into several more modular functions. The overall goal of the restructuring is to separate the game engine from, well, everything else (items, monsters, roles, races, etc).  I want to keep the interfaces to the game engine as uniform as possible for player and monster alike.  The hope is to make it easier to add new items, monsters, roles, races, and entire systems (bards, music, anyone?) to the game.

Also, a robust interface to monster strategy could pave the way for experimenting with alternative strategies, like monster AI-based strategies, or evolving/adapting strategies.  I will make this a future blog post, because I also have ideas for in-game evolution of both monster strategy and, well, monster creation.  What do you get when you cross a yellow dragon with a silver dragon?  A gold dragon egg.

Anyway, I'm going to start with techniques because that's already a pretty self contained system. Instead of the nearly 1000 line-long switch statement, I'm going to remake the tech struct to contain a function pointer to a function that handles that particular technique's effects.  I figure function-call overhead vs. switch statement efficiency isn't going to make a difference in a turn-based, user-land game.

Besides, who doesn't like to bask in the beauties of C type declarations.