posted an update

More about the algorithm: It's a genetic algorithm with fitness score, this is a good explanation: https://en.wikipedia.org/wiki/Genetic_algorithm

What it means is each dog has muscles and each muscle has values for how it moves its legs. The muscle values are its genotype. Muscle values drive the joint torque based off of a sin wave. Every round we start with the previous best dogs and clone them and mutate the values, adding variations.

public void mutate(float power = 1f){ offset+= power * Random.Range(-0.1f, 0.1f); frequency+= power * Random.Range(-0.1f, 0.1f); amplitude+= power * Random.Range(-0.1f, 0.1f); center+= power * Random.Range(-0.01f, 0.01f); ...

Dogs run for a set amount of time and are evaluated by a fitness function. Here's what we used to make them run forward:

public float getScore(float wD, float wH, float wR){ scoreRecieved = wD*transform.position.z/10f + wH*(transform.position.y - startingHeight)/startingHeight + wR*Vector3.Dot(transform.up, Vector3.up); return scoreRecieved; }

where the arguments are for a weighted value (the most weight is given to the distance traveled and the others are a "bonus"). Best scores are the next dogs to start with, and repeat. The fitness function is the most important part of the simulation. Changing the weights or even changing what is evaluates will be what creates the emergent behaviour we are looking for. Genetic algorithms like this are definitely the least complex kind of machine learning, but a great thing to do in a limited time for a hackathon. And we got the results we were wanting for after only a few hundred generations and got better from there.

Log in or sign up for Devpost to join the conversation.