<data:blog.pageTitle/>

This Page

has moved to a new address:

http://lofalexandria.com

Sorry for the inconvenienceā€¦

Redirection provided by Blogger to WordPress Migration Service
Library of Alexandria: Programming, Artificial Intelligence, and Minecraft: Post 1 - The Dirt/Grass Cycle

June 18, 2013

Programming, Artificial Intelligence, and Minecraft: Post 1 - The Dirt/Grass Cycle



I have always had a strong interest in artificial intelligence, simulated life, simulated worlds, and video games. Unfortunately, I have never really had the patience to sit down and learn to program beyond the classic "Hello World" program in C++.

My plan is to outline my ideas regarding AI and simulated environments in as much detail as I can in hopes that it will inspire and encourage me to actually take the steps needed to begin making it a reality.  If nothing else then maybe someone with more skills than I have will read my ideas and reach out to me about working together to make it happen.

I have decided to start this whole thing within the game world of minecraft.  I think that this provides an existing framework that is simple enough to be able to start a project like this really small and yet is complex enough to allow for me to slowly build some really complex interactions if I can actually begin figuring this all out and get things going. Also, it is a platform that has a huge modding community and plenty of resources for me to examine and learn from as I figure this all out.

I have decided to follow this guide as it seems to be intended to teach both Java programing and Minecraft modding at the same time.

So, here is my idea, roughly laid out.

As with most things that are complex, the trick is going to be to start small. A simulated world does not need to accurately replicate every aspect of reality for it to be an effective simulated world for AI development.

So, where do we start? Within Minecraft there already exists a huge amount of biodiversity. There are a variety of plants, a number of prey species, and even a few predators. This is wonderful because it should save a lot of time in the future once the underlying framework of what I hope to achieve has been laid out.

For example, lets start at the bottom of the food chain, plants. There are a number of plant options but the one that makes the most sense to me for starting out is the the interaction between the dirt blocks, the grass blocks, and tall grass blocks. This provides a nice existing framework for a growth cycle.  There are already some basic rules regarding grass growth and reproduction that I need to explore in depth but here is what I hope to achieve in the longer term.

Grass needs water and sunlight to grow.  Step one is going to be to figure out what existing variables in the game can be used to potentially influence grass growth.  Options that come to mind is block proximity to a water block, frequency of exposure to rain, amount of time exposed to rain, and amount of time exposed to sunlight (with a possible modifier for sunlight strength if I can find an existing variable for this to work off of), and finally, some reproductive potential stat I may need to code in that accounts for the overall health of the block (might be able to use the hunger/heart meter for this).

Essentially each block will need to have a certain number of stats associated with it that update over time. These stats will then be used to calculate what happens to it each "cycle" which will be a yet to be determined amount of time.

Each cycle the blocks will have a chance to update based on their parameters at the end of each cycle. Here are some ideas for how dirt blocks, grass blocks, and tall grass blocks will change over time based on their overall statistics based on the variables described above.

The Dirt Block

The dirt block will remain a dirt block until it reaches a certain 'health' value upon which it will 'upgrade' to a grass block, its health will be determined by the following variables.

Proximity to water: this is something I recognize that I will likely have to tweak the numbers over and over to find some kind of balance but nevertheless here are some guesstimates. Proximity to water score will be based on number of blocks from water source, 1-5 blocks it will get a score of 5 for this variable, 6-10 blocks it will get a 4, 11-15 a 3 and so on.

Amount of rain exposure: this is probably going to be some kind of timer ratio. I have no idea what a good balance for this would be (of even if this is something I can use) but lets just say that if we divide number of seconds exposed to rain by 20 minutes we will get a ratio. Lets say that for this measure again it can have a maximum score of 5.  0 rain in the last 30 minutes give it a 0 score, 1-30 seconds gives it a 1, 31-60 gives it a 2, and so on up to 2.5 minutes in the past 30 minutes giving it a full score of 5.

Now we can generate a water score for the block, X/10.

Then we can generate a sunlight score, if possible. Again some time ratio similar to the rain score, again figure out some appropriate ratio, lets make this out of 10 as well.

