本文整理汇总了Golang中container/vector.IntVector.AppendVector方法的典型用法代码示例。如果您正苦于以下问题:Golang IntVector.AppendVector方法的具体用法?Golang IntVector.AppendVector怎么用?Golang IntVector.AppendVector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类container/vector.IntVector
的用法示例。
在下文中一共展示了IntVector.AppendVector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: continuedFraction
func continuedFraction(a float64, dSquaredFloorTimesTwo int) vector.IntVector {
aFloor := int(math.Floor(a))
var ret vector.IntVector
if dSquaredFloorTimesTwo == aFloor {
return ret
}
ret.Push(aFloor)
nextRet := continuedFraction(1/(a-float64(aFloor)), dSquaredFloorTimesTwo)
ret.AppendVector(&nextRet)
return ret
}
示例2: Play
// apply color to vertex, modifying board and updating liberties of any go_adj strings
func (t *GoTracker) Play(color byte, vertex int) {
if vertex != -1 {
t.passes = 0
if t.koVertex != -1 {
t.weights.Set(t.koColor, t.koVertex, INIT_WEIGHT)
t.koVertex = -1
t.koColor = EMPTY
}
if t.superko {
if t.history.Len() == 0 {
t.history.Push(*NewHash(t.boardsize))
}
cp := t.Copy()
cp.(*GoTracker).superko = false
cp.Play(color, vertex)
t.history.Push(*MakeHash(cp))
}
// modify the board
t.board[vertex] = color
// update parents and liberties of adjacent stones
opp := Reverse(color)
root := vertex
for i := 0; i < 4; i++ {
adj := t.adj[vertex][i]
if adj != -1 && t.board[adj] == color {
adj := find(adj, t.parent)
// take adjacent chain out of atari (may be added back later)
t.atari[color][adj] = 0, false
// or in liberties to friendly chains
new_root, old_root := union(root, adj, t.parent, t.rank)
t.liberties[new_root][0] |= t.liberties[old_root][0]
t.liberties[new_root][1] |= t.liberties[old_root][1]
// xor out liberty from self
t.liberties[new_root][0] &= ^t.mask[adj][0]
t.liberties[new_root][1] &= ^t.mask[adj][1]
root = new_root
} else if adj != -1 && t.board[adj] == EMPTY {
// xor out liberty from empty vertices
t.liberties[adj][0] &= ^t.mask[vertex][0]
t.liberties[adj][1] &= ^t.mask[vertex][1]
} else if adj != -1 {
// xor out liberties from enemy chains
enemy := find(adj, t.parent)
t.liberties[enemy][0] &= ^t.mask[vertex][0]
t.liberties[enemy][1] &= ^t.mask[vertex][1]
}
}
// xor out liberty from self
t.liberties[root][0] &= ^t.mask[vertex][0]
t.liberties[root][1] &= ^t.mask[vertex][1]
// capture any adjacent enemies reduced to zero liberties
var captured *vector.IntVector
for i := 0; i < 4; i++ {
adj := t.adj[vertex][i]
if adj != -1 && t.board[adj] == opp {
enemy := find(adj, t.parent)
libs := t.libs(enemy)
if libs == 0 {
// take chain out of atari
t.atari[opp][enemy] = 0, false
if captured == nil {
captured = t.capture(enemy)
} else {
captured.AppendVector(t.capture(enemy))
}
}
}
}
// check for suicide of affected empty points
for i := 0; i < 4; i++ {
adj := t.adj[vertex][i]
if adj != -1 && t.board[adj] == EMPTY && t.libs(adj) == 0 {
t.check_suicide(adj)
} else if adj != -1 && (t.board[adj] == BLACK || t.board[adj] == WHITE) {
adj = find(adj, t.parent)
if t.libs(adj) == 1 {
last_liberty := t.lastliberty(adj)
if t.libs(last_liberty) == 0 {
t.check_suicide(last_liberty)
}
}
}
}
// ko check
if captured != nil && captured.Len() == 1 {
capture := captured.At(0)
t.check_suicide(capture)
if t.libs(root) == 1 {
t.koColor = opp
t.koVertex = capture
}
//.........这里部分代码省略.........