當前位置: 首頁>>代碼示例>>Golang>>正文


Golang board.NewBoard函數代碼示例

本文整理匯總了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))
}
開發者ID:esanmiguelc,項目名稱:gottt,代碼行數:7,代碼來源:impossiblecomputer_test.go

示例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,
	}
}
開發者ID:esanmiguelc,項目名稱:gottt,代碼行數:16,代碼來源:gametick.go

示例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))
}
開發者ID:esanmiguelc,項目名稱:gottt,代碼行數:5,代碼來源:rules_test.go

示例4: TestNoDiagonalWinnerIfBoardEmpty

func TestNoDiagonalWinnerIfBoardEmpty(t *testing.T) {
	board := board.NewBoard(THREE_BY_THREE)
	assert.False(t, DiagonalWinner(board, FIRST_PLAYER))
}
開發者ID:esanmiguelc,項目名稱:gottt,代碼行數:4,代碼來源:rules_test.go

示例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))
}
開發者ID:esanmiguelc,項目名稱:gottt,代碼行數:5,代碼來源:rules_test.go

示例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))
}
開發者ID:esanmiguelc,項目名稱:gottt,代碼行數:5,代碼來源:rules_test.go

示例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))
}
開發者ID:esanmiguelc,項目名稱:gottt,代碼行數:6,代碼來源:impossiblecomputer_test.go

示例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))
}
開發者ID:esanmiguelc,項目名稱:gottt,代碼行數:5,代碼來源:impossiblecomputer_test.go

示例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))
}
開發者ID:esanmiguelc,項目名稱:gottt,代碼行數:5,代碼來源:rules_test.go

示例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))
}
開發者ID:esanmiguelc,項目名稱:gottt,代碼行數:6,代碼來源:rules_test.go

示例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))
}
開發者ID:esanmiguelc,項目名稱:gottt,代碼行數:5,代碼來源:rules_test.go

示例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))
}
開發者ID:esanmiguelc,項目名稱:gottt,代碼行數:5,代碼來源:rules_test.go

示例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))
}
開發者ID:esanmiguelc,項目名稱:gottt,代碼行數:5,代碼來源:rules_test.go

示例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))
}
開發者ID:esanmiguelc,項目名稱:gottt,代碼行數:5,代碼來源:rules_test.go

示例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))
}
開發者ID:esanmiguelc,項目名稱:gottt,代碼行數:4,代碼來源:rules_test.go


注:本文中的github.com/esanmiguelc/gottt/core/board.NewBoard函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。