Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

80
LINES

< > BotCompany Repo | #1014939 - A. I. Game 8 / Colored Boxes [OK]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Uses 3874K of libraries. Click here for Pure Java version (12235L/89K).

!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<BoxWithColor> {
  *() {}
  *(BackgroundPlus<BoxWithColor> 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

Author comment

Began life as a copy of #1006945

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1014939
Snippet name: A. I. Game 8 / Colored Boxes [OK]
Eternal ID of this version: #1014939/45
Text MD5: 95e8f85658c6b2c62329acd28d3af998
Transpilation MD5: 14d04796541024febc762c4249a67d09
Author: stefan
Category: javax / gui / a.i.
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-15 02:24:08
Source code size: 1865 bytes / 80 lines
Pitched / IR pitched: No / No
Views / Downloads: 444 / 2174
Version history: 44 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1014939 & http://1014939.tinybrain.de