Akavall / GoGamesProject

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

Game crashes fairly quickly after game is continued after it is "over" #60

Closed Akavall closed 6 years ago

Akavall commented 6 years ago

This happens in special case:

It looks like the game can continue even after the winner has been declared (one player go 13 or more points and thus won the game, there is no tie). I don't think I remember checking for it before, but it certainly can now. This is fine; it is are reasonable feature...

However, playing this game for a while results in this error:

2017/11/13 02:47:38 Grabbed game state with id: 75dcef79-03f4-494d-68dd-16be63c94f98
2017/11/13 02:47:38 Size of deck : 12
2017/11/13 02:47:38 shot: 0,brains: 1, walks: 2
2017/11/13 02:47:38 AI Player rolled: green, brain
2017/11/13 02:47:38 AI Player rolled: red, walk
2017/11/13 02:47:38 AI Player rolled: green, walk
2017/11/13 02:47:38 Deleted GameState associated with 75dcef79-03f4-494d-68dd-16be63c94f98 in DynamoDB table: GameStates
2017/11/13 02:47:41 PLAYERS NAME : AI Player
2017/11/13 02:47:41 continue_turn_0 : true
2017/11/13 02:47:41 uuid : 75dcef79-03f4-494d-68dd-16be63c94f98
2017/11/13 02:47:41 Grabbed game state with id: 75dcef79-03f4-494d-68dd-16be63c94f98
2017/11/13 02:47:41 http: panic serving 71.217.47.28:56220: runtime error: index out of range
goroutine 106 [running]:
net/http.(*conn).serve.func1(0xc42008c000)
    /usr/lib/go-1.9/src/net/http/server.go:1697 +0xd0
panic(0x88e380, 0xbaaa80)
    /usr/lib/go-1.9/src/runtime/panic.go:491 +0x283
main.take_zombie_dice_turn(0xb7eb60, 0xc420182000, 0xc42017c700)
    /home/kirill/GoStuff/src/github.com/Akavall/GoGamesProject/zombie_dice_server/basic_server.go:186 +0x1c05
net/http.HandlerFunc.ServeHTTP(0x92b108, 0xb7eb60, 0xc420182000, 0xc42017c700)
    /usr/lib/go-1.9/src/net/http/server.go:1918 +0x44
net/http.(*ServeMux).ServeHTTP(0xc42013b920, 0xb7eb60, 0xc420182000, 0xc42017c700)
    /usr/lib/go-1.9/src/net/http/server.go:2254 +0x130
net/http.serverHandler.ServeHTTP(0xc420152b60, 0xb7eb60, 0xc420182000, 0xc42017c700)
    /usr/lib/go-1.9/src/net/http/server.go:2619 +0xb4
net/http.(*conn).serve(0xc42008c000, 0xb7f3a0, 0xc4202cac00)
    /usr/lib/go-1.9/src/net/http/server.go:1801 +0x71d
created by net/http.(*Server).Serve
    /usr/lib/go-1.9/src/net/http/server.go:2720 +0x288
2017/11/13 02:47:45 Put/update GameState associated with 75dcef79-03f4-494d-68dd-16be63c94f98 in DynamoDB table: GameStates
Akavall commented 6 years ago

The game should not continue after it is over because we are "deleting" a relevant game state after the game is over. The problem is the game is not deleted, and therefore we get this "feature".

        err := dynamo_db_tools.DeleteGameStateFromDynamoDB(uuid)

        if err != nil {
            log.Println("Was not able to delete GameState in DynamoDB, uuid: %s", err, uuid)
        } else {
            log.Printf("Deleted GameState associated with %s in DynamoDB table: GameStates", uuid)
        }

Looks OK, and in the log it looks like the GameState was deleted, but looking at AWS UI it is still there, and it really is still there.

I have validated the https://github.com/Akavall/GoGamesProject/blob/master/dynamo_db_tools/dynamo_db_tools.go#L76 works, when calling it from outside of zombie dice.

Still looking at it...

Akavall commented 6 years ago

Turned out to be a simple bug: I have a pull request to fix it: https://github.com/Akavall/GoGamesProject/pull/61