!7 static int boxes = 3; !include #1015048 // AI Game & API p-autorestart { newImageText = "New Letter!"; gameTitle = "A. I. Game 8"; reproZoom = 1; makeInstruction(); pGame(); swing { final JSpinner spinner = jSpinner(boxes, 1, 100); addToWindowPack_keepWidth(is, withMargin(jRightAligned(withLabel("Number of boxes to use:", spinner)))); onChange(spinner, r { boxes = intFromSpinner(spinner); makeInstruction(); restartAIs(); }); clickButton(last(aiButtons)); // Start the winner AI! } } svoid makeInstruction { setInstruction("Reproduce this image with " + n2(boxes, "box", "boxes") + ":"); } sclass Submission extends BackgroundPlus { *() {} *(BackgroundPlus b) { copyFields(b, this); check(); } void check { assertEqualsQuick(main.boxes, l(things)); } } ////////////////// // PUZZLE MAKER // ////////////////// sS lastLetter; static RGBImage makeImage() { lastLetter = randomUpperCaseLetterNotEqualTo(lastLetter); ret randomLetterImage(lastLetter, #1004568, 100); } /////////////// // RENDERERS // /////////////// static BufferedImage renderImage1(Submission s) { ret renderRenderable(w, h, s); } static BufferedImage renderWithHints(Submission s) { ret renderRenderable_withHints(w, h, s); } ////////////////////////////////////// // Test AIs. Just add your own here // ////////////////////////////////////// AI_Random_abstract > AI_Random { Submission guess() { ret Submission(randomBackgroundPlusBoxes(w, h, boxes)); } } AI_RandomWithVariation_abstract > AI_RandomWithVariation { AI_RandomWithVariation() { super(new AI_Random); } Submission vary(Submission s) { ret varyBackgroundPlusBoxes(s, w, h); } } !include #1014957 // AI_Racer