本文整理匯總了Golang中github.com/skelterjohn/go/matrix.DenseMatrix.Set方法的典型用法代碼示例。如果您正苦於以下問題:Golang DenseMatrix.Set方法的具體用法?Golang DenseMatrix.Set怎麽用?Golang DenseMatrix.Set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/skelterjohn/go/matrix.DenseMatrix
的用法示例。
在下文中一共展示了DenseMatrix.Set方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GenerateMoveBoard
func GenerateMoveBoard(piece byte, x int, y int) *matrix.DenseMatrix {
var singleMove *matrix.DenseMatrix
var result *matrix.DenseMatrix
// Start with the single move board
switch piece {
case Pawn:
singleMove = singlePawnMove
case Rook:
singleMove = singleRookMove
case Knight:
singleMove = singleKnightMove
case Bishop:
singleMove = singleBishopMove
case Queen:
singleMove = singleQueenMove
case King:
singleMove = singleKingMove
case Puppy:
singleMove = singlePuppyMove
}
result = shiftMatrix(singleMove, x-8, y-8)
for i := 0; i < 15; i++ {
for j := 0; j < 15; j++ {
if HoleBoard.Get(j, i) > float64(0) {
result.Set(j, i, 500)
}
}
}
// fmt.Println(HoleBoard.String())
// Get the secondary moves
for n := 1; n < 20; n++ {
// fmt.Println("Current State: \n", result.String())
for i := 0; i < 15; i++ {
for j := 0; j < 15; j++ {
// Check if the current position needs to generate it's child moves
if result.Get(i, j) == float64(n) {
// Shift the single move matrix
// fmt.Println("Generating moves from position (", j, ", ", i, ") as ", n)
result = addMovesToBoard(result, shiftMatrix(singleMove, j-7, 15-(i+8)), n+1)
}
}
}
}
// Remove the -1
for i := 0; i < 15; i++ {
for j := 0; j < 15; j++ {
// Check if the current position needs to generate it's child moves
if result.Get(i, j) == float64(-1) {
result.Set(i, j, 0)
}
}
}
// fmt.Println(result.String())
result = result.GetMatrix(7, 0, 8, 8)
// for i := 0; i < 8; i++ {
// for j := 0; j < 8; j++ {
// if HoleBoard.Get(i, j) == 1 {
// result.Set(j, i, 500)
// }
// }
// }
return result
}