Libraryless. Click here for Pure Java version (5838L/33K).
1 | abstract sclass AIStrategy<A> implements Steppable { |
2 | // user must set |
3 | F1<A, Double> submit; // scoring function |
4 | |
5 | *() {} |
6 | *(F1<A, Double> *submit) {} |
7 | |
8 | selfType setJudge(IF1<A, Number> judge) { |
9 | submit = func(A a) -> double { judge.get(a).doubleValue() }; |
10 | this; |
11 | } |
12 | |
13 | long round; |
14 | new Best<A> best; |
15 | bool verbose; |
16 | event newBest(A guess, double score); |
17 | |
18 | void updateBest(A guess, double score) { |
19 | if (best.put(guess, score)) |
20 | newBest(guess, score); |
21 | } |
22 | |
23 | double submit(A guess) { |
24 | if (guess == null) ret best.worstScore(); |
25 | double score = callF(submit, guess); |
26 | updateBest(guess, score); |
27 | ret score; |
28 | } |
29 | |
30 | selfType lowerIsBetter(bool b) { |
31 | best.lowerIsBetter(b); |
32 | this; |
33 | } |
34 | } |
Began life as a copy of #1018798
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1022920 |
Snippet name: | AIStrategy |
Eternal ID of this version: | #1022920/15 |
Text MD5: | d644e46fab8a1b19788b68d8b279b796 |
Transpilation MD5: | 1e7cb03abb3ac31f2182239052f7e86c |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-03-13 05:31:20 |
Source code size: | 767 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 353 / 877 |
Version history: | 14 change(s) |
Referenced in: | [show references] |