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

1  
!7
2  
3  
static int boxes = 3;
4  
5  
!include #1006931 // AI Game & API
6  
7  
p-autorestart {
8  
  newImageText = "New Letter!";
9  
  gameTitle = "A. I. Game 8.7";
10  
  reproZoom = 1;
11  
  makeInstruction();
12  
  pGame();
13  
  swing {
14  
    final JSpinner spinner = jSpinner(boxes, 1, 100);
15  
    addToWindowPack_keepWidth(is, withMargin(jRightAligned(withLabel("Number of boxes to use:", spinner))));
16  
    onChange(spinner, r {
17  
      boxes = 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(boxes, "rounded box", "rounded boxes") + ":");
28  
}
29  
30  
sclass Submission extends BackgroundPlus<RoundedBoxWithColor> {
31  
  *() {}
32  
  *(BackgroundPlus<RoundedBoxWithColor> b) { copyFields(b, this); check(); }
33  
34  
  void check {
35  
    assertEqualsQuick(main.boxes, l(things));
36  
  }
37  
}
38  
39  
//////////////////
40  
// PUZZLE MAKER //
41  
//////////////////
42  
43  
sS lastLetter;
44  
45  
static RGBImage makeImage() {
46  
  lastLetter = randomUpperCaseLetterNotEqualTo(lastLetter);
47  
  ret randomLetterImage(lastLetter, #1004568, 100);
48  
}
49  
50  
///////////////
51  
// RENDERERS //
52  
///////////////
53  
54  
static RGBImage renderImage(Submission s) {
55  
  ret new RGBImage(renderImage1(s));
56  
}
57  
58  
static BufferedImage renderImage1(Submission s) {
59  
  ret renderBackgroundPlusRoundedBoxes(w, h, s);
60  
}
61  
62  
static BufferedImage renderWithHints(Submission s) {
63  
  ret renderBackgroundPlusRoundedBoxes_withHints(w, h, s);
64  
}
65  
66  
//////////////////////////////////////
67  
// Test AIs. Just add your own here //
68  
//////////////////////////////////////
69  
70  
AI_Random_abstract > AI_Random {
71  
  Submission guess() {
72  
    ret Submission(randomBackgroundPlusRoundedBoxes(w, h, boxes));
73  
  }
74  
}
75  
76  
AI_RandomWithVariation_abstract > AI_RandomWithVariation {
77  
  AI_RandomWithVariation() { super(new AI_Random); }
78  
  
79  
  Submission vary(Submission s) {
80  
    ret varyBackgroundPlusRoundedBoxes(s, w, h);
81  
  }
82  
}
83  
84  
!include #1014957 // AI_Racer
85  
86  
// hack randomPoint
87  
static Pt randomPoint(int w, int h) {
88  
  ret randomPointNearCenter(w, h);
89  
}

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: 391 / 1143
Referenced in: [show references]