Skip to content

Commit 82dbb58

Browse files
committed
bugfixes (improved move suggestion)
1 parent e6baf67 commit 82dbb58

13 files changed

+193
-25
lines changed

Chess/applicationcomponent.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ class ApplicationComponent {
4949

5050
public turnSides(): boolean {
5151
this.suggestedMove = null
52-
alert("Turn sides hasn't been implemented yet");
52+
var move = this.chessboard.suggestMove()
53+
this.chessboard.move(move)
5354
return false;
5455
}
5556

Chess/engine/chessboard.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Chess/engine/chessboard.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Chess/engine/chessboard.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ export class Chessboard {
163163
original_enPassantCol,
164164
captureRow,
165165
secondColFrom,
166-
secondColTo))
166+
secondColTo,
167+
this._moves))
167168
return targetPiece;
168169
}
169170
move(fromRow, fromCol, toRow, toCol: number, promotion: number): void {
@@ -206,6 +207,7 @@ export class Chessboard {
206207
this.blackLeftRookHasMoved = lastMove.blackLeftRookHasMoved
207208
this.blackRightRookHasMoved = lastMove.blackRightRookHasMoved
208209
this.enPassantCol = lastMove.enPassantCol
210+
this._moves=lastMove.legalMoves
209211
if (lastMove.secondColTo > 0) {
210212
this.fields[lastMove.fromRow][lastMove.secondColFrom] = this.fields[lastMove.toRow][lastMove.secondColTo]
211213
this.fields[lastMove.toRow][lastMove.secondColTo] = 0
@@ -215,8 +217,8 @@ export class Chessboard {
215217
}
216218
public revertLastMove(): void {
217219
var capturedPiece = this.revertLastMoveInternally()
218-
if (null != capturedPiece)
220+
if (0 != capturedPiece)
219221
this.capturedPieces.pop()
220-
this.recalculateLegalMovesAndCheck()
222+
//this.recalculateLegalMovesAndCheck()
221223
}
222224
}

Chess/engine/chessboardUI.js

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Chess/engine/chessboardUI.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Chess/engine/chessboardUI.ts

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {Injectable} from 'angular2/angular2';
44
import {Move} from './move';
55
import {Moves} from './moves';
66
import {Chessboard} from './chessboard';
7-
import {Evaluator} from './evaluator';
87
import {Suggestor} from './suggestor';
98

109
export module ChessEngineAPI {
@@ -51,7 +50,6 @@ export module ChessEngineAPI {
5150
this.isPieceSelected = false;
5251
if (this.chessboard.isLegalMove(this.selectedPieceRow, this.selectedPieceCol, row, col)) {
5352
this.chessboard.move(this.selectedPieceRow, this.selectedPieceCol, row, col, this.isWhitePlaying ? 5 : -5);
54-
Evaluator.showPerformanceStats()
5553
var answer = new Suggestor(this.chessboard).suggestMove()
5654
if (null != answer)
5755
this.move(answer)

Chess/engine/move.js

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)