// 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 }
// 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])) } } }
// printInitBoard2 is equivalent to printInitBoard // but uses the iteration function ah.EachNode // and a literal func. func printInitBoard2(abhr *ah.AbstHier) { var row ah.RowValue = 0 nCol, nRow := abhr.GetSize() fmt.Println("Board", int(nCol), "by", int(nRow)) abhr.EachNode(ah.PointLevel, func(brd *ah.Graph, nl ah.NodeLoc) { _, r := brd.Nodes[nl].GetPointColRow() if r != row { fmt.Println() row = r } fmt.Print(ah.PtTypeNames[brd.Nodes[nl].GetPointType()]) }) fmt.Println() }
// Print the boards, after transformation func printBrds(msg string, brd *ah.AbstHier, newBrd *ah.AbstHier, tName string) { var c ah.ColValue var r ah.RowValue nCol, nRow := brd.GetSize() fmt.Println("Board size", int(nCol), "by", int(nRow), "after", tName) for r = 0; ah.RowSize(r) < nRow; r++ { for c = 0; ah.ColSize(c) < nCol; c++ { bp := brd.Graphs[ah.PointLevel].GetPoint(c, r) ch := bp.GetNodeLowState() fmt.Printf("%c", byte(ch)) } fmt.Print(" | ") for c = 0; ah.ColSize(c) < nCol; c++ { nbp := newBrd.Graphs[ah.PointLevel].GetPoint(c, r) ch := nbp.GetNodeLowState() fmt.Printf("%c", byte(ch)) } fmt.Println() } }
// differBrds checks the LowStates of the Nodes // only suitable for special set boards func differBrds(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] if bp1.GetNodeLowState() != bp2.GetNodeLowState() { ret = true break } } } } return ret }
// printInitBoard prints the PointType values // after a Board is initialized (via SetSize) func printInitBoard(abhr *ah.AbstHier, title string) { // Black_Occ_Pt: "◉", // White_Occ_Pt: "◎", var c ah.ColValue var r ah.RowValue nCol, nRow := abhr.GetSize() fmt.Println(title, "Board", int(nCol), "by", int(nRow)) for r = 0; ah.RowSize(r) < nRow; r++ { for c = 0; ah.ColSize(c) < nCol; c++ { bp := abhr.Graphs[ah.PointLevel].GetPoint(c, r) hs := bp.GetNodeHighState() if hs == uint16(ah.White) { fmt.Print("◎") } else if hs == uint16(ah.Black) { fmt.Print("◉") } else { fmt.Print(ah.PtTypeNames[bp.GetPointType()]) } } fmt.Println() } }