diff --git a/src/app/board/board.component.ts b/src/app/board/board.component.ts index 566f130..9041ce1 100644 --- a/src/app/board/board.component.ts +++ b/src/app/board/board.component.ts @@ -28,7 +28,10 @@ export class BoardComponent implements OnInit { async makeAiMove(){ const history = this.history.slice(); - const squares = history[history.length - 1]; + let squares = history[history.length - 1]; + if(squares === undefined) { + squares = this.fields.slice(); + } const normalizedMoves = squares.map((v) => { if (v === "X") { return this.xIsNext ? 1 : -1;