Sunday, January 29, 2012

Timesink, part 3: Did someone say loops?


SPOILER ALERT: Those interested in playing on the server and taking part in the story I am planning should probably NOT read the following. It won't reveal any specifics, but it will disclose technique.

I'm still working on the next architecture type that will be destined for more woody biomes, so I thought I would take some time to describe how I plan in placing cities in the Minecraft world in an automated, systematic way which will appear random at first, but will eventually allow players to figure out where other cities are.

As a plant biologist that models hoe plants grow, I'm interested in the Fibonacci numbers (http://en.wikipedia.org/wiki/Fibonacci_number). This sequence of numbers (1,1,2,3,5,8,13,21,34,55,89,144...) is cool for a number of reasons I won't go into here, an will only point the enterprising reader to Schimper (1836), Braun (1831) and Niklas (1992) for some thoughts on the relationship between the sequence and plant biology.

One can predict the next number in the sequence for values greater than 1 using the equation:

Ni=ROUND(Ni-1*phi)

where phi can be approximated as 1.618.

Given this, one can make some interesting visuals, such as spirals. If you were to decide you wanted to make a plot where the Fibonacci numbers are both the radius and arc length, and if you multiply the resulting x and y coordinates by the sequence number of the Fibonacci sequence, than you end up with a spiral like this:



Throw in a consistent multiplier to make those x,y coordinates be really big, and you can see how you can easily determine city locations that would be separated by so much space that it would be hard for a player to accidentally find a lot of them.

But, let's assume the player _did_ find some. In fact, let's assume that the player started in one of the defined locations. How could one encode information that would allow them to find other locations?

Well, assuming the player knows their x,y, they would need to know:

1) That the cities are placed in a spiral.
2) What the multiplier used is

The first can be hinted at by placing spiral motifs all over the place for the player to find. One could even find ways to visually show the first few numbers in the Fibonacci sequence; maybe as pillars which appear in a sequence of 1, 1, 2, 3, 5, 8, and 13 blocks high.

The multiplier could be encoded into an important, central part of each city. Suppose the multiplier were 400. One could place those Fibonacci pillars on a very plain box that is 5x5x16 blocks. One could even encode which Fibonacci number the city represented by having a circular plaza where the radius of the plaza was the number.

Let's do an example for clarification, and you can check my math. The player finds themselves in the center of a circular plaza which has a radius of 10 blocks. The circular plaza has a conspicuous spiral pattern in the blocks used, and along the outside of the plaza are small towers which are 1, 1, 2, 3, 5, 8, and 13 blocks in height. "A-ha!," says our hypothetical player. "I recognize that pattern of numbers!" A quick check on the internet and they can either calculate or look up the sequence of Fibonacci numbers.

In creating the spiral as I have described, one of the cool things is that the angle in radians for each successive Fibonacci number in the sequence is it's order in the sequence. For example, the first value of one, with an arc length of one and radius of one, would be 57.32 degrees or one radian. The second value of one and radius one would be 57.32 degrees+57.32 degrees(114.65 degrees), or two radians. The tenth number of the Fibonacci sequence, 55, would mean n arc length of 55 and a radius of 55, which would be 573.24 degrees or ten radians.

If our enterprising player has figured things out, then hopefully they will know that a radius of ten in the plaza would mean they are at a point that corresponds with the tenth location on the Fibonacci spiral (Of course, there is room for confusion since the ten blocks of the radius might be thought to be a part of the arc length/radius relationship. Any suggestions on a way to clear up confusion?).

So in theory our player knows _where_ in the spiral they are, but not where other cities are. If they assumed there was another location with a plaza with a radius of nine (i.e. the ninth city in the sequence), they wouldn't even need to know their x,y coordinates to find the coordinates of he next city.

X=N*cos(radians)
Y=N*sin(radians)

where N and radians are the same value. In this case:

X=9*cos(9)
Y=9*sin(9)

or x=-8.200172357 and y=3.709066367

And here's where our multiplier comes in. If the plaza the player is in faces our 5*5*16 monstrosity, and they multiply the x and y by 400, they get:

x=-3280.068943
y=1483.626547

Throw in some clever means whereby the player can enter coordinates into a teleportation device (think Stargate), and the player can find other cities to explore.

What bothers me is that the player would (rightly) assume that the center of the spiral would contain something interesting. I'd rather if they didn't just jump straight to the first point in the spiral, but haven't thought through how to prevent this.

So, thoughts? Is my math wonky? Too confusing?

No comments:

Post a Comment