How to write “dependent” understanding-when rules? - inform7

I’m in a situation like this:
"Cream Corner" by Lynn
An ice cream cone is a kind of edible thing.
An ice cream cone has a number called scoop count.
Rule for printing the name of an ice cream cone:
say "[the scoop count in words]-scoop ice cream cone".
The Cream Corner is a room.
The player holds an ice cream cone with scoop count 3.
Now I want > eat three-scoop to work. I can do this:
Understand "one-scoop" as an ice cream cone
when the scoop count of the item described is 1.
Understand "two-scoop" as an ice cream cone
when the scoop count of the item described is 2.
Understand "three-scoop" as an ice cream cone
when the scoop count of the item described is 3.
[ ... ]
But of course, ideally, I’d like to write a rule like this:
Understand "[number]-scoop" as an ice cream cone
when the scoop count of the item described is the number understood.
However, the Inform documentation specifies that this is impossible:
So we cannot safely say "when the noun is the fir cone", for instance, or refer to things like "the number understood". (We aren't done understanding yet.) If we want more sophisticated handling of such cases, we need to write checking rules and so on in the usual way.
All the same, it isn’t clear to me how to replace such a rule with a checking rule “in the usual way”. How do I use checking rules to make [number]-scoop in the player’s command be interpreted as “an ice cream cone with that many scoops”?

I'm not quite sure what the documentation is implying we do there, but I can help solve the base problem. A partial solution is these two lines:
Understand the scoop count property as referring to an ice cream cone.
Understand "scoop" as an ice cream cone.
This allows the player to type things like three scoop cone or three ice cream cone, and have the three-scoop cone be understood.
This is only a partial solution, as we don't include the dash*, so something like take three-scoop cone wouldn't be understood correctly. The obvious way of solving this problem is by replacing the dash entirely before the command is read, something like this:
[Nonfunctional solution!]
After reading a command:
If the player's command includes "-scoop":
replace the matched text with " scoop";
This doesn't seem to work however, as the above rule matches only whole words--i.e., three -scoop, but not three-scoop. Attempting to do the same with only replacing - fails similarly.
*You can also argue that three ice cream cone shouldn't be a valid match.

Related

How should I exactly mix refracted and reflected color, fresnel

I am building a raytracer in C for the school. Yesterday I successfully implemented my first recursive refraction, however I am not very satisfied with the result. a picture of my raytracer with 2 reflective spheres
I find that the water ball doesn't look like a water ball so if you have some advice on what I should do next tell me please, from what I had read:
Beer law
Making the darkness of the shadow depend on how long a ray light traveled trough a refractive material (I guess I can use beer law for that)
I suspect this could come from my implementation, here is what I did:
first I set a material like that:
-DIFFUSE 1
-SPECULAR 10
-REFLEXION 0.1
-REFRACTION 0.9
-IOR 1.33
This are the characteristics of my water material.
Since I am using fresnel to calculate how much transmitted and refracted colore I should take to compute my final colore I am wondering if my reflection and refraction coef shouldn't be simply Boolean. Right now I am using them to ponderate how much reflection and refraction colore I should use, but isn't it too much since I am also using fresnel? I am a bit confused about this part and red a lot of PDF from a lot a university but the precise mix isn't cover by them, they just tell us to use fresnel to choose how much reflected or transmitted light we should use but when they put pseudo code you can read that they call recursively them function: if (material->is_reflective)
if (material->is_refractive)

AI Snake BFS Issue

I am working on solving snake boxing itself problem. I believe that If I use Breadth-First Search (BFS) to make a move, it can reduce the risk of being boxed greatly. My question is how many possible empty spaces (connected) I should look for to make sure that this move will not result in boxing myself.
The distance you have to look to see if you are boxed in is always going to depend on the size/position of the snake. The only way to be 100% sure is to search all moves in advance, and avoid moves that lead the snake to be boxed in. That said, you might have better luck with a depth-first search over breadth-first, because it can rapidly find a dead end (if it exists). Then avoid those moves. In your second example, depth-first would quickly find that moving "up" is a dead end.
I think the number of moves deep you need to search the game tree is related to the square area the snake can contain when it encircles itself. For example, a length 12 snake:
----
|00|
|00|
91--
If the snake goes up (north), it can still live but only if it then goes east. if it goes north again, then it dies.
The maximum area a snake can contain is: (length/4 - 1)^2. When this is fractional, you probably want to round up.

How do you create 2D vines procedurally for a game?

For a game I am making I want to create 2D vines and vine like structures procedurally. Is there some paper or code snippet that someone can point me to?
Googling results in procedural trees which have straight spiky branches, but I need to create vines which are curvy. Think Jack and the beanstalk type of growth.
http://youtu.be/2wq541W6LyE?t=2m11s
Your particular approach is going to depend on how you game handles drawing and collisions.
An approach popular with flash-based games is to draw the vine to a bitmap: Since you don't list your programming environemnt, I'll just explain the steps, not the code.
Start with a circle,
1 draw it,
2 move it,
3 scale it down.
4 At a random interval, spawn a "branch" and or a leaf.
Set the scale and position of the branch to match the parent. Start a 1-5 loop on the branch.
5 repeat 1 until fully grown (scale is too small to proceed).
In the move phase it can be handy to use Sin curve to make your vine weave in and out.
Youcan tweak the settings for how much it curves to get different types of vines.
Here is a link to a discussion fo teh topic. Some good source to be found in the links.
http://groups.google.com/group/flashcodersny/browse_thread/thread/9906041e557e620c
Including source code inf flash:
http://xfiles.funnygarbage.com/~colinholgate/swf/varicoseg.zip
And a javascript version that looks more like lightning, but couild be adapted to vines without much change:
http://www.brainjam.ca/hyperbolic/01_spite_mrdoob.html

Gray code pattern in tournament chart?

In a tournament chart from the bottom to the top where there is a winner I've been told that it is somehow connected with the gray-code. I know that the grey code is an alternative code, it's recursive and is useful to find the best solution in various games, space-filling-curves, error correction codes, harddisk positioning and is a shorthand for the piano player but how is this code is related with a tournament chart?
Parsed the following from here:
A tournament is really a node in a binary tree. The value in each
node contains the ranking of the best ranking team contained in the
tournament tree. It turns out that the gray code of the ranking-1 has
a bit pattern that conveniently helps us descend the binary tree to
the appropriate place at which to put the team. When descending the
three, the bits in the gray code of the ranking from least-significant
to most-significant indicate which branch to take.

Expressing order or disorder mathematically

I work for game development company which makes casual games. One of the main casual genres is match-3: there is a field and chips of different colors. One should move chips so that they make lines of at least three chips of the same color. If the move leads to making a line the chips in the line disappear.
Chips on field can be located differently: there may be a lot of chips of the same color gouped in one place or there may be a situation when a player can't make a move - all the neighbour chips are of the different colors.
So, I want to express the situation on the field mathematically with a factor of order (disorder). If the factor is high a player can make a lot of matches and the lines made by the player are long. If the factor is low, the field is in complete disorder and one can't make a single match. This may be helpful for generating field of different difficulty.
The question is: what branch of math can help me to do this. Where should I start my research. Any suggestions for keywords to google?
Thanks in advace.
Entropy.
I would look into graph theory. You can for example make a graph, where nodes would be positions on the board, and two nodes would be connected with an edge if they are neighbours and have a chip of the same color. If you have large components with nodes of large degree, you have less disorder. If all your components are small, you have high disorder.
First thing that comes to mind is that you're looking at the distribution of n populations (one for each color), which I would approach with Poisson sampling,. You can use that to calculate the probability of finding two adjacent units of the same population (color), which will give you a measure of the difficulty of your puzzle.

Resources