Saturday, 1 December 2007

An Analysis of Shopping In Angband

It is with tired hands and a weary brow that I have to admit to you that, in fact, I have spent the last ten or so years, working on a game about shopping.

Angband, as I have mentioned numerous times, is focused on inventory management. And a big part of that inventory management is the art of purchasing goods from the 7 stores in the town precariously perched above Morgoth's iron prison.

Let us not forget the absolute suspension of disbelief that having the fantasy equivalent of a small arcade directly above the bastion of all that is evil requires. Or the fact that the jaded and world weary shopkeepers will not cut you a discount, even when you have felled that ultimate enemy of light and heft the weight of his mighty hammer in your hand. The recent discussions on the impact on Charisma in the game point to the pithy contrast of absurdity and game balance requirements that having shops in the game entails. Of course, you can get rid of them completely, but in designing a variant which has multiple towns as waypoints onto the same final destination, I'd like to find a suitable half-way house in which they can be maintained.

Well, for a start, lets have a brief discussion about what tools that the current shop system avails us, and then look at where it might take us.

Shops in Angband consist of an inventory, a stock list of items that could be potentially generated in that inventory (with a fixed probability for each) and a shopkeeper with various racial preferences and a maximum purse from which he can purchase goods. Of particular note is the black market, which as opposed to having a fixed stock list, instead stocks items as if generated from a certain depth in the dungeon.

The player buys from the stores inventory, and buying up the entire inventory causes it to be generated anew. Periodically the inventory is refreshed, which results in some items being removed from the inventory, and others being added. This may also result in the shop keeper being replaced by one that is either less or more generous, and has a different purse size.

The player can also sell equipment that is found in the dungeon to the appropriate store. In this instance, the shopkeepers purse is the maximum sale value that the player can get for a single item. The sale price is guaranteed to be no more than the purchase price, and the black market is not worth selling to. Obviously the player can only make a sale if the store inventory is not full.

The disadvantages of this mechanic have already been discussed in Andrew Sidwell's analysis of Charisma, with particular reference to the impact that Charisma has on shop prices. It should be worth noting that various variants have tried to fix parts of this design, by creating store services, which allow the player to spend money in store in return for having their weapons enchanted, items identified and so on, and on allowing shops to stock better items than their original inventory, sometimes requiring an investment of funds for this to be the case.

As is always the case, it is worthwhile going back to first principles to analyse why we would potentially want shops at all. They serve the following functions:

1. To justify the function of money.
2. To allow low-level players to get additional cash by selling items found in the dungeon to the shops. This is useful up to a point, beyond which money stops being important.
3. To allow players of all power levels to get various essential supplies - food, light, magical healing, escape magic, ammunition for their current weapon, and so on.
4. To allow players to upgrade their existing equipment through purchasing scrolls of Enchant Weapon and Armour.
5. To sometimes allow players to spend a larger amount of money in return for a useful item.

Point 1 could be substituted for the original purpose of money in Rogue, which was a measure of score. This works well, but I'm not sure that game players these days are as focused on score as they may have been previously.

Point 2 works well, as mentioned, up to a point. There is definitely a tipping point where the amount of money recoverable from selling items exceeds the ability of the player to spend it. This actually occurs in several stages: the first can be exploited through a quick descent to level 3 in the game, where the first wands start occurring. Wands are problematic in that they are light and valuable, and reaching wand depth is usually results in you can afford all the basics. The next major boost is usually when you start finding enough ego-items to be able to haul them up and sell them. Very quickly after that, money stops being an issue and the actual contents of the store inventories becomes your limiting factor.

Point 3 is usually frustrated by the actual selection of required consumables in the stores. If you are out of something 'essential', you have little choice but to descend to level 1, and rest it out until the shop stock rotates, at which point you can have a chance of finding the item again, although it is not guaranteed. Of course, the definition of what is 'essential' differs from character to character.

Point 4 is the most effective money sink in the game, because of the diminishing returns on investment of the various enchantment spells. At the same time, this results in much game-balance breakage, resulting in warriors wielding (+9, +9) daggers instead of long swords, because they've been able to enchant the lower powered weapons up, and the poorly thought out combat design encourages lighter weight weapons.

Point 5 is a great money sink, very occasionally. Usually what happens is 75% of the stores are filled with 'useless' non-consumables, such as 3 Morning Stars, or 7 Maces, piles of which are less than useful for just about anyone.

