Example #1
0
// checkHandicapBrds checks the LowStates of the Nodes
// only suitable for special set boards
func checkHandicapBrds(brd1, brd2 *ah.AbstHier) (ret bool) {
	var c ah.ColValue
	var r ah.RowValue
	nCol, nRow := brd1.GetSize()
	nCol2, nRow2 := brd2.GetSize()
	if (nCol != nCol2) || (nRow != nRow2) {
		ret = true
	} else {
		for r = 0; ah.RowSize(r) < nRow; r++ {
			for c = 0; ah.ColSize(c) < nCol; c++ {
				nl := ah.MakeNodeLoc(c, r)
				bp1 := &brd1.Graphs[ah.PointLevel].Nodes[nl]
				bp2 := &brd2.Graphs[ah.PointLevel].Nodes[nl]
				low1 := bp1.GetNodeLowState()
				low2 := bp2.GetNodeLowState()
				// check that both are occupied or unoccupied
				if ah.IsOccupied(ah.PointStatus(low1)) != ah.IsOccupied(ah.PointStatus(low2)) {
					ret = true
					break
				}
			}
		}
	}
	return ret
}
Example #2
0
File: game.go Project: Ken1JF/sgf
func (gam *GameTree) DoAW(p ah.NodeLoc, doPlay bool) (err ah.ErrorList) {
	movType := ah.Unocc
	gam.aW = append(gam.aW, p)
	bp := &gam.Graphs[ah.PointLevel].Nodes[p]
	cur := bp.GetNodeLowState()
	if ah.IsOccupied(ah.PointStatus(cur)) {
		// TODO: check for black and add AW_W?
		movType = ah.AW_B
	} else {
		movType = ah.AW_U
	}
	if doPlay {
		gam.ChangeNodeState(ah.PointLevel, p, ah.NodeStatus(ah.White), true)
	}
	_ = gam.AddMove(p, movType, 0, ah.NilNodeLoc)
	if doPlay {
		gam.EachAdjNode(ah.PointLevel, p,
			func(adjNl ah.NodeLoc) {
				newSt := gam.Graphs[ah.PointLevel].CompHigh(&(gam.AbstHier), ah.PointLevel, adjNl, uint16(ah.Unocc))
				gam.ChangeNodeState(ah.PointLevel, adjNl, ah.NodeStatus(newSt), true)
			})
	}
	return err
}