Describe the bug
When I update the size of the board from 10x10 to 7x6, the game crashes after a move.
To Reproduce
Steps to reproduce the behavior:
Go to ./cmd/four-in-a-row/main.go
Change game board to g := game.NewGame(7, 6).
Run game
See error
Error Message
panic: runtime error: index out of range
goroutine 1 [running]:
github.com/gokultp/go-four-in-a-row/pkg/game.(*Game).isWon(0xc0000f4000, 0x4, 0x5, 0x1, 0x10c7cac)
/Users/berto/go/src/github.com/gokultp/go-four-in-a-row/pkg/game/game.go:132 +0xa0a
github.com/gokultp/go-four-in-a-row/pkg/game.(*Game).addEntry(0xc0000f4000, 0x4, 0x1)
/Users/berto/go/src/github.com/gokultp/go-four-in-a-row/pkg/game/game.go:123 +0x15b
github.com/gokultp/go-four-in-a-row/pkg/game.(*Game).Input(0xc0000f4000, 0x4)
/Users/berto/go/src/github.com/gokultp/go-four-in-a-row/pkg/game/game.go:245 +0x3e
main.main()
/Users/berto/go/src/github.com/gokultp/go-four-in-a-row/cmd/four-in-a-row/main.go:38 +0x1bc
exit status 2
Additional context
I'm pretty sure it has to do with the vertical check using width. I changed it to use g.Height and it seemed fixed. There were other issues not detecting diagonal wins after that. It's inconsistent and tedious to replicate.
Describe the bug When I update the size of the board from 10x10 to 7x6, the game crashes after a move.
To Reproduce Steps to reproduce the behavior:
./cmd/four-in-a-row/main.go
g := game.NewGame(7, 6)
.Error Message
Additional context I'm pretty sure it has to do with the vertical check using width. I changed it to use
g.Height
and it seemed fixed. There were other issues not detecting diagonal wins after that. It's inconsistent and tedious to replicate.