Uses 3874K of libraries. Click here for Pure Java version (8349L/59K/208K).
1 | !7 |
2 | |
3 | !include #1006931 // AI Game & API |
4 | |
5 | p { pGame(); } |
6 | |
7 | sclass Submission { |
8 | Pt a, b; |
9 | |
10 | *() {} |
11 | *(Pt *a, Pt *b) {} |
12 | } |
13 | |
14 | extend AI { |
15 | double submit(Pt a, Pt b) { ret submit(new Submission(a, b)); } |
16 | } |
17 | |
18 | ////////////////// |
19 | // PUZZLE MAKER // |
20 | ////////////////// |
21 | |
22 | static RGBImage makeImage() { |
23 | ret loadRGBImage(#1006930); |
24 | } |
25 | |
26 | //////////////// |
27 | // FORM MAKER // |
28 | //////////////// |
29 | |
30 | static JComponent makeTheForm(final GameForAI game) { |
31 | final JSpinner x1 = jSpinner(10); |
32 | final JSpinner y1 = jSpinner(20); |
33 | final JSpinner x2 = jSpinner(30); |
34 | final JSpinner y2 = jSpinner(40); |
35 | ret makeForm(+x1, +y1, +x2, +y2, callAndPass(r { |
36 | game.submit(new Submission(ptFromForm(x1, y1), ptFromForm(x2, y2))); |
37 | })); |
38 | } |
39 | |
40 | static Pt ptFromForm(JTextField x, JTextField y) { |
41 | ret new Pt(intFromTextField(x), intFromTextField(y)); |
42 | } |
43 | |
44 | static Pt ptFromForm(JSpinner x, JSpinner y) { |
45 | ret new Pt(intFromSpinner(x), intFromSpinner(y)); |
46 | } |
47 | |
48 | ////////////// |
49 | // RENDERER // |
50 | ////////////// |
51 | |
52 | static RGBImage renderImage(Submission s) { |
53 | BufferedImage bi = newBufferedImage(w, h, Color.white); |
54 | drawRoundEdgeLine(bi, s.a, s.b, Color.black, 10); |
55 | ret new RGBImage(bi); |
56 | } |
57 | |
58 | static RGBImage renderWithHints(Submission s) { ret renderImage(s); } |
59 | |
60 | ////////////////////////////////////// |
61 | // Test AIs. Just add your own here // |
62 | ////////////////////////////////////// |
63 | |
64 | AI > TestAI { |
65 | void go { |
66 | submit(randomPoint(image()), randomPoint(image())); |
67 | } |
68 | } |
Began life as a copy of #1006908
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: | #1006932 |
Snippet name: | pre 5 A. I. Game / Reproduce Image |
Eternal ID of this version: | #1006932/15 |
Text MD5: | 27d938e179b5aa1f8a0b16b510aa4cf0 |
Transpilation MD5: | 643be4f47e05c1344839df3dc22f02f1 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-02-20 00:12:49 |
Source code size: | 1495 bytes / 68 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 491 / 649 |
Version history: | 14 change(s) |
Referenced in: | [show references] |