I think there are some algorithms that evaluate difference between drawn symbol and expected one, or something like that. Any help will be appreciated :))
Have you checked Detexify. I think it does pretty much what you want http://detexify.kirelabs.org/classify.html
It is open source, so you could take a look at how it is implemented. You can get the code from here (if I do not recall wrongly, it is in Haskell) https://github.com/kirel/detexify-hs-backend
In particular what you are looking for should be in Sim.hs
I hope it helps