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

69
LINES

< > BotCompany Repo | #1014965 // A. I. Game 8.2 / Colored Quads [OK]

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

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

!7

static int quads = 2;

!include #1006931 // AI Game & API

p-autorestart {
  newImageText = "New Letter!";
  gameTitle = "A. I. Game 8.2";
  reproZoom = 1;
  makeInstruction();
  pGame();
  swing {
    final JSpinner spinner = jSpinner(quads, 1, 100);
    addToWindowPack_keepWidth(is, withMargin(jRightAligned(withLabel("Number of quads to use:", spinner))));
    onChange(spinner, r {
      quads = intFromSpinner(spinner);
      makeInstruction();
      restartAIs();
    });
    
    clickButton(last(aiButtons)); // Start the winner AI!
  }
}

svoid makeInstruction {
  setInstruction("Reproduce this image with " + n2(quads, "quad") + ":");
}

sclass Submission extends BackgroundPlus<PolygonWithColor> {
  *() {}
  *(BackgroundPlus<PolygonWithColor> b) { copyFields(b, this); check(); }
  
  void check {
    assertEqualsQuick(quads, l(things));
    for (PolygonWithColor p : things)
      assertEqualsQuick(4, l(p.points));
  }
}

!include #1014964 // Random letter puzzle maker 

///////////////
// RENDERERS //
///////////////

static RGBImage renderImage(Submission s) { ret new RGBImage(renderImage1(s)); }
static BufferedImage renderImage1(Submission s) { ret renderBackgroundPlusPolys(w, h, s); }
static BufferedImage renderWithHints(Submission s) { ret renderBackgroundPlusPolys_withHints(w, h, s); }

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

AI_Random_abstract > AI_Random {
  Submission guess() {
    ret Submission(randomBackgroundPlusPolys(w, h, quads, 4));
  }
}

AI_RandomWithVariation_abstract > AI_RandomWithVariation {
  AI_RandomWithVariation() { super(new AI_Random); }
  
  Submission vary(Submission s) {
    ret varyBackgroundPlusPolys(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 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1014965
Snippet name: A. I. Game 8.2 / Colored Quads [OK]
Eternal ID of this version: #1014965/17
Text MD5: 19fc790ad75b805111503c50abb04ad0
Transpilation MD5: 2fbda869526cb4b014821229afe02ec5
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-08 01:28:46
Source code size: 1845 bytes / 69 lines
Pitched / IR pitched: No / No
Views / Downloads: 461 / 1189
Version history: 16 change(s)
Referenced in: [show references]