Skip to content

Commit f03f9be

Browse files
committed
replaced int by int8
1 parent ff363c8 commit f03f9be

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

cmd/engine/random_engine.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ type RandomEngine struct{}
1212

1313
func (e *RandomEngine) Move(board game.Board, player game.FieldState, ko *game.Point) *game.Point {
1414
empty := []game.Point{}
15-
for i := 0; i < 9; i++ {
16-
for j := 0; j < 9; j++ {
15+
for i := int8(0); i < 9; i++ {
16+
for j := int8(0); j < 9; j++ {
1717
if board[i][j] == game.Empty {
1818
empty = append(empty, game.Point{Row: int8(i), Col: int8(j)})
1919
}

cmd/game/gui.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,19 @@ func (g *Gui) Refresh() {
5252
print("\033[?25h") // Show cursor
5353
}
5454

55-
func (g *Gui) DrawGridToWriter(w io.Writer, cursorRow, cursorCol int) {
55+
func (g *Gui) DrawGridToWriter(w io.Writer, cursorRow, cursorCol int8) {
5656
// Column labels
5757
fmt.Fprint(w, " ")
58-
for j := range g.Grid[0] {
58+
for j := int8(0); j < int8(len(g.Grid[0])); j++ {
5959
fmt.Fprintf(w, " %c ", 'A'+j)
6060
}
6161
fmt.Fprintln(w)
6262

63-
for i, row := range g.Grid {
64-
// Row label
63+
for i := int8(0); i < int8(len(g.Grid)); i++ {
64+
row := g.Grid[i]
6565
fmt.Fprintf(w, "%2d ", i+1)
66-
for j, cellVal := range row {
66+
for j := int8(0); j < int8(len(row)); j++ {
67+
cellVal := row[j]
6768
stone := cellVal.String()
6869
if g.Grid[i][j] != Empty {
6970
stone = g.Grid[i][j].String()

main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ type Config struct {
1818
}
1919

2020
var (
21-
cursorRow, cursorCol int
21+
cursorRow, cursorCol int8
2222
gui game.Gui
2323
keybindings map[string]string
2424
prevBoard *game.Board // Track previous board for Ko rule
25-
currentPlayer int = 1 // Track current player (1 or 2), start with Black
25+
currentPlayer int8 = 1 // Track current player (1 or 2), start with Black
2626
koPoint *game.Point // Track Ko point (nil if no Ko)
27-
passCount int // Track consecutive passes
27+
passCount int8 // Track consecutive passes
2828
gameOver bool // Track if the game is over
2929
engineEnabled bool // Play against engine if true
3030
selectedEngine engine.Engine // The engine instance
@@ -70,7 +70,7 @@ func layout(g *gocui.Gui) error {
7070
return nil
7171
}
7272

73-
func moveCursor(dRow, dCol int, jumpOverOccupied bool) func(*gocui.Gui, *gocui.View) error {
73+
func moveCursor(dRow, dCol int8, jumpOverOccupied bool) func(*gocui.Gui, *gocui.View) error {
7474
return func(g *gocui.Gui, v *gocui.View) error {
7575
nextRow, nextCol := cursorRow, cursorCol
7676
for {
@@ -191,7 +191,7 @@ func placeStone(g *gocui.Gui, v *gocui.View) error {
191191
// Ko rule and legality check: resulting board must not match prevBoard
192192
if prevBoard != nil {
193193
same := true
194-
for i := range nextBoard {
194+
for i := int8(0); i < int8(len(nextBoard)); i++ {
195195
if nextBoard[i] != (*prevBoard)[i] {
196196
same = false
197197
break

0 commit comments

Comments
 (0)