Slide 1

Slide 1 text

http://www.egeniq.com [email protected] @egeniq Dutch PHP Conference, 7 June 2013 Ivo Jansch Cheater’s Math Or: how iOS app + PHP == $$$

Slide 2

Slide 2 text

About Me @ijansch Entreprenerd Mobile & Web Developer Author & Speaker Talk feedback: http://joind.in/8446 2

Slide 3

Slide 3 text

2 ways to make money ‣Successful games ‣Cheats for successful games 3

Slide 4

Slide 4 text

The arrival of Letterpress 4

Slide 5

Slide 5 text

Beating Letterpress ‣What do we need: • Analyze screen (dimensions, location of the board) • OCR • Color matching • Word matching • Word scoring • Game strategy 5

Slide 6

Slide 6 text

OCR ‣Complex algorithms ‣Look at existing libraries ‣Image comparison or..... ‣CHEAT! 6

Slide 7

Slide 7 text

Fast & Dumb Binary Tree Pixel Thingee 7 ABCDEFGIJOPQRSTZ HKLMNUVWXY BDEFPRTZ ACGIJOQS HMNXY KLUVW

Slide 8

Slide 8 text

Workable, but crude & ugly code 8

Slide 9

Slide 9 text

Same for dimensional stuff 9

Slide 10

Slide 10 text

Heuristic scoring ‣Simple rules ‣Strategy design pattern 10

Slide 11

Slide 11 text

GameCoach was born 11

Slide 12

Slide 12 text

The Problem ‣T=0: Letterpress came out ‣T=5: Idea for coaching app • No cheat apps available ‣T=10: GameCoach for Letterpress ready • 1 other cheat app available ‣T=17: Apple approved GameCoach • 23 other cheat apps available :-( • By now there are over 40 12

Slide 13

Slide 13 text

GameCoach for Letterpress retrospective ‣ Few downloads per day, even fewer buys • Letterpress themes weren’t supported • Buggy OCR • Average: $ 0.18 / day • Did we care? No, we had fun! ‣ To make $$$ with apps like this, we need to: • Reduce the amount of code we need to write • Support more & other games • Release quickly • So abstract and generalize the hell out of the time consuming parts! 13

Slide 14

Slide 14 text

GameCoach new style 14 Game management, analysis Signatures Generic parser, game strategy

Slide 15

Slide 15 text

Generalizing a data model 15 Game Variant Theme Theme Tags TileTell #dd0000=theirs #ff0000=theirs,locked #0000dd=mine #000000=char Theme Tell name=letterpress board=5x5 ipad iphone 10,10=theirs,mine,locked tolerance=3 240,50 400,50 Classic Disco

Slide 16

Slide 16 text

Recursive dimension parsing board width = screen width board height = screen width (square board) board x = 0 board y = screen height - board height 16

Slide 17

Slide 17 text

Poor Man’s OCR ‣Pixel method worked, but hard to do ‣What if we train a parser using existing screenshots? 17

Slide 18

Slide 18 text

Enter The Matrix 18

Slide 19

Slide 19 text

Enter The Matrix 19

Slide 20

Slide 20 text

How? Just some Imagick 20

Slide 21

Slide 21 text

Canonicalize the screenshots 21

Slide 22

Slide 22 text

Reduced Matrix 22

Slide 23

Slide 23 text

Reduced Matrix up close 23

Slide 24

Slide 24 text

Finally, combine matrixes into OCR tree Creating the tree is remarkably simple: findTellPixel: find the ‘most binary’ pixel; dividing the set of letters in 2 halves. 24

Slide 25

Slide 25 text

Result: generic signatures 25

Slide 26

Slide 26 text

Client side generic parser 26 + =

Slide 27

Slide 27 text

We need a CMS! ‣ZF? Symfony? ‣Nah, let’s go for good old ATK • http://www.atk-framework.com • 13 years old, but gets the job done 27

Slide 28

Slide 28 text

Stop! Demo Time! 28

Slide 29

Slide 29 text

CSS Sprite techniques 29 Issue: css sprites & image scaling != friends

Slide 30

Slide 30 text

CSS sprite techniques 30
(yes I know inline styles are evil)

Slide 31

Slide 31 text

HTML5 Canvas (Yay!) ‣It’s so easy, even you can use it. 31

Slide 32

Slide 32 text

HTML5 Canvas 32

Slide 33

Slide 33 text

Reading canvases 33

Slide 34

Slide 34 text

Writing canvases 34

Slide 35

Slide 35 text

GameCoach engine to the test: Ruzzle 35

Slide 36

Slide 36 text

Ruzzle Retrospective ‣GameCoach for Letterpress: 5 days ‣GameCoach for Ruzzle: 5 hours • Required support for more tile properties (e.g. inter-tile margin) • Different word search (using ‘Trie’ algorithm: http:// en.wikipedia.org/wiki/Trie) • Multiple dictionary support • Some rendering changes 36

Slide 37

Slide 37 text

Next step: WordOn! ‣WordOn was piece of cake • Playing /collecting screenshots was the time consuming part ‣GameCoach was first (and still only) cheat ‣Reached Nr. 6 top grossing in word games :-) 37

Slide 38

Slide 38 text

The future :-) 38

Slide 39

Slide 39 text

The future :-) 39

Slide 40

Slide 40 text

Summary ‣Development reduction by PHP backend: zillion percent ‣Managed to incorporate everything I ever learned: • Database design, Design patterns, Image manipulation, CSS sprites, CMS systems, Math, File uploads, JSON, APIs, Imagick, command line PHP, memory management, internationalization, caching 40

Slide 41

Slide 41 text

Thank you! Questions? http://www.egeniq.com [email protected] @egeniq http://www.egeniq.com [email protected] @ijansch