bandits run on boot!

stable
Valerie 2021-12-22 09:20:12 -05:00
parent 8038129027
commit 52b5f5ef92
3 changed files with 35 additions and 7 deletions

20
.system
View File

@ -3,7 +3,8 @@
"instances": {
"B7FFCD6C11974FC7A74509B6683D7420": {
"config": {
"sshd": "invoke sshd start"
"sshd": "invoke sshd start",
"invoke": "invoke EXPLORE run 10"
},
"module": "systemd"
},
@ -45,6 +46,18 @@
"base": 7.786595862237511
},
"module": "n-arm-bandit/bandit"
},
"7E884FCACAC74FDF985D46B2BC937B5B": {
"config": {
"bandits": [
"SLOT1",
"SLOT2",
"SLOT3",
"SLOT4",
"SLOT5"
]
},
"module": "n-arm-bandit/agent/exploreOnly"
}
},
"aliases": {
@ -54,7 +67,8 @@
"SLOT2": "05EA8268E28F4C9FAC7F8E5BE0ABAB5F",
"SLOT3": "0F0B6AEB69754319A7E480E3989F7E54",
"SLOT4": "34064741B6324D9BBCEE0A1364F21220",
"SLOT5": "18461538E5A1487EBC9F54040295440A"
"SLOT5": "18461538E5A1487EBC9F54040295440A",
"EXPLORE": "7E884FCACAC74FDF985D46B2BC937B5B"
},
"devMode": true
"devMode": false
}

View File

@ -1,6 +1,20 @@
import { exec } from "@kernel:base";
export function run(tries: string) {
export default {
config: {
bandits: []
}
}
export async function run(tries: number) {
for(let i = 0; i < tries; i ++) {
const slot = this.config.bandits[Math.floor(Math.random() * this.config.bandits.length)];
const result = await exec(`invoke ${slot} pull`);
console.log(`Pulling ${slot}...`);
console.log(`Got ${result.toFixed(2)} reward`);
}
}
export function addBandit(name: string) {
this.config.bandits.push(name);
}

View File

@ -6,9 +6,9 @@ import { exec } from '@kernel:base';
// }
// }
export function boot() {
export async function boot() {
for(const [name, script] of Object.entries(this.config)) {
exec(script as string);
await exec(script as string);
}
}