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

73
LINES

< > BotCompany Repo | #1014979 // A. I. Game 8.3 / Colored Polys [OK]

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

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

!7

static int polys = 2, corners = 4;

!include #1015048 // AI Game & API

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

svoid makeInstruction {
  setInstruction("Reproduce this image with " + n2(polys, "poly") + ", each having " + corners + " corners:");
}

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

!include #1014964 // Random letter puzzle maker 

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

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, polys, corners));
  }
}

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 #1014965

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: #1014979
Snippet name: A. I. Game 8.3 / Colored Polys [OK]
Eternal ID of this version: #1014979/6
Text MD5: 2a7072dc1d669b939d61c38c7ff78e70
Transpilation MD5: 2c84471de3f0a5d61a435dccf243609b
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-09 03:12:30
Source code size: 2119 bytes / 73 lines
Pitched / IR pitched: No / No
Views / Downloads: 617 / 1453
Version history: 5 change(s)
Referenced in: #1014980 - A. I. Game 8.4 / Circles [OK]
#3000526 - Smart Bot's answer to: !fresh latestPrograms()