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

Wednesday, June 8, 2011

Graphics Speed Optimizing

Procrastination is dead.  Long live procrastination.  Yes, that is one of those fluffy flavor graphics I wasn't going to make until everything else totally working.  Sue me.

I'm feeling good about the project again, which is awfully nice.  I'm sketching out the speed boost for the graphics, which mostly consists of doing something about the *cough*mumble* hundred tree sprites. 

If I were very very careful, I think it would be possible to collapse all foreground layers to a single sprite with seasonal changes.  It would mean setting things up in Photoshop and snapping a "picture" of each season.  That would be fastest, and I'm not wholly opposed to it.  The downsides are: loss of flexibility and loss of variation.  The loss of flexibility is more serious - what if I touch up the "bare earth" layers, which I'm not happy with?  Instead of just saving new versions of the changed layers to the materials folder, I'd need to open the original Photoshop file, retake the pictures, and replace them.  If there's any kind of misalignment or color tweak, this would need to happen every time.  Those extra steps add up, and if I ever lost the master file, I'd be screwed.  (It would be a pain to recreate the master file from the current materials folder, but doable.)

So step 1 is making backups of the essentials - both the master photoshop file where I do tweaks and check general layout concerns before going into the canvas editor, and the original, large-size sprite files. 

After that, I'm planning on turning umpty hundred trees into a handful of layers: 3 backdrop tree layers, to give the forest on the horizon depth, and 1-2 foreground layers.  I'm planning to drop the interstitial layer between the front wave of grass and the back wave of grass, and merge the grass layers in-game, although I might add some seasonal herbaceous plants or flowers in there.  That frees up a layer for the cliffs, which have always been in the plans, but need to go in the far distance, behind the forest on the horizon. (Yes, it used to be bluffs - cliffs with a flat top - but now it's just sort of craggy hill things.  Turns out they're easier to make - bluffs are hard, and I couldn't find a top that I liked.  A for effort, but C- for graphical accuracy.)

In order to cut down on the work, I'm creating little tree groves - maybe a couple maples and a basswood, or five oaks and some bushes.  Arranging these tree packets is quick, and flipping stuff over and putting them in different positions makes it harder to spot that placement is not entirely random.  I practiced yesterday on the cliffs I made.  The forest is mostly in a place that won't be seen, but it was very informative.  Random placement is not as good as beginning at the back and working to the front - all kinds of overlap issues begin to crop up if you do that.  That means switching between sprites more often (so you get more diversity) or working over a larger area than the cliffs provided.  The grassland area should be fine.  Also, things get choked up with layers pretty darn fast - I'm planning on grouping every tree group into its own folder this time, and periodically combined/flatten out the various layers to speed things up. 

Or, you know, maybe your view will be of a prairie.  Writing all this out makes me tired.  Fortunately, it's definitely something I can do in little bursts of procrastination as a break from rewriting the damn hunting function, or implementing fish, or something.

800 width pixel crop - the small end of what I expect people to use.  I'm not thrilled with this one, but it does have some framing.  I think some branch/trunk might be better - but perhaps a bush under the tree would round things out.

1200 pixel crop - probably about where most people will end up.  Notice the complete lack of forests on the horizon.  Pretty sweet moon, though.  Notice how it's got a blue background during the day, just like a real moon?  Also, I think I better shrink the celestial bodies again.

1800 pixel crop - probably about as big as I plan to design to.  I feel like something should go on the left-hand side.  The dense pine forest is the experimental part of yesterday.  I think it looks pretty credible zoomed out.  (Zoomed in, it's pretty clear that I have exactly 2 pine sprites, and have trouble drawing cliff shadows with the mouse, and not enough patience to use more than one brush size.)
Cliffs, without trees. Something here is the wrong color.  Cliffs too white?  Back hill too blue?  Clouds?  I'd like to find a way to give the snowy hills some softness, but haven't been successful yet.
In other news, I fixed a couple minor things in clothing, and began to do the necessary work to make it possible to make clothes.  (Baby steps, but still.)  I stripped some old graphics code out of a couple places, where it was really gumming up the works, made some design changes to the way I want plants to behave, and investigated the Multitudes extension for the gathering of wild plants, and possibly a switch in tree calculations. 

Friday, June 3, 2011

FTA: Cooking

Mushroom cloud-shaped cake.  I worry about people sometimes.
One of the first IF games I wanted to write was a Iron Chef style competition.  Your PC would have access to a kitchen and supplies, and would have to fricassee, blend, saute, and garnish her way to victory.  At the end of a game, the judges would give ridiculous reviews of your hideously complicated dish, and you'd win if you'd managed to garner enough points. Or maybe you'd just win.

I got as far as the beginnings of a taste mechanic.  I figured if you were able to decide what combinations of flavors went well together, and assigned ingredients a specific flavor profile, you could have a fairly flexible system that would predict taste outcomes.  For instance, lemons and chicken are classic, so the game would give a certain number of secret bonus points for an bitter/sour poultry combination, plus a bunch of extra points if it wasn't in an expected "list" - lemon chicken in itself might not win you any prizes, but what about tonic water chicken, which would have a bitter/poultry combination? 

The mechanic really encouraged some bizarre combinations, some of which sounded remarkably unappetizing (blackberry bacon potatoes), but no worse than some of the real cooking competitions.

(I still think this game has potential to be hugely fun.  Someone should make it.)

My first impulse in FTA was to give the PC the ability to do something similar.  Sanity returned, though, and I realized I needed something way less intrusive and fiddly.  Most people do not carefully craft new dishes every meal.  I don't even think most *chefs* do that. The focus of the game isn't cooking, so it doesn't *really* matter if the potatoes you grubbed are pan-seared or not.  And God knows I'd get fed up with a game that required careful construction of three meals a day, over years. 

I've had some trouble clarifying what I do want, and this is part of that - nothing's set in stone yet.


The PC should be able to autonomously choose what to eat, cook it, and consume it.

Autonomous consumption should use food resources in a mostly appropriate manner.

The player should be able to force the decision to eat certain foods when necessary.

Desired Behavior

 The apple is sweet and crisp.  You toss the core in the compost heap.
You dine on fresh trout, steamed spinach, and roast potatoes, washed down with a couple mugs of ale.  For dessert, you polish off the last of the cherries.
 You roast nearly a dozen apples before your hunger is satisfied.
You make beef stew, thick with chunks of top round, carrots, and onions, simmered in red wine, and set it aside for later.  
So there's four things here, in order of increasing difficulty.


When the EAT command is paired with an edible food, that is consumed, with nothing else.  (EAT [meal] redirects to MAKE [meal].)  If the food can be eaten raw, it is; if it can only be eaten cooked, an autocook reaction is probably in order.  If the food is a discrete unit, like an apple, the PC will eat only one.  (Maybe.  It seems like there should be an option like EAT APPLES that would loop until hunger was satisfied or the food was gone.)  If there's a lot of them, like berries, or it's a fluid or powder, like cornmeal, the PC will eat/prepare up to a given serving size - maybe a bowl full? - or caloric intake - if she's hungry, she'll eat until she's not, and if she's not, she'll eat a small meal/snack, up to the point where's she's too full to eat any more.

I kind of waffle on this bit - perhaps a single serving is appropriate under all circumstances.  If you eat stew, you eat a single bowl of stew.  If you eat bread, you eat a single slice (or roll, or whatever).  Not sure what the player's intentions would be.  I think either is potentially fine, and the single serving is less complicated, but jury's still out.

If different cooking methods are used to cook foods (ie boil vs. saute), eating would use the least demanding and/or quickest method of preparation.   EAT OATMEAL pretty much means cook up a batch of hot cereal, not turn it into cookies or bread or bake it.  (Although baked oatmeal is kind of amazing, and I should totally make some tomorrow.  Also, I should not work on food design when hungry.)

Make a meal

The PC decides, on her own, what the most appropriate meal is.  This requires looking at the hunger state of the PC to decide a calorie target for the meal.  (Obviously, if the PC's too full to eat, she's too full to eat.)  There's a location that is basically the "home kitchen" of the PC - initially, this is likely to be a campsite or cave.  Later, it should be the Kitchen room.  The game will look at the food available in the inventory, the home kitchen, and any nearby food storage rooms (the cellars, for instance).

From the available choices, the game will make decisions about what to eat.  This bit is kind of blurry - for instance, should there be a preference for breakfasty foods at breakfast?  But here's a first stab:

- Meals may consist of a main dish, plus 0-4 side dishes, something to drink, and optional dessert.
- Main dish, by order of availability:
    - non-preserved, very short shelf-life food - fresh meat or fish especially
    - calorie dense foods near their expiration, or shortish shelf life foods - breads, fresh green beans, corn on the cob, farmer's cheese, most vegetables, eggs
    - less calorie-dense foods with shortish shelf lives, combined with something a little richer- lettuce, tomato, with cheese, oil
    - moderate shelf life foods - things that might last days or a couple weeks - cured meats, potatoes, onions (with other calorie-dense food if possible), winter squash, other "keeper" vegetables 
   - long shelf life foods, preserved foods - dry beans, dry grains, canned goods, dried fruit, jerky, hard cheeses.

Side dishes - a variety of other categories of foods, either chosen to round out a food pyramid type thing, or by chance (or both).  Main + 2 veg/fruit + 1 fat/condiment + 1 grain is a pretty rough start, but yields something that at least pretends to be a balanced meal: bacon, buttered toast, tomatoes and potatoes is a better breakfast than I usually get. Of course, I'm fudging a lot of random stuff I'd be bound to get: trout, squash, corn on the cob, cheddar and oats is kind of weird.  And it would be awhile before there's much chance for randomness - most PCs are going to be eating a lot of spam, spam, spam, spam, and spam (or whatever they brought).

The nice thing about having a tier is that it seems to respond more to actual events than it does.  Since fresh meat is preferred, a successful hunt will mean that the PC can sit down to a nice bit of roast rabbit the same night, which seems like a natural response to running across protein.  And it doesn't require secret checks into whether the PC *did* go hunting - it just looks for the proper foods available.

Make a meal with something

This would be the flip side of EAT APPLES if I don't implement a "eat X until you're full" policy.  This would allow either specifying the main, or more likely, consuming as much of a food as can be managed.  Useful for trying to consume a supply of food before it goes bad - if the PC shot a deer in July, but had no curing facilities, she needs to consume as much of that meat as possible before it goes green.  But standard meal practice will only include a serving size (possibly two, if the PC is very hungry) of the fresh meat with each meal, unless there's nothing else to eat.  

Alternatively, the command could be used to force a main dish - if the PC has a fresh rabbit on hand, but wants to turn it all into jerky, there should be a way to easily dodge the default behavior of eating it for dinner.  At that point, MAKE MEAL OF BEANS should work.  This could be a totally extraneous command, depending on how EAT [something] is handled, but it's worth noting that the behavior does some nice things.

Make a specific meal

There's basically two parts of this command, one pretty froofy and one pretty necessary.

Cooking and eating takes place simultaneously.  I toyed with the idea of a meal object, but there's a bunch of problems with it that I just couldn't fully resolve.

One thing not covered would be a case where the PC would want to pack a meal to eat later - say, if she was going hunting.  This sort of thing would have to be covered by carrying edible food and then EATing it.

The necessary part: being able to make food *without* eating it, and being able to make food that takes sort of a long time against future use.  It's possible to limit this to just a couple foods, I think, but the best example is bread.  Making bread isn't part of normal meal prep.  It can't be part of normal meal prep, at least for rising breads.  It takes time, and a fair amount of work time.  So it makes sense to make bread when you have the opportunity, and eat it later.  This is a totally sensible thing for the player to expect, and really helps with time management.  (And bread's a pretty key comestible for a bunch of English speakers.)  It makes sense from the PC's point of view as well - it makes sense to take your lunch with you if you go cut down trees or hunt deer or fish trout, rather than hiking an extra few miles back to camp to slowly cook something.  Pretty much every culture has portable food for trips and situations where you can't get home.

It's a logical extension of being able to MAKE BUTTER or MAKE CHEESE.

With the theoretical tools planned, it's possible to have dried meat or fruit or something, but I'm not entirely that justifies an inability to make bread.  (Especially since it's cheaper and easier to lay hands on flour than meat or fruit.)

The less justifiable bit would be a list of specific foods and cooking methods.  This one's super tempting, but also one of those holes you'll never fill.  It would be kind of awesome to MAKE POACHED EGGS, but even I have trouble justifying it.  And it's bad enough for stuff that has a recipe - I can give a pretty good argument that most chocolate cakes contain more or less the same stuff.  (There's always exceptions.  Don't email me.)  But what is a stew?  What goes in a stew?  Meat, sometimes.  Root vegetables, sometimes.  Other vegetables, sometimes.  But hardly ever green beans.  Why?

I think I could assemble a recipe using either a specific ingredient or a kind, plus an amount.  So a stew might have 6 oz of meat, 10 oz of root vegetables, and a list of optional additions (1 bay leaf, 1 bottle of wine, 2 tsp ground pepper).  But holy fuck that's a lot of work, and it's hard for me to believe that it's worth it for anyone involved, especially since that stew will stay fresh less than a day, and in the meantime get all congealed and gross.  And let's face it - there would never be enough recipes to satisfy people, and knowing me, there'd be some kickoff as to whether the proper crust for a key lime pie is graham cracker or wheat flour, and the world would end.  (Graham cracker.  Also, no whipped cream and certainly no meringue.)

I *think* I might be able to do a decent job with a few cooking methods: MAKE APPLE PIE wouldn't work, but ROAST APPLES would.  I don't know if that's better or worse than doing nothing.  Worse, I suspect, but it's still mostly on the table, whereas the whole recipe thing . . . yeah.  Not unless I can find a way of doing it that is easy, straightforward, and just requires a couple easy-to-remember inputs into a table.

Heh.  We're moving right along on the list of features no longer under consideration.  On the up side, I never even started the recipe collection, so I'm going to count myself about 100+ hours ahead of where I would have been.

But I do need to chew over what, besides bread, the PC should be able to make and store.  It seems reasonable to me to put a few desserts on the list.  I'm looking for stuff that's fairly common - bonus points for having cultural significance.  For instance, cake seems like a real possibility.  Sugar is hard to come by, but possible, and it seems reasonable to let the player set by a dessert or two.  Also, cakes have a bunch of nice connotations - if I were post apocalypse, I'd totally try to find a something to celebrate my birthday.

If you, dear reader, think of anything else, let me know.  Preservation is a whole other issue, so dried fruit and meats, cured sausages, canned stuff, cheese/butter, and alcohol is handled elsewhere.  Also, I was going to make a joke here about how there's no apocalypse cookbook and that's totally a market niche, but I was wrong.   Then I was going to make a joke about there being no post-apocalyptic cookbookD: