Skip to content

Commit f738441

Browse files
author
zilvinas
committed
..
1 parent 07fc8af commit f738441

File tree

6 files changed

+35
-47
lines changed

6 files changed

+35
-47
lines changed

dist/assets/index-RNX4iP-h.js renamed to dist/assets/index-4ef7-Snv.js

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta charset="UTF-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>puzzle 15 ml</title>
8-
<script type="module" crossorigin src="/assets/index-RNX4iP-h.js"></script>
8+
<script type="module" crossorigin src="/assets/index-4ef7-Snv.js"></script>
99
<link rel="stylesheet" crossorigin href="/assets/index-BEpohK8n.css">
1010
</head>
1111

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta charset="UTF-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>puzzle 15 ml</title>
8-
<script type="module" crossorigin src="dist/assets/index-RNX4iP-h.js"></script>
8+
<script type="module" crossorigin src="dist/assets/index-4ef7-Snv.js"></script>
99
<link rel="stylesheet" crossorigin href="dist/assets/index-BEpohK8n.css">
1010
</head>
1111

src/game-15-reconstruction/qtable/EpisodeTrainer.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ export class EpisodeRunner {
2020
learningRate: number,
2121
trainerInfo: string,
2222
semaphoreId: number | null
23-
) {
23+
): Promise<void> {
24+
25+
2426
//-------------some hack------------
2527
if (!Trainer.semaphore.goodToGo(semaphoreId)) return;
2628
//----------------------------------
2729

28-
const random = new Random();
2930
const environment = new Environment(stateProducer);
3031
environment.reset();
3132
let state0 = environment.getInitState();
@@ -49,7 +50,7 @@ export class EpisodeRunner {
4950
possibleActions.splice(index, 1); // Remove reverse action
5051
}
5152

52-
if (random.nextDouble() < epsilon) { // Explore
53+
if (Math.random() < epsilon) { // Explore
5354
Utils.prnt("\nrndm move");
5455
action = GameUtils.getRandomAction(possibleActions);
5556
} else { // Exploit
@@ -84,8 +85,8 @@ export class EpisodeRunner {
8485
if (EpisodeRunner.experience.size > 10000) EpisodeRunner.experience.clear();
8586

8687
const statsInfo = `QTable size: ${qTable.size}, experience size: ${EpisodeRunner.experience.size}`;
87-
8888
Utils.prnt("\n");
89+
await Utils.sleep(0);
8990
Utils.prnt(trainerInfo);
9091
Utils.prnt(statsInfo);
9192
ConsoleUtils.prntStatsInfo(statsInfo);
@@ -118,11 +119,4 @@ export class EpisodeRunner {
118119
);
119120
});
120121
}
121-
}
122-
123-
// Random class to handle random number generation
124-
class Random {
125-
public nextDouble(): number {
126-
return Math.random();
127-
}
128-
}
122+
}

src/game-15-reconstruction/qtable/Trainer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class Trainer {
3737

3838
for (let i = 0; i < n; i++) {
3939
let trainerInfo = "Running training batch: " + (i + 1) + " of " + n;
40-
await Promise.all(lessons.map(e => stateProducerConsumer(e, trainerInfo)));
40+
for (const e of lessons) await stateProducerConsumer(e, trainerInfo);
4141
}
4242

4343
Utils.prnt("training done");

src/main.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Utils } from './game-15-reconstruction/utils/Utils';
21
import { GameUtils } from './game-15-reconstruction/environment/GameUtils';
32
import { EpisodeTester } from './game-15-reconstruction/qtable/EpisodeTester';
43
import { ConsoleUtils } from './game-15-reconstruction/utils/ConsoleUtils';
@@ -21,22 +20,17 @@ export class ToolBox {
2120
private static async startTraining() {
2221
QTableGenerator.stopTester();
2322
ConsoleUtils.clearScreen();
24-
Utils.prnt("starting training session ... ");
25-
await Utils.sleep(0);
26-
QTableGenerator.train()
27-
.then(() => ToolBox.startTesting().then());
23+
await QTableGenerator.train();
24+
await ToolBox.startTesting();
2825
}
2926

3027
private static async startTesting() {
3128
QTableGenerator.stopTrainer();
3229
ConsoleUtils.clearScreen();
33-
Utils.prnt("start testing ... ");
34-
await Utils.sleep(0);
35-
QTableGenerator.test().then();
30+
await QTableGenerator.test();
3631
}
3732

3833
private static async configOnOff() {
39-
4034
this.btnOff('lessonsBtn', 'training lessons', show => LessonsEditor.toggleLessonsDisplay(show));
4135
this.btnOnOff('configBtn', 'configuration', show => ConfigEditor.toggleConfigurationDisplay(show));
4236
}

0 commit comments

Comments
 (0)