How we improved our pattern recognition algorithm from 37% to 93%
Maybe you already played Ludum Darons's :crown: last game Blood Sweat And Seals

The game is an Age of War like where you have to draw different ~~sigils~~ seals to summon different types of creatures.
The idea is that you can mix the 5 different seals models to get combinations of summons.
For example, if you draw a seal that is halfway the seal summoning the tank and the one summoning the archer, you would summon... a tanky archer
However the pain point about our game was the weakness of our shape recognition algorithm.
Jam algorithm: Hu's moments
To compute the likelyhood between a drawing and a model, we first calculated the drawing's image Hu's moments, which conceptually capture the shape of the drawing.
We then applied and euclidian distance to each of the model seals, and applied a softmax function.
While this worked quite well with some specific model seals, some of them were very hard to obtain.
We estimated the accuracy of our first algorithm to roughly 37%.
Note that this is fairly better than pure randomness (20% accuracy).
Postjam algorithm: DNN
As postjam, we decided to improve the recognition system.
We knew image recognition was a task that a deep neural network could easily deal with. However, it was inconceivable to build and train such model during the jam.
First, we built a fancy web tool to constitute a dataset.
Using this tool, we created a dataset containing ~800 drawings.

We then designed a small deep neural network using pytorch.
This DNN takes the image moments as inputs, and outputs the score for each of the five model seals.
The full dimensions of the neural network is:
24 (moments) :arrowright: 64 *(hidden layer)* :arrowright: 5 (model seals)
(We also applied some regularization methods such as dropout)
After a quick training of 190 epoch, we could achieve an accuracy of 93%!
We then implemented the deep neural network directly in godot, imported the training weights and... tada! :v:
Happily, our neural network implemented in godot is really quick to process an input (approximately 50ms).
Feel free to test the brand new postjam version of our game :wink:
https://ldjam.com/events/ludum-dare/55/blood-sweat-and-seals