Design and documentation journal for my interactive fiction (text games); also reviews and other miscellaneous stuff.

Tuesday, July 20, 2010

Nut Trees and Headaches

I was working with some loose ends on trees. (I still can't get the game to recognize "pin oak" - it always defaults to northern pin oak, regardless of where it's defined or what the "should the game choose" or "does the player mean" values are set. I may have to take it out entirely. No huge loss, but it is irksome. I've had better luck with swamp white oak vs. white oak. Why? An excellent question.)

So I thought: Self, this is a good time to define some nut trees. Nut trees are a kind, and contain just a little extra information. Fruit trees are going to be pretty complex, but nut trees are an older, more primitive thing.

Basically: each species has a constant called max_harvest. (Actually, this is on every tree, in case I do get around to letting the player "improve" them. I might move this to a global constant.) There's also an interval variable, which indicated the frequency of "good years". Nuts tend strongly towards big crops followed by several years of smaller crops. This is calculated for each tree separately; I think real-life species tend to follow the same patterns, but I couldn't quite bear to have the entire walnut crop fail at once. There's also some luck involved. Each species can have a good year or bad year (+/- 10% of crop weight), and so can each tree. There's also an overall harvest_luck variable that does the same thing. So in a really good year, trees can produce 130% of max_harvest, which is a mid-high guess for wild nut production numbers.

What I need to do: factor in age and size. Immature trees shouldn't produce at all. Trees that are smaller than max (or maybe a percentage of max) should produce a scaled quantity of nuts. (That is: a 30' oak should produce 3/5 the nuts that a full-sized 50' oak would produce given the same numbers.) Right now, trees have neither ages nor sizes. Age is easy; size is not, since it means completing the Table of Dendric Doom.

In lieu of that, I've created a scene, During Fall Nut Harvest, that goes from mid-September to mid-November. Once a day during the nut harvest, nut trees can drop some of their nuts. Theoretically. They calculate the right weight to drop, anyway, and I think I finally got them subtracting the drop weight from their current_harvest correctly. (Testing is definitely needed.) I'm having difficulty with the nut objects, though.

The problem: Nuts are kind of like liquid. You don't really >TAKE 1000 NUTS, nor would I want to model such a thing. You take weights or volumes. (Volumes, actually, but weight is easier for me to work with.) So the same way you might >TAKE A CUP OF WATER or >FILL BUCKET WITH MILK, you might >TAKE HANDFUL OF NUTS or >FILL BASKET WITH NUTS. And you don't really want to take inventory and find that you have:
- a handful of acorns
- some acorns

So I decided I needed some sort of combine command, where objects like nuts or water could be smushed together by weight and variety. So instead of two discrete acorn objects, there would be one with the weight of them both, and the second object would go poof, or never exist in the first place, depending.

This sounds awesome on the surface, right? But it's sort of like introducing a rope to your game. After a few minutes thought, the problems start emerging. Then you have to sit down somewhere quiet. Then you have to have a stiff drink.

For example: nuts don't last forever. Are you just going to mash the old rotting ones together with the fresh ones? And sometimes, it is appropriate to combine things - say, cold water and hot water, but you'll need to recalculate values. Not that I intend to have cold and hot water modeling. Worse, you need some way to communicate the difference between these two things to the player, and differentiate them to the parser. So the parser should distinguish between the older nuts and the newer nuts the player is carrying. When do you try this combining thing? Before taking? After taking? Instead of? Each has some problems. What if the player tries taking more water than she can carry? The game should do the same weight/volume checks as for normal objects, but should it adjust the total?

What about commands like >PUT NUTS IN BASKET - how should the game behave to that?

So the more I flailed, the worse the whole situation became, until my brain shut down for self protection. So, nuts are sidelined for now. Maybe I'll go by "[weight of nuts] [nuts]" for now, if I can get that filled out to marginal satisfaction. Or maybe I'll put a big red star there and come back to it.

No comments:

Post a Comment