Akavall / GoGamesProject

Trying to make some simple games using golang.
1 stars 1 forks source link

Index error, when Human has 13 and AI lost #70

Closed Akavall closed 6 years ago

Akavall commented 6 years ago
2018/10/03 04:55:59 Grabbed game state with id: c296770a-7047-4f12-681b-b3c043109ea1
2018/10/03 04:55:59 http: panic serving 75.172.135.96:59584: runtime error: index out of range
goroutine 651 [running]:
net/http.(*conn).serve.func1(0xc4201ec3c0)
    /usr/lib/go/src/net/http/server.go:1726 +0xd0
panic(0x8b6ec0, 0xc37900)
    /usr/lib/go/src/runtime/panic.go:502 +0x229
main.take_zombie_dice_turn(0x9dd420, 0xc4201d6540, 0xc4201ce500)
    /home/kirill/GoStuff/src/github.com/Akavall/GoGamesProject/zombie_dice_server/basic_server.go:186 +0x1c23
net/http.HandlerFunc.ServeHTTP(0x9603c0, 0x9dd420, 0xc4201d6540, 0xc4201ce500)
    /usr/lib/go/src/net/http/server.go:1947 +0x44
net/http.(*ServeMux).ServeHTTP(0xc4201a24b0, 0x9dd420, 0xc4201d6540, 0xc4201ce500)
    /usr/lib/go/src/net/http/server.go:2337 +0x130
net/http.serverHandler.ServeHTTP(0xc42019ec30, 0x9dd420, 0xc4201d6540, 0xc4201ce500)
    /usr/lib/go/src/net/http/server.go:2694 +0xbc
net/http.(*conn).serve(0xc4201ec3c0, 0x9dd8a0, 0xc4203309c0)
    /usr/lib/go/src/net/http/server.go:1830 +0x651
created by net/http.(*Server).Serve
    /usr/lib/go/src/net/http/server.go:2795 +0x27b

The error occurs every time "Take Turn" is hit.

Maybe another way to describe this bug is that: "Winner: You", does not show up. Winner is just left blank.

Otherwise, index out of range error occurs every time human wins and "Take Turn" button is hit. That could be an issue in itself?

The issue seems to occur, when Human won (has at least 13 points) and AI got shot at least 3 times on their last move. If AI took the brains, but still lost, the issue does not occur.

Akavall commented 6 years ago

This should be fixed: https://github.com/Akavall/GoGamesProject/pull/71