Esempio n. 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
}
Esempio n. 2
0
// SetUpTestBoard stores the test data (string characters)
// in the Board as PointStatus information.
func SetUpTestBoard(N int, brd *ah.AbstHier, data *[]string) {
	for r := 0; r < N; r++ {
		for c := 0; c < N; c++ {
			brd.SetPoint(ah.MakeNodeLoc(ah.ColValue(c), ah.RowValue(r)), ah.PointStatus((*data)[r][c]))
		}
	}
}
Esempio n. 3
0
File: game.go Progetto: Ken1JF/sgf
func (gam *GameTree) DoAE(p ah.NodeLoc, doPlay bool) (err ah.ErrorList) {
	movType := ah.Unocc
	//	gam.aE = append(gam.aE, p)
	bp := &gam.Graphs[ah.PointLevel].Nodes[p]
	cur := bp.GetNodeLowState()
	if ah.PointStatus(cur) == ah.Black {
		movType = ah.AE_B
	} else {
		// TODO: check for white and add AE_E?
		movType = ah.AE_W
	}
	if doPlay {
		newSt := gam.Graphs[ah.PointLevel].CompHigh(&(gam.AbstHier), ah.PointLevel, p, uint16(ah.Unocc))
		gam.ChangeNodeState(ah.PointLevel, p, ah.NodeStatus(newSt), true)
	}
	_ = gam.AddMove(p, movType, 0, ah.NilNodeLoc)
	return err
}
Esempio n. 4
0
File: game.go Progetto: 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
}