Rectifying the situation will have to be done very carefully. Just making money useful again by allowing more appropriate purchases will have the unbalancing effect when money stops being a problem to acquire.

So what are my recommendations? I'll discuss what is best suited for Unangband, since that is where my interest primarily lies.

1. To address point 2, you want the shop keepers to scale down the amount of money they'll be prepared to offer the player for equipment. I'd do this by adjusting the shop keepers purse directly. If they buy stuff off the player, decrease the purse size by the value of the purchase - if they sell stuff to the player, increase the purse size. That way, the purse becomes a direct measure of how 'profitable' the shopkeeper is.

So what happens when a shop keeper runs out of purse. Well, to avoid this happening, I'd scale down the amount the shopkeeper is prepared to offer, as their purse size drops, and treat some of the scale down as future 'profit' which the shopkeeper realises the purchase by selling it to some other suckercustomer. And as their purse increases, increase the chance that shopkeeper will rotate out, by retiring, so that the player can't recoup their 'losses' through a big sale.

Alternately, you could periodically reduce the value of a high purse shopkeeper, and in return add to the selection of consumables that they stock, as discussed in point 2 below.

2. Point 3, the selection of consumables, is too random at the moment. The list of consumables should be a list of fixed items available, which is regenerated with each shop refresh.

However, the actions of the player should be allowed to change the consumable list. I'd recommend the following sequence of events.

a. The player sells an item to the store that the shopkeeper hasn't seen before.
b. The shopkeeper gives the player a quest to find x of these items, so that he can analyse them to work out how they are made.
c. The player completes the quest. The shopkeeper gives the player a quest to find a set of ingredients in order to make the items. These happen to be made from a monster.
d. The shopkeeper starts stocking the item in question.
e. Periodically, the shopkeeper runs out of ingredients for a consumable item that the player has purchased. This means that the shopkeeper cannot restock the consumable, until the player completes a similar ingredient quest.

3. Point 4 has been 'fixed' in Unangband, by adjusting the weapon enchantment routines. I can only recommend something similar for Angband.

4. To address point 5, and deal with the problems Andrew discusses around Charisma, I recommend making stores stock one or two high level items each, and have those rotate frequently. The 'level' at which the item occurs should be based on a number of factors: Charisma being the most important one. If you drop Charisma's impact on prices, and make high Charisma result in better 'special' equipment available, Charisma will still have a much needed impact on shopping, without affecting the overall money supply. In fact, higher Charisma will result in the player having less money, as shops will create 'more appropriate' items for him.

This is the most complex recommendation, because you still want to have the player able to have most of the equipment come from the dungeon, while encouraging him to spend money where ever possible. So tuning the nature of the items is critically important. Ideally, you want the shops to generate '2nd-tier' alternatives for the player: say items about 80% of the power of what he is finding in the dungeon. I suspect you'll want to cheat, and pick item abilities directly based on what items the player currently has. If you make Charisma work on the 'appropriateness' match as well, that'll encourage the player to focus on Charisma further.

Of course, the brokeness of the stat-gain mechanic is food for thought and potential discussion in another article.

[Edit: I've followed this up with a brief post-script.]

2 comments:

Mikolaj said...

I like all you propose.

I think the shopping game is actually quite nice as it is, despite having the various problems / wierdnesses / stages. Therefore I'd be careful not to break it and certainly I'd not remove it. I think the real problem is when the other aspects of the game are not heroic enough or easily winnable with enough shopping. Then the problem is that the shopping is _the only_ important part of the game and this is bad.

The only problems I've found to date are when you have not enough home space (V, O, S) or too much homespase (TOME) to play the shopping game in the scale suited to the properties of human's mind. Another problem is when a town unique drop or a lucky find of a stack of branded ammo / throwing weapons make the scarcity stage of the game too short. Another when shops are useless and e.g. you have to make unnatural things like shopscum or buy out. Probably the most important problem is in repetitiveness of the shopping game in mid-game, when a popular way of playing is to WOR down, loot, WOR up, sell, repeat until you can buy any speed items you want. Your ideas with purse and quests are quite promising in making this stage more interesting.

One last thing: I really hate (I don't know why) when good items are generated in the dungeon according to player class or equipment. For quest rewards or for shops this is OK, though, but I'd be very careful not to block some original strategies by, say, never generating good bows for mages, or otherwise doing stupid things, like never generating a vital resist, because a warrior already has it on his wielded broken dagger...

Joseph said...

This post just resurfaced on Reddit. No idea why. :-)