Wednesday, June 8, 2016

Winning machine assisted

This method is not suggested as it takes the fun out of guessing in the game.  However it was fun for me to write the R program to guide when you are in the verge of losing :-)

Here is the algorithm:

1. Save the snapshot of image into a PNG file
2. Read the file using R library as a matrix
3. Convert the image to grayscale
4. Flip the image Horizontally
5. Convert into a binary image with threshold 0.99999.
6. Apply thinning algorithm to the matrix
7. Apply R's cor function to get the correlation from the matrix
8. Print it
9. Use it :-)

Here is the program:

Note: I spent 3 hours and learnt some amount of R just for this stint.  So the program might not be efficient.

Here are the custom functions:

No comments:

Post a Comment