File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44 import { MAKE_MOVE } from ' ../../../core/action-types' ;
55 import Hotkey from ' ../main/Hotkey.svelte' ;
6+ import Options from ' ./Options.svelte' ;
67 import { MCTSBot } from ' ../../../ai/mcts-bot' ;
78 import { RandomBot } from ' ../../../ai/random-bot' ;
89 import MCTS from ' ../mcts/MCTS.svelte' ;
2526 }
2627
2728 let selectedBot;
29+ let botAction;
30+ let botActionArgs;
2831 function ChangeBot () {
2932 const botConstructor = bots[selectedBot];
3033 bot = new botConstructor ({
3134 game: client .game ,
3235 enumerate: client .ai .enumerate ,
3336 });
37+ botAction = null ;
3438 }
3539
36- let botAction;
37- let botActionArgs;
3840 async function Step () {
3941 const t = await _Step (client, bot);
4042 botAction = t .payload .type ;
119121 </select >
120122 </section >
121123
124+ {#if Object .keys (bot .opts ()).length }
125+ <section >
126+ <h3 >Options</h3 >
127+ <Options bot ={bot }/>
128+ </section >
129+ {/if }
130+
122131 {#if botAction }
123132 <section >
124133 <h3 >Action</h3 >
Original file line number Diff line number Diff line change 1+ <script >
2+ export let bot;
3+
4+ let values = {};
5+ for ([key, value] of Object .entries (bot .opts ())) {
6+ values[key] = value .value ;
7+ }
8+
9+ function OnChange () {
10+ for ([key, value] of Object .entries (values)) {
11+ bot .setOpt (key, value);
12+ }
13+ }
14+ </script >
15+
16+ <style >
17+ label {
18+ font-weight : bold ;
19+ color : #999 ;
20+ }
21+
22+ .option {
23+ margin-bottom : 20px ;
24+ }
25+
26+ .value {
27+ font-weight : bold ;
28+ }
29+ </style >
30+
31+ {#each Object .entries (bot .opts ()) as [key, value]}
32+ <div class =" option" >
33+ <label >{key }</label >
34+ <span class ="value" >{values [key ]}</span >
35+ {#if value .range }
36+ <input type =range bind:value ={values [key ]} min ={value .range .min } max ={value .range .max } on:change ={OnChange }>
37+ {/if }
38+ </div >
39+ {/each }
You can’t perform that action at this time.
0 commit comments