@@ -5,8 +5,8 @@ const BoardSize = 9
55
66// Point represents a coordinate on the board.
77type Point struct {
8- Row int
9- Col int
8+ Row int8
9+ Col int8
1010}
1111
1212// Board is a BoardSize x BoardSize Go board.
@@ -15,7 +15,7 @@ type Board [BoardSize][BoardSize]FieldState
1515// Neighbors returns the adjacent points of a given point.
1616func Neighbors (p Point ) []Point {
1717 var n []Point
18- dirs := []struct { dr , dc int }{{- 1 , 0 }, {1 , 0 }, {0 , - 1 }, {0 , 1 }}
18+ dirs := []struct { dr , dc int8 }{{- 1 , 0 }, {1 , 0 }, {0 , - 1 }, {0 , 1 }}
1919 for _ , d := range dirs {
2020 r , c := p .Row + d .dr , p .Col + d .dc
2121 if r >= 0 && r < BoardSize && c >= 0 && c < BoardSize {
@@ -101,10 +101,10 @@ func IsLegalMove(b Board, p Point, color FieldState, prev Board) bool {
101101}
102102
103103// CalculateScore returns the territory score for Black and White.
104- func CalculateScore (b Board ) (black , white int ) {
104+ func CalculateScore (b Board ) (black , white int8 ) {
105105 visited := make (map [Point ]struct {})
106- for i := 0 ; i < BoardSize ; i ++ {
107- for j := 0 ; j < BoardSize ; j ++ {
106+ for i := int8 ( 0 ) ; i < BoardSize ; i ++ {
107+ for j := int8 ( 0 ) ; j < BoardSize ; j ++ {
108108 pt := Point {i , j }
109109 if b [i ][j ] == Black {
110110 black ++
@@ -125,7 +125,7 @@ func CalculateScore(b Board) (black, white int) {
125125}
126126
127127// territoryOwner returns the size and owner (Black/White/Empty) of a territory.
128- func territoryOwner (b Board , start Point , visited map [Point ]struct {}) (size int , owner FieldState ) {
128+ func territoryOwner (b Board , start Point , visited map [Point ]struct {}) (size int8 , owner FieldState ) {
129129 queue := []Point {start }
130130 owner = Empty
131131 border := make (map [FieldState ]struct {})
0 commit comments