Machine Learning Blender

Greetings all,

this is probably one quite unique kind of project I am showing here. It is basically the result of me wanting to prove myself I understood basic machine learning.

It all started by seeing some interesting projects on the internet, so I was getting keen on understanding how the nature of machine learning works.
So I started googleing some examples to create some really basic neural networks from the scratch.
Those where basically processing matrices as input data and compared them with a given output. I used Excel spread sheets at the start for a better understanding and plotting graphs directly.

Then I thought to realize a small own project with blender (the one seen here), in order to demonstrate a result more impressively than just a β€œ1” or a β€œ0” (oh wow, so you tought your computer to learn and its telling you β€œyes” or β€œno”…).
But the one shown requires a different AI learning technique. I remembered a funny guy on youtube made his computer learn to play super mario https://www.youtube.com/watch?v=qv6UVOQ0F44
He used a self developing NN by evolution called β€œNEAT” which would fit that problem. So I read the paper of it
http://nn.cs.utexas.edu/downloads/papers/stanley.ec02.pdf and his source code to understand it.
Then I started to code a NEAT implementation for python in order to make it interact with Blender. But a google search revealed there is already a python implementation ready to use https://neat-python.readthedocs.io/en/latest/
So I skipped the demanding part of programming, debugging, testing,
as I was already aware to have understood it and was confident to use a ready library for this.
I never actually learned python, but I do know some programming and I realised python is actually very compfortable and intuitive to use.

So then came the fun part, building a physical system with rigid objects in Blender and assign it a task.
I modelled a simple pendulum, free to move in a 2-Dimensional area. It has two force fields that it is able to use, one on each side. I visualized the forces using a cylinder that extends along with the strength.

The task is to bring the weight as long as possible the high as possible, within a time limit of 200 frames (~4 seconds).

The forces are limited in their strength so it is not possible to swing up in one go. I wanted it to realize that it needs to swing back and forth in order to
reach the top, just to make the task a bit more challenging. Keep in mind that you never tell AI how to solve a problem, that is on their own.
I had to tweak some setting parameters until it was able to learn this. In many runs, the system learns impressively fast to swing using only one force. But bringing both force in interaction and using the counter-force at the top to brake the weight down, happens actually only in quite few solutions, even if that brings the fastest results.
Anyway, finally it made its way - so here you can see the result.

Regards,
Justin

com-gif-maker

2 Likes

Hi Centauri,
I am Adnan. I am current studying architecture. I am working on something similar, but I am stuck. It would be great if you could share your python code. I would like to use it as a reference.

email - [email protected]

Thank you.