I'm creating this project in unity.Karl Sims, the creator of the project, published the paper describing the project. In order to create the 3d creature like in the video, I'm using 3d boxes and BoxColliders. The boxes are connected to each other with a
ConfigurableJoint that limits their rotation limit on some axes. The creatures are then trained to learn different behaviors.
In order to create a new creature a tree is defined. A node in the tree includes data about itself like size or rotation limits, and connections to its children. Each connection includes the rotational limit of its children.
Collision is enabled between the nodes.
This system results in many different looking creatures. Some of them can't actually exist. For example, a creature with two nodes that are long boxes connected side to side really closely, but their connection also says one of them needs to be rotated by 90 degrees.
This creature will cause colliders to be in one another, which results in a fight between the
Colliders pushing the boxes away, and the
ConfigurableJoints pulling the boxes to each other. This results in the boxes moving around in an unnatural way. These creatures need to be eliminated.
I'm looking for a way to have as many valid creatures as fast as possible. Currently, I'm still using the same random creature generation method. After that, I add a
Validator which that instantiates the creature's body and performs some checks.
The validation checks I tried are:
1. See if the creature is not moving
2. See if the colliders overlap with
Physics.OverlapBox (I think this didn't work because regular creatures are also colliding and so it eliminated valid creatures)
3. See if there is an unreasonable force acting on the joint, which would indicate an overlap. This seems like the most promising, and I'm still testing it. The thing is that the creature learned to cheat this, during validation they didn't overlap, and when I added their control system (The brain of the creature) they push themselves to overlap.
4. Check for extreme accelerations out of nowhere. Had some success but the creatures adapted to the limit I set.
Currently, I'm leaning towards making the creature will a very small mass, so they don't need to apply a lot of force to move. I think this can help make detecting unreasonable forces easier.
Hopefully, I explained the problem in a manner that enables you to think about solutions. This is less of a code problem, but more of a unity collider and joints problem. I chose to not add code because it's just too much.
Edit: Since I'm using an evolutionary algorithm, at each point in time, there is more than one creature. A regular evolution process is slow, but when a creature breaks the physics, it gains a big lead. Deleting creatures like that helped slow down the takeover of cheating creatures, but did not prevent it.