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

89
LINES

< > BotCompany Repo | #1015011 // A. I. Game 8.7 / Rounded Boxes Near Center [OK]

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

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

!7

static int boxes = 3;

!include #1006931 // AI Game & API

p-autorestart {
  newImageText = "New Letter!";
  gameTitle = "A. I. Game 8.7";
  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, "rounded box", "rounded boxes") + ":");
}

sclass Submission extends BackgroundPlus<RoundedBoxWithColor> {
  *() {}
  *(BackgroundPlus<RoundedBoxWithColor> 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 RGBImage renderImage(Submission s) {
  ret new RGBImage(renderImage1(s));
}

static BufferedImage renderImage1(Submission s) {
  ret renderBackgroundPlusRoundedBoxes(w, h, s);
}

static BufferedImage renderWithHints(Submission s) {
  ret renderBackgroundPlusRoundedBoxes_withHints(w, h, s);
}

//////////////////////////////////////
// Test AIs. Just add your own here //
//////////////////////////////////////

AI_Random_abstract > AI_Random {
  Submission guess() {
    ret Submission(randomBackgroundPlusRoundedBoxes(w, h, boxes));
  }
}

AI_RandomWithVariation_abstract > AI_RandomWithVariation {
  AI_RandomWithVariation() { super(new AI_Random); }
  
  Submission vary(Submission s) {
    ret varyBackgroundPlusRoundedBoxes(s, w, h);
  }
}

!include #1014957 // AI_Racer

// hack randomPoint
static Pt randomPoint(int w, int h) {
  ret randomPointNearCenter(w, h);
}

Author comment

Began life as a copy of #1015005

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: #1015011
Snippet name: A. I. Game 8.7 / Rounded Boxes Near Center [OK]
Eternal ID of this version: #1015011/1
Text MD5: 2548a350f0b92c278410da1c1d291748
Transpilation MD5: 702d348ae4e7f10c19454eb64d39d1ad
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-06 23:30:03
Source code size: 2132 bytes / 89 lines
Pitched / IR pitched: No / No
Views / Downloads: 556 / 1582
Referenced in: