{"author_link":"\/users\/wakobu","author_name":"Wakobu","author_uid":"wakobu","comments":[],"epoch":1714488070,"event":"LD55","format":"md","ldjam_node_id":394877,"likes":10,"metadata":{"p_key":"206742","p_author":"Wakobu","p_authorkey":"1011842","p_urlkey":"443277","p_title":"How we improved our pattern recognition algorithm from 37% to 93%","p_cat":"LDJam ","p_event":"LD55","p_time":"1714488070","p_likes":"10","p_comments":"0","p_status":"WAYBACK","us_key":"1011842","us_name":"Wakobu","us_username":"wakobu","event_start":"1712966400","event_key":"120","event_name":"Ludum Dare 55"},"node":{"_collation":{"body_sanitizer":"TextUtils::SanitizeHTML via existing importer","event":"LD55","removed_author":false},"_superparent":383062,"_trust":5,"author":11842,"body":"Maybe you already played **Ludum Darons's** :crown: last game **Blood Sweat And Seals**\n\n![anim.gif](\/\/\/raw\/24e\/2\/z\/63531.gif)\n\nThe game is an *Age of War* like where you have to draw different ~~sigils~~ seals to summon different types of creatures.  \nThe idea is that **you can mix** the 5 different seals models to get **combinations of summons**.  \nFor 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\n\nHowever the pain point about our game was the weakness of our shape recognition algorithm.\n\n## Jam algorithm: Hu's moments\n\nTo compute the likelyhood between a drawing and a model, we first calculated the drawing's [image Hu's moments](https:\/\/en.wikipedia.org\/wiki\/Image_moment), which conceptually **capture the shape** of the drawing.  \nWe then applied and euclidian distance to each of the model seals, and applied a softmax function.\n\nWhile this worked quite well with some specific model seals, some of them were very hard to obtain.\n\nWe estimated the accuracy of our first algorithm to roughly **37%**.  \n*Note that this is fairly better than pure randomness (20% accuracy).*\n\n## Postjam algorithm: DNN\n\nAs postjam, we decided to improve the recognition system.  \nWe 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.\n\nFirst, we built a fancy web tool to constitute a dataset.  \nUsing this tool, we created a dataset containing ~800 drawings.\n\n![fancy.png](\/\/\/raw\/24e\/2\/z\/64e50.png)\n\nWe then designed a small deep neural network using **pytorch**.\n\nThis DNN takes the **image moments** as inputs, and outputs the score for each of the five model seals.\n\nThe full dimensions of the neural network is:  \n24 *(moments)* :arrow_right: 64 *(hidden layer)* :arrow_right: 5 *(model seals)*\n\n*(We also applied some regularization methods such as dropout)*\n\nAfter a quick training of *190 epoch*, we could achieve an accuracy of **93%**!\n\nWe then implemented the deep neural network directly in godot, imported the training weights and... tada! :v:  \nHappily, our neural network implemented in godot is really quick to process an input (approximately **50ms**).\n\nFeel free to test the brand new postjam version of our game :wink:  \nhttps:\/\/ldjam.com\/events\/ludum-dare\/55\/blood-sweat-and-seals","comments":0,"created":"2024-04-30T14:32:30Z","files":[],"files-timestamp":0,"id":394877,"love":10,"love-timestamp":"2024-05-01T15:52:17Z","meta":[],"modified":"2024-05-01T15:52:17Z","name":"How we improved our pattern recognition algorithm from 37% to 93%","node-timestamp":"2024-04-30T15:22:13Z","parent":388389,"parents":[1,5,9,383062,388389],"path":"\/events\/ludum-dare\/55\/blood-sweat-and-seals\/how-did-we-improve-our-pattern-recognition","published":"2024-04-30T14:41:10Z","scope":"public","slug":"how-did-we-improve-our-pattern-recognition","subsubtype":"","subtype":"","type":"post","version":1237586},"node_metadata":{"n_key":"394877","n_urlkey":"443277","n_parent":"388389","n_path":"\/events\/ludum-dare\/55\/blood-sweat-and-seals\/how-did-we-improve-our-pattern-recognition","n_slug":"how-did-we-improve-our-pattern-r","n_type":"post","n_subtype":"","n_subsubtype":"","n_author":"11842","n_created":"1714487550","n_modified":"1714578737","n_version":"1237586","n_status":"WAYBACK"},"source_url":"https:\/\/ldjam.com\/events\/ludum-dare\/55\/blood-sweat-and-seals\/how-did-we-improve-our-pattern-recognition","text":"Maybe you already played **Ludum Darons's** :crown: last game **Blood Sweat And Seals**\n\n![anim.gif](\/\/\/raw\/24e\/2\/z\/63531.gif)\n\nThe game is an *Age of War* like where you have to draw different ~~sigils~~ seals to summon different types of creatures.  \nThe idea is that **you can mix** the 5 different seals models to get **combinations of summons**.  \nFor 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\n\nHowever the pain point about our game was the weakness of our shape recognition algorithm.\n\n## Jam algorithm: Hu's moments\n\nTo compute the likelyhood between a drawing and a model, we first calculated the drawing's [image Hu's moments](https:\/\/en.wikipedia.org\/wiki\/Image_moment), which conceptually **capture the shape** of the drawing.  \nWe then applied and euclidian distance to each of the model seals, and applied a softmax function.\n\nWhile this worked quite well with some specific model seals, some of them were very hard to obtain.\n\nWe estimated the accuracy of our first algorithm to roughly **37%**.  \n*Note that this is fairly better than pure randomness (20% accuracy).*\n\n## Postjam algorithm: DNN\n\nAs postjam, we decided to improve the recognition system.  \nWe 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.\n\nFirst, we built a fancy web tool to constitute a dataset.  \nUsing this tool, we created a dataset containing ~800 drawings.\n\n![fancy.png](\/\/\/raw\/24e\/2\/z\/64e50.png)\n\nWe then designed a small deep neural network using **pytorch**.\n\nThis DNN takes the **image moments** as inputs, and outputs the score for each of the five model seals.\n\nThe full dimensions of the neural network is:  \n24 *(moments)* :arrow_right: 64 *(hidden layer)* :arrow_right: 5 *(model seals)*\n\n*(We also applied some regularization methods such as dropout)*\n\nAfter a quick training of *190 epoch*, we could achieve an accuracy of **93%**!\n\nWe then implemented the deep neural network directly in godot, imported the training weights and... tada! :v:  \nHappily, our neural network implemented in godot is really quick to process an input (approximately **50ms**).\n\nFeel free to test the brand new postjam version of our game :wink:  \nhttps:\/\/ldjam.com\/events\/ludum-dare\/55\/blood-sweat-and-seals","title":"How we improved our pattern recognition algorithm from 37% to 93%","wayback_source":[]}