Wednesday, April 12, 2017

Digestion Game Work, Typing Outloud

hey all,

Still slaving away at the digestion game. Those horrible redundancies I found last week are now all cleared away, but I am left with the design decision of how to keep track of the player's nutrients.

In a nutshell, it has to do with time. Right now, in the mouth level the player is in control of when food spawns in for chewing and swallowing. Because of this the player could just hit the space key a bunch of times and have chicken, pizza, and whatever shot at their face over a few seconds. If the player successfully chews and swallows all that food in such a short time, under the current rules, the player will just go to the next stage of digestion in the stomach. Or the player could start the level, go away and do something else, letting game time tick by, basically starving the avatar to death. But because I'm not keeping track of efficiency in this level, nothing will really change in either case. The question is: should I be keeping track of this?

In the stomach, the player is not in control of when or how often food appears. I've already spent a lot of time developing a cyclic function that ramps up and then ramps down the appearance of food chunks from the esophagus. This is supposed to mimic meal time, with peak food ingestion occurring every X seconds. One course of action would be to rig the function so that meals occur at 8AM, 12PM, and 6PM, and then fast forward through the night to 8AM again. Or maybe force the player to spend the night digesting the day's food. This second option seems to match reality more.

The same problem occurs in the small intestine. The player is not in control of when the nutrients appear any more, but again there is a cyclic function. Based on my gut feelings (haha) of the above, I think saving the game time from the stomach level and continuing the digestive process from there seems most logical. After all, if the goal is to make the player understand digestion, seeing how much time it takes for food to be processed by their body sounds like a good learning goal.

The big issue lurking behind all this discussion of time and energy is player health. A large part of one's health is determined by the ratio between how much energy is coming in and how much energy is being used up. If more is being used up, the player should starve, right? And if more is coming in, the player should get fat, right? So far, at least, I have focused my time and thinking about the latter more than the former, and actually I'm not sure if it would be a good idea to include the first option. I mean, if you are not getting enough food, there is not much digestion going on, so what can you learn about the process of digestion, right?

In any case, I have been thinking that I will need some way to keep track of game time, and of displaying the game time to the player. Also, I'll need caloric values for my food chunks and nutrients. Then, I'll need an upkeep value for the human body. Luckily, we already have the figure of about 1,500 ~ 2,500 Calories/day for the average adult. Based on the player's initial choice of diet (only meat, random, food pyramid, etc), I can change what foods appear. This will lead to differences in what food chunks appear in the stomach, and later to differences in what nutrients appear in the small intestines. I think I will use the small intestine as the place to show how the player's choices have affected their body, since it is in the small intestine where nutrients are actually absorbed by the body. Since I know how much energy the body needs, it should be a relatively simple matter to figure out if the player's choices are producing more, less, or an appropriate amount of energy for the body to use. Here's a little snippet of what I've been working on:

for (int i = 0; i < totalFoodChunks.Count; i++) { totalCarbs += totalFoodChunks[i].GetComponent().carbAmount; totalProteins += totalFoodChunks[i].GetComponent().proteinAmount; totalFats += totalFoodChunks[i].GetComponent().fatAmount; } carbPercent = totalCarbs / (float)(totalCarbs + totalFats + totalProteins); fatPercent = totalFats / (float)(totalCarbs + totalFats + totalProteins); proteinPercent = totalProteins / (float)(totalCarbs + totalFats + totalProteins); integralPart = (int)(carbPercent * 100) + (int)(fatPercent * 100) + (int)(proteinPercent * 100); decimalPart.Add(new NutrientRatio(NutrientType.Carbohydrate, (carbPercent * 100) - (int)(carbPercent * 100))); decimalPart.Add(new NutrientRatio(NutrientType.Protein, (proteinPercent * 100) - (int)(proteinPercent * 100))); decimalPart.Add(new NutrientRatio(NutrientType.Lipid, (fatPercent * 100) - (int)(fatPercent * 100))); remainder = 100 - integralPart; if (remainder != 0) { decimalPart.Sort(); decimalPart.Reverse(); for (int i = remainder; i >= 0; i--) { decimalPart[i % decimalPart.Count].amount++; } }

This is one of my functions that at the start of a level loops through all the food pieces and gets the values for its protein, carbohydrate, and lipid content, then computes the percentage of each, and lastly uses the same Hamiltonian method for converting a floating point percentage into a representative integral one that I used in my personality code months ago. I'm using this, again, only at the start of the level to set the chance of spawning a protein, carbohydrate, or lipid based on the food pieces the player ate before. Since the amount of energy for a gram of lipid, carbohydrate, and protein is pretty well-known (9 Calories, 4.5 Calories, and 4.5 Calories respectively,) from these I can compute how much energy the player is receiving. Cheers,

No comments:

Post a Comment