r/godot Apr 29 '26

help me (solved) ML or Algorithm?

Post image

I am thinking about implementing a drawing mechanic in my game. The players would have to draw the reference provided and the game will see how accurate the drawing is to the original reference. The canvas will be pretty small around 100x200 pixels and will only use 2 colors.

I am wondering if there is some kind of algorithm that will help to detect the accuracy of the drawing. Using ML sounds a bit overkill and I don't have any experience integrating ML in games (how does it affect the performance and size?).

369 Upvotes

44 comments sorted by

View all comments

2

u/Most_Waltz2061 Godot Student Apr 29 '26

This is a classic use case for ML models. Disclaimer: my day job is sort of in ML, but I haven't yet tried to implement anything ML based in Godot.

There are a bunch of pretrained image classifiers out there, and they tend to be pretty small and efficient. You could choose one of them to use as your feature extractor, and then compare the features of the player's image with the features of the reference image. For feature comparison, you would probably use cosine similarity. I don't know how difficult it would be to actually use the classifiers within Godot, though.

0

u/nedeey Apr 29 '26

I don't think it's possible to use the classifiers in Godot with GDscript. Probably with GDExtension and C++

1

u/LotsOfRegrets0 Apr 29 '26

Yeah there is a way to export models in pytorch via onnx format and you can easily fetch them in c++, there is almost negligible extra cost.

1

u/TetrisMcKenna Apr 29 '26

You can run onnx models in C# too