-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c217180
commit 9378dbc
Showing
11 changed files
with
69 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { | ||
updateBoard, | ||
} from "./base.js" | ||
import { | ||
BLACK, | ||
WHITE, | ||
} from "../util.js" | ||
|
||
const NOT_FORBIDDEN = [-1, -1] | ||
|
||
export function getForbidden(board, updated, move) { | ||
if (!board || !board.length) { | ||
return NOT_FORBIDDEN | ||
} | ||
let {x, y, color, dead} = move | ||
if (dead.size() !== 1) { | ||
return NOT_FORBIDDEN | ||
} | ||
let oppositeColor = color ^ (WHITE | BLACK) | ||
let dx = dead.x(0) | ||
let dy = dead.y(0) | ||
let [kill] = updateBoard(updated, {x: dx, y: dy, color: oppositeColor}) | ||
if (kill.size() !== 1) { | ||
return NOT_FORBIDDEN | ||
} | ||
if (kill.x(0) !== x || kill.y(0) !== y) { | ||
return NOT_FORBIDDEN | ||
} | ||
return [dx, dy] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,5 @@ public record GameMove( | |
int x, | ||
int y, | ||
boolean counting, | ||
boolean end, | ||
int[] forbidden) { | ||
boolean end) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters