Uses 3874K of libraries. Click here for Pure Java version (8718L/62K/220K).
!7 !include #1006891 // Click AI Include static int spacing = 10; // space between the two images p { w = h = 150; imageZoom = 1; pGame(); } extend AI { Rect leftRect() { ret main.leftRect(image); } Rect rightRect() { ret main.rightRect(image); } L<Rect> clickLeft() { ret submit(leftRect()); } L<Rect> clickRight() { ret submit(rightRect()); } L<Rect> clickLeftIf(bool b) { ret b ? clickLeft() : clickRight(); } L<Rect> clickRightIf(bool b) { ret b ? clickRight() : clickLeft(); } RGBImage leftImage() { ret image.clip(leftRect()); } RGBImage rightImage() { ret image.clip(rightRect()); } } static int singleImageWidth(RGBImage img) { ret (img.w()-spacing)/2; } static Rect leftRect(RGBImage img) { int iw = singleImageWidth(img); ret new Rect(0, 0, iw, h); } static Rect rightRect(RGBImage img) { int iw = singleImageWidth(img); ret new Rect(iw+spacing, 0, iw, h); } ////////////////////////////////////// // Test AIs. Just add your own here // ////////////////////////////////////// AI > ClickOnBrighterImage { void go { clickLeftIf(rgbAverageBrightness(leftImage()) > rgbAverageBrightness(rightImage())); } } ////////////////// // PUZZLE MAKER // ////////////////// static Puzzle makePuzzle() { S instruction = "Click on the brighter image"; RGBImage img = rgbImage(0xeef3e6, w*2+spacing, h); double l = random(10)/10.0, r = random(10)/10.0; Rect lr = leftRect(img), rr = rightRect(img); rgbFill(img, lr, new RGB(l)); rgbFill(img, rr, new RGB(r)); L<Rect> solution = l > r ? ll(lr) : l == r ? ll(lr, rr) : ll(rr); ret new Puzzle(instruction, img, solution); }
Began life as a copy of #1006837
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1007159 |
Snippet name: | A. I. Game 3.1 - Dark/Bright [REFACTORED, WORKS] |
Eternal ID of this version: | #1007159/7 |
Text MD5: | f15733e55f0a887ba4315a27b9d04ea5 |
Transpilation MD5: | 8d9f7636718cd120527f4143c799de15 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-03-08 17:22:58 |
Source code size: | 1686 bytes / 59 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 505 / 626 |
Version history: | 6 change(s) |
Referenced in: | -