Now we have essentially a 20 point input score for the "organism" which would be akin to a hunger/food score for an animal we can base the blocks health/food score on their score for the above X/20.

Now, we can work out how a dirt block changes to a grass block. 1 dirt block has the potential to be touching 8 blocks and has 16 more blocks in the next row out. If we calculate a reproductive health value for proximity to grass blocks it might look something like this. If it is touching 8 blocks it gets a score of 5, touching 6-7 blocks a score of 4, 4-5 blocks a score of 3, 2-3 blocks a score of 2, 1 block a score of 1, and 0 blocks a score of 0. Then we can do the same for the second row out. If 15-16 of these have a grass block then it gets a score of 5, 12-14 = 4, 9-11 = 3, 5-8 = 2, 1-3 = 1 and 0 = 0.

Now we can give the block a reproductive health value of 0 to 10 for proximity to grass blocks. We can do the same for proximity to tall grass blocks. Maybe 0-10, based on some values of the number of tall grass blocks within a certain range.

Now we can use our resources value of X/20 and our reproductive health value of X/20 to determine if a dirt block becomes a grass block.

Lets say that if the resources value of the block is at least 14/20 then it can 'upgrade' to a grass block. Then the reproductive health value of the block will determine the %chance that the block upgrades each cycle. For this simply divide the X/20 for the reproductive health value to get your % chance.

The Grass Block

Now that we have a system in place for the dirt block to become a grass block we can examine the grass block. I envision this as slightly more complicated because I hope to have this block be able to both 'upgrade ' to a tall grass block and 'downgrade' to a dirt block.  For downgrading we can use the same parameters described above to generate the resource value, if it falls below a certain threshold for a certain number of cycles then it will downgrade to a dirt block. For example, if it fell below a ratio of 8/10 for however long I decide in the end then it becomes a dirty block again.

For upgrading, we can again use the resources value but shift in the other direction. Now, if the block has a score of over 16/20 for a certain amount of time then it becomes a tall grass block.

The Tall Grass Block

Here is the meat and potatoes of it so to speak. This is what I imagine as being the primary food source of a number of prey species, particularly sheep and cows. Hopefully I can find a way to make it so that if the animal is standing on the block for a certain amount of time then it "consumes" the tall grass making the block a grass block again.  There could also be some interesting dynamics if I can find some way of having it be that if the block is consumed a certain number of times over a certain time frame that it reverts all the way back to the dirt block again. But alas, that is getting a bit ahead of myself. Finally, again this block would have the potential to 'downgrade' to a grass block due to environmental conditions rather than consumption.

So, here are the variables I am going to have to either create or convert from existing variables for each of the three above block types.

Dirt
Proximity to Water
Exposure to Rain
Exposure to Light (potential for this to be somewhat dependent on the strength of the light as well)
Number of grass blocks it is touching
Number of grass blocks 1 row out
Number of tall grass blocks within a certain range

Grass Block
Proximity to Water
Exposure to Rain
Exposure to Light (potential for this to be somewhat dependent on the strength of the light as well)
Number of consecutive cycles with score over upgrade threshold
Number of consecutive cycles with score below downgrade threshold

Tall Grass Block
Proximity to Water
Exposure to Rain
Exposure to Light (potential for this to be somewhat dependent on the strength of the light as well)
Number of consecutive cycles with score below downgrade threshold

Last thought for added complexity at some point, animals transfer seeds and whatnot in the real world, we could have the first 2 dirt blocks an animal that has recently fed steps on become 'seeded' and have its reproductive health value maxed out until it upgrades one time.

Leave thoughts and opinions down in the comments! Assuming I could get this to work, how would you change the plan so far? What are some of your ideas for a simulated world within minecraft?

Labels: , , ,

1 Comments:

At July 20, 2013 at 9:19 AM , Blogger Kiara Pepper said...

all the people love to playing the game in their free time and Minecraft is best option for those people they can easily download Minecraft...and minecreft is a JAVA based gaming program and if you wants to download the trial varsion of this game then you cn also download it freely......

 

Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home