Summary of the project

Crop farming in Minecraft can be quite a time consuming process: to get any significant benefit in the game, we have to first find suitable spots for the seeds to grow, and then physically go to each of those locations to plant them. The locations we find, as a human user, may not even be optimal planting positions, especially if the mechanics of minecraft farming aren't known. So to make the process quicker and easier we have made a tool that allows an AI to do the farming process for you and save more time for you to do whatever else you want to do in the game. The final aim of this project is to have an agent that, given a map, and some farmable objects defined by the user (wheat, pumpkin seeds etc), will plant the objects for the user in an optimal position.

For this MVP version of the project, we are essentially creating a genetic algorithm AI to find the best points of farmland on a map to plant wheat crops in. Results from farming in minecraft can vary greatly based on a number of criteria, which our agent will use to evaluate positions on the map, and eventually select the optimum locations for farming. The criteria include:

Our agent is tasked with applying these criteria to evaluate locations on the map and efficiently select the best locations for farming

Approach

We will be using a Genetic Algorithm to solve this problem, which essentially involves mapping the problem to a graph search problem and following a procedure of breeding successful states to allow our seeds to converge onto an optimal location.

Setup

To set the agent up with what it needs, we do the following:

Now our agent is given 10 seeds, and can follow one of 2 methods:

The Algorithm

Our algorithm essentially simulates placing the seeds on the map, and evaluates this potential placement using our scoring function. It will do this until convergence. The steps to our genetic algorithm are as follows:

Evaluation of the current agent

Below we evaluate our current agent compared to a random agent

Evaluation Method: Our aim in this section of the project was to beat a random agent with our genetic algorithm. So to test whether we were successful, we:

The scores are summarised in the chart below:

The blue bars in the chart above represent the random agent. As you can see, every trial of the baseline algorithm, underperformed compared to our genetic algorithm. Interestingly, if we calculate the average of the scores of the random agent, we get exactly 2 / 10, or 20%, which is very close to the estimated 18% earlier. If we did more trials, we would find that eventually the success rate of the random agent would tend to 18%.

Our genetic algorithm was very successful in this case, mostly planting 10 seeds in the optimal zone. The average overall came to roughly 9.2/10.

A further piece of information we gathered was how the global scores vary with the round. This gives us an overall picture of the convergence of the algorithm

We see that, as we map the scores per round onto the chart, in the general case it will steadily rise and then finally by round 9/ round 10, we get very little difference

It is also interesting to see how to seeds converge on the water block. Below is a charting of different stages of the algorithm and how it progresses

Round 1

Round 3

Round 6

Round 8

By round 8 of 10 the seeds have converged

Remaining Goals and Challenges

At the moment we have a very basic algorithm that will give us a better score than randomly placing seeds, but we have identified three main points of improvment

Related Resources on Genetic Algorithms

Below is a list of resources we found useful when researching Genetic Algorithms

Matlab Article

This resource demonstrates how a genetic algorithm is used to find minimum points on a graph

A nice breakdown is given of the seperate stages of the genetic algorithm and how you can actually code up a solution by yourself

Visit here to see the article

Video Demonstration

The below video shows a nice visual animation on how genetic algorithms repeatedly take the best performing samples from the "gene pool" to eventually converge on a population that each finds itself on some optimal point.

See the video on youtube here

Washington University

This gives a brief insight into how genetic algorithms came about and a general overview of implementation

See it here

Wiki page

Gives a few good examples of genetic algorithms

See it here