added train buttons
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
</section>
|
||||
<section w-full>
|
||||
<p><button nbButton outline status="danger" (click)="resetGame()">Neues Spiel!<br /></button><br /></p>
|
||||
<p><button nbButton outline status="danger" (click)="trainUp('X')" *ngIf="winner">Train like X!<br /></button><br /></p>
|
||||
<p><button nbButton outline status="danger" (click)="trainUp('O')" *ngIf="winner">Train like O!<br /></button><br /></p>
|
||||
<h1>current player: {{ player }}</h1>
|
||||
<h2 *ngIf="winner">Gewinner: {{ winner }}<br /></h2><br />
|
||||
</section>
|
||||
@@ -10,3 +12,4 @@
|
||||
<app-square class="square-container h-48" *ngFor="let val of fields; let i=index" [value]="val"
|
||||
(click)="playerPress(i)"></app-square>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -21,6 +21,29 @@ export class BoardComponent implements OnInit {
|
||||
this.resetGame();
|
||||
}
|
||||
|
||||
trainUp(playerLearn) {
|
||||
console.log('Train Called - to be more like ', playerLearn);
|
||||
|
||||
const AllMoves = this.history.map((board) => {
|
||||
return board.map((v) => {
|
||||
if (v === playerLearn) {
|
||||
return 1;
|
||||
} else if (v === null) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
});
|
||||
});
|
||||
console.log(AllMoves);
|
||||
// let ai: AiService;
|
||||
// let games = [];
|
||||
// games.push(AllMoves);
|
||||
// ai = new AiService();
|
||||
// ai.trainOnGames(games, (data)=>{console.log(data)});
|
||||
|
||||
}
|
||||
|
||||
resetGame() {
|
||||
this.winner = null;
|
||||
this.draw = false;
|
||||
|
||||
Reference in New Issue
Block a user