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

80
LINES

< > BotCompany Repo | #1015013 // A. I. Game 8.8 / Lines with colors [OK]

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

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

!7

static int lines = 8;

!include #1015048 // AI Game & API

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

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

sclass Submission extends BackgroundPlus<LineWithColor> {
  *() {}
  *(BackgroundPlus<LineWithColor> b) { copyFields(b, this); check(); }

  void check {
    assertEqualsQuick(main.lines, 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(randomBackgroundPlusLines(w, h, lines));
  }
}

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

!include #1014957 // AI_Racer

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: #1015013
Snippet name: A. I. Game 8.8 / Lines with colors [OK]
Eternal ID of this version: #1015013/6
Text MD5: 09715322170160ec90ab35eecc9d5c64
Transpilation MD5: 787a51b3d996fc2151282dbec73bc7ae
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-07 17:37:48
Source code size: 1861 bytes / 80 lines
Pitched / IR pitched: No / No
Views / Downloads: 532 / 1907
Version history: 5 change(s)
Referenced in: #1015046 - Headless Racer AI to find lines in image - see #1015013 [OK]