Skip to content

Instantly share code, notes, and snippets.

@kulte
Last active December 11, 2015 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kulte/4566961 to your computer and use it in GitHub Desktop.
Save kulte/4566961 to your computer and use it in GitHub Desktop.
describe('minimax', function () {
var INFINITY = 1.7976931348623157E+10308;
var N_INFINITY = -1.7976931348623157E+10308;
var COMPUTER = 1;
var HUMAN = 2;
it('should return INFINITY when computer has won', function () {
var state = [1, 1, 1, -1, -1, -1, -1, 2, 2];
var board = new Board(state);
assert.equal(board.minimax(COMPUTER), INFINITY); /* assertion passes */
})
it('should return N_INFINITY when human has won', function () {
var state = [-1, 1, 1, -1, -1, -1, 2, 2, 2];
var board = new Board(state);
assert.equal(board.minimax(COMPUTER), N_INFINITY); /* assertion fails */
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment