Skip to content

Commit

Permalink
Merge branch 'pr/1680' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionel Laské committed Dec 23, 2024
2 parents 6445b2c + c243aea commit d483143
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
### Added
- 3D Volume activity
- Launch activity directly from url of CLI
- Launch activity directly from url or CLI

### Changed
- Upgrade to Cordova 12
Expand Down Expand Up @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Listview Popup increasing page length and opening downwards for lower icons #1674
- Vertical bar are broken in Chart/Gears activities on Windows #1646
- In the activity of food chain, the picture of frog shows incomplete #1191
- Unusual Draw in Chess Activity #1678

## [1.8.0] - 2024-04-10
### Added
Expand Down
42 changes: 17 additions & 25 deletions activities/Chess.activity/js/chessGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,18 +391,10 @@ var ChessGame = {
var start_time = Date.now();
var possibleMove = this.state.findmove(this.level);
var delta = Date.now() - start_time;
// game over
if (possibleMove.length === 0) {
this.game_won = true;
return;
}
if (1 / possibleMove[2] == 1 / this.state.stalemate_scores[this.state.to_play]) {
this.game_draw = true;
return;
}
var move = this.state.move(possibleMove[0], possibleMove[1]);

if (!(move.flags & (1 << 0))) {
// this is where the king can't move or any valid move aren't available, usually happens on stalemate and checkmate
var depth = this.level;
depth++;
//find at higher depths until it runs out of time
Expand All @@ -414,28 +406,26 @@ var ChessGame = {
delta = Date.now() - start_time;
}
}
if (possibleMove.length === 0) {
this.game_won = true;
return;
}
if (possibleMove[2] == this.state.stalemate_scores[this.state.to_play]) {
this.game_draw = true;
return;
}
move = this.state.move(possibleMove[0], possibleMove[1]);
if (!(move.flags & (1 << 0))) {
if (possibleMove.length === 0 && flags & 2) {
this.game_won = true;
return;
}
move = this.state.move(possibleMove[0], possibleMove[1]);
}

if (move.flags & (1 << 1) && move.flags & (1 << 2)) {
this.game_lost = true;

} else if (move.flags & (1 << 1) && !(move.flags & (1 << 2))) {
if ( (move.flags & 1<<0 ) && (move.flags & 1<<1) && (move.flags & 1<<2) ) {
this.board.position(p4_state2fen(this.state, true));
this.updateMoves();
this.game_lost = true;
return;
} else if (move.flags & (1<<1) && !(move.flags & (1<<2))) {
this.game_check = true;
} else if ((!(move.flags & (1 << 1)) && move.flags & (1 << 2)) || move.flags & (1 << 6)) {
} else if (!(move.flags& 1<<1) && ( ((move.flags & 1<<0) && move.flags & 1<<2) || move.flags & (1<<6))) {
this.board.position(p4_state2fen(this.state, true));
this.updateMoves();
this.game_draw = true;
return;
} else {
this.game_check = false;
}
Expand All @@ -461,10 +451,12 @@ var ChessGame = {
// illegal move
if (move.flags === 0) return 'snapback';

if (move.flags === 7) {
if (move.flags === 7 || move.flags === 15 || move.flags === 23 || move.flags === 39) {
this.game_won = true;
} else if ((!(move.flags & (1 << 1)) && move.flags & (1 << 2)) || move.flags & (1 << 6)) {
return;
} else if ( (!(move.flags & 1<<1 )) && (((move.flags & 1<<0) && (move.flags & 1<<2) ) || move.flags & (1<<6))) {
this.game_draw = true;
return;
} else {
this.game_check = false;
}
Expand Down

0 comments on commit d483143

Please sign in to comment.