Minecraft and math
13 years ago
General
So earlier this week I came across a modern recreation of the programing language I used to work with when I was a teen. Its been about a years since I put together a little playlist utility. Unlike most of the programing languages I've come across this version has really easy commands for dealing with clients and servers over the internet. So I deiced to mess with Minecraft.
I am using an programming add-on for an alternative Minecraft server call Bukkit. Raspberry Juice is a PC add-on to emulate the programming interface and commands for the RaspberryPi version of Minecraft.
What I've done so far is made a program that creates a ripple pattern around a point. It looks like the ripples caused when you drop a pebble into water. The ripples get smaller and closer together the further away from the center point. It covers and area about 201 x 201 units.
I used the Pythagorean theorem to find the distance from the center a point is then used this to figure out how high above or below ground level to put the block
Z = INT(COS(a * rad * 70 * (a / 360)) * 8 * ((100 - a) / 100)) + player_z
a - the distance from the center point of the grid : a = INT((ABS(100 - x) ^ 2 + ABS(100 - y) ^ 2) ^ .5)
rad - pi/180 the constant to convert degrees to radians
70 - Controls the frequency of waves generated by cosine
(a/360) - adjusts the frequency of the waves the closer they get to 360 the faster they occur. The closer they get to the center the slower they occur. So the first ring around the center is the largest and the last is barely one unit wide.
8 - Is my amplifier, the values generated by cosine range from -1 to 1. This makes for rather blah waves so 8 boosts the range to -8 to -8
(100 - a) / 100 - This controls how high the waves get. a / 100 would make the waves larger the further away from the center point. By taking 'a' away from 100 I reverse that and make them taller the closer they are to the center.
player_z is the height the player was at the time the program started. It defines ground level.
Umm, yeah
Edit:
On a side note getting block data from minecraft is kind of slow. Finding what kind of block is in each location of a 11x11 grid was taking me ~6 seconds. I noticed in the server window each time I connected it mentioned a new thread was started for that connection.
I took a chance and modified a scanning program to make four connections and possibly four threads. The program would spread the data requests across all four connections. It basically checked to see if a connection had data or was waiting for data. If it was there it would process it. Next it send a new data request and mark the connection as waiting on data. It would then move to the next connection. The time for the same number of requests was four times faster at only ~1.5 seconds.
I think I could make it faster with more connections there would be a limit to how many I can do.
Edit2:
See image here:
http://www.furaffinity.net/view/10113609/
I am using an programming add-on for an alternative Minecraft server call Bukkit. Raspberry Juice is a PC add-on to emulate the programming interface and commands for the RaspberryPi version of Minecraft.
What I've done so far is made a program that creates a ripple pattern around a point. It looks like the ripples caused when you drop a pebble into water. The ripples get smaller and closer together the further away from the center point. It covers and area about 201 x 201 units.
I used the Pythagorean theorem to find the distance from the center a point is then used this to figure out how high above or below ground level to put the block
Z = INT(COS(a * rad * 70 * (a / 360)) * 8 * ((100 - a) / 100)) + player_z
a - the distance from the center point of the grid : a = INT((ABS(100 - x) ^ 2 + ABS(100 - y) ^ 2) ^ .5)
rad - pi/180 the constant to convert degrees to radians
70 - Controls the frequency of waves generated by cosine
(a/360) - adjusts the frequency of the waves the closer they get to 360 the faster they occur. The closer they get to the center the slower they occur. So the first ring around the center is the largest and the last is barely one unit wide.
8 - Is my amplifier, the values generated by cosine range from -1 to 1. This makes for rather blah waves so 8 boosts the range to -8 to -8
(100 - a) / 100 - This controls how high the waves get. a / 100 would make the waves larger the further away from the center point. By taking 'a' away from 100 I reverse that and make them taller the closer they are to the center.
player_z is the height the player was at the time the program started. It defines ground level.
Umm, yeah
Edit:
On a side note getting block data from minecraft is kind of slow. Finding what kind of block is in each location of a 11x11 grid was taking me ~6 seconds. I noticed in the server window each time I connected it mentioned a new thread was started for that connection.
I took a chance and modified a scanning program to make four connections and possibly four threads. The program would spread the data requests across all four connections. It basically checked to see if a connection had data or was waiting for data. If it was there it would process it. Next it send a new data request and mark the connection as waiting on data. It would then move to the next connection. The time for the same number of requests was four times faster at only ~1.5 seconds.
I think I could make it faster with more connections there would be a limit to how many I can do.
Edit2:
See image here:
http://www.furaffinity.net/view/10113609/
FA+

I did a quick test and found out that I can put blocks on the map as fast as I can plot them.
I've had a thought of streaming working with this some Monday night.