Warning: session_start(): open(/var/lib/php/sessions/sess_o8l6f3cbqv62lpkbgoahde5077, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
static int boxes = 3;
!include #1006931 // AI Game & API
!include #1014957 // AI_Racer
p-autorestart {
newImageText = "New Letter!";
reproZoom = 1;
makeInstruction();
pGame();
swing {
setFrameTitle(is, "A. I. Game 5");
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 BackgroundPlusBoxes {
*() {}
*(RGB background, BoxWithColor... boxes) { super(background, boxes); check(); }
*(RGB background, L boxes) { super(background, boxes); check(); }
void check {
assertEquals(main.boxes, l(boxes));
}
}
//////////////////
// PUZZLE MAKER //
//////////////////
sS lastLetter;
static RGBImage makeImage() {
lastLetter = randomUpperCaseLetterNotEqualTo(lastLetter);
ret randomLetterImage(lastLetter, #1004568, 100);
}
///////////////
// RENDERERS //
///////////////
static RGBImage renderImage(Submission s) {
ret new RGBImage(renderImage1(s));
}
static BufferedImage renderImage1(Submission s) {
ret renderBackgroundPlusBoxes(w, h, s);
}
static BufferedImage renderWithHints(Submission s) {
ret renderBackgroundPlusBoxes_withHints(w, h, s);
}
//////////////////////////////////////
// Test AIs. Just add your own here //
//////////////////////////////////////
AI > AI_Random {
new Best best;
void go {
//print("Round: " + round());
if (round() == 1 && best.has()) // TODO: automate this
submit(best.get());
else {
Submission guess = guess();
updateBest(guess, submit(guess));
}
}
void updateBest(Submission guess, double score) {
best.put(guess, score);
}
Submission guess() {
ret new Submission(randomColor(),
produceN(func { randomBoxWithColor(w, h) }, boxes));
}
}
AI_Random > AI_RandomWithVariation {
int n;
Submission guess() {
if (odd(n++) && best.has())
ret vary(best.get());
else
ret super.guess();
}
Submission vary(Submission s) {
ret varyBackgroundPlusBoxes(s, w, h);
}
}