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

81
LINES

< > BotCompany Repo | #1019339 // A. I. Game 8 / Colored Boxes [showing actual boxes, OK]

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

Download Jar. Uses 3874K of libraries. Click here for Pure Java version (13621L/102K).

!7

static int boxes = 3;

!include #1015048 // AI Game & API

p-autorestart {
  mixReproWithImage = false;
  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 #1014939

download  show line numbers  debug dex  old transpilations   

Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

-
Snippet ID: #1019339
Snippet name: A. I. Game 8 / Colored Boxes [showing actual boxes, OK]
Eternal ID of this version: #1019339/4
Text MD5: 13e79e0e2df5351d4048f511d76819f5
Transpilation MD5: d0a663bf7b0439491c8abf5d6fb2516d
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-11-02 15:42:59
Source code size: 1899 bytes / 81 lines
Pitched / IR pitched: No / No
Views / Downloads: 457 / 1126
Version history: 3 change(s)
Referenced in: