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).

1  
!7
2  
3  
static int quads = 2;
4  
5  
!include #1006931 // AI Game & API
6  
7  
p-autorestart {
8  
  newImageText = "New Letter!";
9  
  gameTitle = "A. I. Game 8.2";
10  
  reproZoom = 1;
11  
  makeInstruction();
12  
  pGame();
13  
  swing {
14  
    final JSpinner spinner = jSpinner(quads, 1, 100);
15  
    addToWindowPack_keepWidth(is, withMargin(jRightAligned(withLabel("Number of quads to use:", spinner))));
16  
    onChange(spinner, r {
17  
      quads = intFromSpinner(spinner);
18  
      makeInstruction();
19  
      restartAIs();
20  
    });
21  
    
22  
    clickButton(last(aiButtons)); // Start the winner AI!
23  
  }
24  
}
25  
26  
svoid makeInstruction {
27  
  setInstruction("Reproduce this image with " + n2(quads, "quad") + ":");
28  
}
29  
30  
sclass Submission extends BackgroundPlus<PolygonWithColor> {
31  
  *() {}
32  
  *(BackgroundPlus<PolygonWithColor> b) { copyFields(b, this); check(); }
33  
  
34  
  void check {
35  
    assertEqualsQuick(quads, l(things));
36  
    for (PolygonWithColor p : things)
37  
      assertEqualsQuick(4, l(p.points));
38  
  }
39  
}
40  
41  
!include #1014964 // Random letter puzzle maker 
42  
43  
///////////////
44  
// RENDERERS //
45  
///////////////
46  
47  
static RGBImage renderImage(Submission s) { ret new RGBImage(renderImage1(s)); }
48  
static BufferedImage renderImage1(Submission s) { ret renderBackgroundPlusPolys(w, h, s); }
49  
static BufferedImage renderWithHints(Submission s) { ret renderBackgroundPlusPolys_withHints(w, h, s); }
50  
51  
/////////////////////////////////
52  
// AIs. Just add your own here //
53  
/////////////////////////////////
54  
55  
AI_Random_abstract > AI_Random {
56  
  Submission guess() {
57  
    ret Submission(randomBackgroundPlusPolys(w, h, quads, 4));
58  
  }
59  
}
60  
61  
AI_RandomWithVariation_abstract > AI_RandomWithVariation {
62  
  AI_RandomWithVariation() { super(new AI_Random); }
63  
  
64  
  Submission vary(Submission s) {
65  
    ret varyBackgroundPlusPolys(s, w, h);
66  
  }
67  
}
68  
69  
!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: 480 / 1228
Version history: 16 change(s)
Referenced in: [show references]