View gist:e9fee573f06fe09bcaf0afdf7e35bcf5
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
/** | |
* Pawn object | |
* @param Player player | |
* @param string role pawn || queen | |
* @constructor | |
*/ | |
function Pawn(player, role) { | |
this.player = player; | |
this.maxStep = 1; | |
this.role = role || 'pawn'; |
View JavascriptBinarySearchArrayPrototype
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
/** | |
* Binary search | |
* | |
* @example: | |
* var arr = [0, 2]; | |
* arr.binarySearch(0) -> true | |
* arr.binarySearch(2) -> true | |
* arr.binarySearch(-1)-> false | |
* arr.binarySearch(1) -> false | |
* arr.binarySearch(3) -> false |