本文整理匯總了Golang中github.com/esanmiguelc/gottt/core/board.NewBoard函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewBoard函數的具體用法?Golang NewBoard怎麽用?Golang NewBoard使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewBoard函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestGoesForTheWin
func TestGoesForTheWin(t *testing.T) {
board := board.NewBoard(rules.THREE_BY_THREE)
impossiblePlayer := ImpossiblePlayer{Mark: rules.SECOND_PLAYER}
testhelper.AddMarkToPositions(board, rules.FIRST_PLAYER, 0, 5, 2)
testhelper.AddMarkToPositions(board, rules.SECOND_PLAYER, 1, 4)
assert.Equal(t, 7, impossiblePlayer.GetMove(board, rules.SECOND_PLAYER, rules.FIRST_PLAYER))
}
示例2: GameTick
func GameTick(playerOneType, playerTwoType string, boardSize int, movesPlayed []int) gamestate.GameState {
playerOne := createFirstPlayer(playerOneType)
playerTwo := createSecondPlayer(playerTwoType)
board := board.NewBoard(boardSize)
rebuildBoard(board, movesPlayed)
return gamestate.GameState{
MovesPlayed: takeTurn(board, playerOne, playerTwo, movesPlayed),
PlayerOneType: playerOneType,
PlayerTwoType: playerTwoType,
CurrentPlayer: gamestate.GetCurrentPlayer(board, playerOne, playerTwo),
BoardSize: boardSize,
BoardState: board.Slots,
Board: board,
}
}
示例3: TestItHasAWinnerIfSameMarkInRightToLeftDiagonal
func TestItHasAWinnerIfSameMarkInRightToLeftDiagonal(t *testing.T) {
board := board.NewBoard(THREE_BY_THREE)
testhelper.AddMarkToPositions(board, FIRST_PLAYER, 2, 4, 6)
assert.True(t, DiagonalWinner(board, FIRST_PLAYER))
}
示例4: TestNoDiagonalWinnerIfBoardEmpty
func TestNoDiagonalWinnerIfBoardEmpty(t *testing.T) {
board := board.NewBoard(THREE_BY_THREE)
assert.False(t, DiagonalWinner(board, FIRST_PLAYER))
}
示例5: TestItHasAWinnerIfSameMarkInThirdColumn
func TestItHasAWinnerIfSameMarkInThirdColumn(t *testing.T) {
board := board.NewBoard(THREE_BY_THREE)
testhelper.AddMarkToPositions(board, FIRST_PLAYER, 2, 5, 8)
assert.True(t, ColumnWinner(board, FIRST_PLAYER))
}
示例6: TestItDoesNotHaveWinnerWhenNoCombinationsFoundForColumn
func TestItDoesNotHaveWinnerWhenNoCombinationsFoundForColumn(t *testing.T) {
board := board.NewBoard(THREE_BY_THREE)
testhelper.AddMarkToPositions(board, FIRST_PLAYER, 3, 1, 8)
assert.False(t, ColumnWinner(board, FIRST_PLAYER))
}
示例7: TestGetsTheCenterMove
func TestGetsTheCenterMove(t *testing.T) {
board := board.NewBoard(rules.THREE_BY_THREE)
impossiblePlayer := ImpossiblePlayer{Mark: rules.SECOND_PLAYER}
testhelper.AddMarkToPositions(board, rules.FIRST_PLAYER, 0)
assert.Equal(t, 4, impossiblePlayer.GetMove(board, rules.SECOND_PLAYER, rules.FIRST_PLAYER))
}
示例8: TestScoreWhenOpponentWins
func TestScoreWhenOpponentWins(t *testing.T) {
board := board.NewBoard(rules.THREE_BY_THREE)
testhelper.AddMarkToPositions(board, rules.SECOND_PLAYER, 0, 1, 2)
assert.Equal(t, -10, Score(board, rules.FIRST_PLAYER, rules.SECOND_PLAYER))
}
示例9: TestReturnsMovesRemainingOnBoard
func TestReturnsMovesRemainingOnBoard(t *testing.T) {
board := board.NewBoard(THREE_BY_THREE)
board.PlaceMove(4, FIRST_PLAYER)
assert.Equal(t, []int{0, 1, 2, 3, 5, 6, 7, 8}, MovesAvailable(board))
}
示例10: TestGetsTieIfNoWinner
func TestGetsTieIfNoWinner(t *testing.T) {
board := board.NewBoard(THREE_BY_THREE)
testhelper.AddMarkToPositions(board, FIRST_PLAYER, 0, 1, 5, 6, 8)
testhelper.AddMarkToPositions(board, SECOND_PLAYER, 2, 3, 4, 7)
assert.Equal(t, "Tie", GetResult(board))
}
示例11: TestGetsWinnerMarkSecondPlayer
func TestGetsWinnerMarkSecondPlayer(t *testing.T) {
board := board.NewBoard(THREE_BY_THREE)
testhelper.AddMarkToPositions(board, SECOND_PLAYER, 0, 1, 2)
assert.Equal(t, SECOND_PLAYER, GetResult(board))
}
示例12: TestGetsWinnerMark
func TestGetsWinnerMark(t *testing.T) {
board := board.NewBoard(THREE_BY_THREE)
testhelper.AddMarkToPositions(board, FIRST_PLAYER, 0, 1, 2)
assert.Equal(t, FIRST_PLAYER, GetResult(board))
}
示例13: TestGameIsOverWhenSecondPlayerWins
func TestGameIsOverWhenSecondPlayerWins(t *testing.T) {
board := board.NewBoard(THREE_BY_THREE)
testhelper.AddMarkToPositions(board, SECOND_PLAYER, 0, 1, 2)
assert.True(t, IsGameOver(board))
}
示例14: TestGameIsOverWhenBoardIsFull
func TestGameIsOverWhenBoardIsFull(t *testing.T) {
board := board.NewBoard(THREE_BY_THREE)
testhelper.AddMarkToPositions(board, FIRST_PLAYER, 0, 1, 2, 3, 4, 5, 6, 7, 8)
assert.True(t, IsGameOver(board))
}
示例15: TestAllMovesAvailableWhenBoardIsEmpty
func TestAllMovesAvailableWhenBoardIsEmpty(t *testing.T) {
board := board.NewBoard(THREE_BY_THREE)
assert.Equal(t, []int{0, 1, 2, 3, 4, 5, 6, 7, 8}, MovesAvailable(board))
}