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
var evaluateBoard = function(board, color) { | |
// Sets the value for each piece using standard piece value | |
var pieceValue = { | |
'p': 100, | |
'n': 350, | |
'b': 350, | |
'r': 525, | |
'q': 1000, | |
'k': 10000 | |
}; |
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
var calcBestMoveOne = function(playerColor) { | |
// List all possible moves | |
var possibleMoves = game.moves(); | |
// Sort moves randomly, so the same move isn't always picked on ties | |
possibleMoves.sort(function(a, b){return 0.5 - Math.random()}); | |
// exit if the game is over | |
if (game.game_over() === true || possibleMoves.length === 0) return; | |
// Search for move with highest value |
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
var calcBestMoveNoAB = function(depth, game, playerColor, | |
isMaximizingPlayer=true) { | |
// Base case: evaluate board | |
if (depth === 0) { | |
value = evaluateBoard(game.board(), playerColor); | |
return [value, null] | |
} | |
// Recursive case: search possible moves | |
var bestMove = null; // best move not set yet |
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
var calcBestMove = function(depth, game, playerColor, | |
alpha=Number.NEGATIVE_INFINITY, | |
beta=Number.POSITIVE_INFINITY, | |
isMaximizingPlayer=true) { | |
// Base case: evaluate board | |
if (depth === 0) { | |
value = evaluateBoard(game.board(), playerColor); | |
return [value, null] | |
} |
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
import os | |
# Get environment, or set to development by default | |
app_env = os.environ.get('APPLICATION_ENVIRONMENT') or 'development' | |
# Settings applied to all environments | |
SECRET_KEY = 'development key' | |
# Settings applied to specific environments | |
if app_env == 'production': |
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
#include <stdio.h> | |
#include <ctype.h> | |
#include <string.h> | |
#define MAX_TOKEN_LENGTH 100 | |
enum TokenType | |
{ | |
TOKEN_INTEGER, | |
TOKEN_VARIABLE, |