Skip to content

Analyse

axet edited this page Oct 20, 2011 · 11 revisions
Clone this wiki locally

Initial image.

https://github.com/axet/starjeweled/blob/master/src/main/java/com/github/axet/starjeweled/core/Capture.java

Trying to catch board background by filtering image for range of black and white colors of the borad. To do that instead of patter recognition we are clearing all colors from screen not in hardcoded range (you have to fix source code if for OS/game have different gamma settings)

function BufferedImage filterMask(Image img) at

https://github.com/axet/starjeweled/blob/master/src/main/java/com/github/axet/starjeweled/core/Lookup.java

Simplify and remove noise from screen.

function BufferedImage filterNoise(BufferedImage bi) at

https://github.com/axet/starjeweled/blob/master/src/main/java/com/github/axet/starjeweled/core/Lookup.java

Result board match (calculed by medium points load in each horisontal and vertical lines). I choised optimal values between 10 and 100.

function Rectangle getBounds(BufferedImage bi) at

https://github.com/axet/starjeweled/blob/master/src/main/java/com/github/axet/starjeweled/core/Lookup.java

Capture full table image, we need only capture and recognize part of the screen to save CPU time.

Next step is to create puzzle map (devide all by 8 and 8).

constructor public Recognition() at

https://github.com/axet/starjeweled/blob/master/src/main/java/com/github/axet/starjeweled/core/Recognition.java

Estimate average color in each puzzle.

function int[] getMatrix() at

https://github.com/axet/starjeweled/blob/master/src/main/java/com/github/axet/starjeweled/core/Recognition.java

And detect image type.

function String getType(int rgb) at

https://github.com/axet/starjeweled/blob/master/src/main/java/com/github/axet/starjeweled/core/Recognition.java

Next step is to make optimal move.

https://github.com/axet/starjeweled/blob/master/src/main/java/com/github/axet/starjeweled/core/SimpleAI.java

Something went wrong with that request. Please try again.