Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Snake and ladder]: Added handling for game go routines #65

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vnkdj5
Copy link

@vnkdj5 vnkdj5 commented Jan 6, 2025

What?
The current go snake and ladder program does not wait for all games to finish.
Added waitgroups so that we wait for all the same to finish before closing the program.
Added Auto generating Ids for game so that we can track the moves of the game.

Output:

$ go run main.go 
Starting Projects
Games started. Check game output above.
Game: 2 :- Player 4 rolled a 4 and moved to position 14
Game: 1 :- Player 1 rolled a 6 and moved to position 6
Game: 1 :- Player 2 rolled a 6 and moved to position 6
Game: 2 :- Player 5 rolled a 3 and moved to position 3
Game: 2 :- Player 4 rolled a 1 and moved to position 15
Game: 1 :- Player 3 rolled a 4 and moved to position 14
Game: 2 :- Player 5 rolled a 5 and moved to position 8
Game: 1 :- Player 1 rolled a 5 and moved to position 11
Game: 1 :- Player 2 rolled a 4 and moved to position 10
Game: 2 :- Player 4 rolled a 6 and moved to position 42
Game: 2 :- Player 5 rolled a 4 and moved to position 12
Game: 1 :- Player 3 rolled a 1 and moved to position 15
Game: 1 :- Player 1 rolled a 2 and moved to position 13
Game: 2 :- Player 4 rolled a 4 and moved to position 46
Game: 2 :- Player 5 rolled a 5 and moved to position 17
Game: 1 :- Player 2 rolled a 1 and moved to position 11
Game: 1 :- Player 3 rolled a 5 and moved to position 20
Game: 2 :- Player 4 rolled a 1 and moved to position 47
Game: 2 :- Player 5 rolled a 6 and moved to position 23
Game: 1 :- Player 1 rolled a 6 and moved to position 19
Game: 1 :- Player 2 rolled a 2 and moved to position 13
Game: 2 :- Player 4 rolled a 6 and moved to position 53
Game: 2 :- Player 5 rolled a 6 and moved to position 29
Game: 1 :- Player 3 rolled a 3 and moved to position 23
Game: 1 :- Player 1 rolled a 5 and moved to position 24
Game: 2 :- Player 4 rolled a 6 and moved to position 59
Game: 2 :- Player 5 rolled a 6 and moved to position 35
Game: 1 :- Player 2 rolled a 1 and moved to position 14
Game: 1 :- Player 3 rolled a 2 and moved to position 25
Game: 2 :- Player 4 rolled a 1 and moved to position 60
Game: 2 :- Player 5 rolled a 5 and moved to position 40
Game: 1 :- Player 1 rolled a 3 and moved to position 27
Game: 1 :- Player 2 rolled a 5 and moved to position 19
Game: 2 :- Player 4 rolled a 2 and moved to position 62
Game: 1 :- Player 3 rolled a 3 and moved to position 84
Game: 2 :- Player 5 rolled a 5 and moved to position 45
Game: 2 :- Player 4 rolled a 4 and moved to position 66
Game: 1 :- Player 1 rolled a 2 and moved to position 29
Game: 1 :- Player 2 rolled a 5 and moved to position 24
Game: 2 :- Player 5 rolled a 6 and moved to position 67
Game: 2 :- Player 4 rolled a 5 and moved to position 71
Game: 1 :- Player 3 rolled a 4 and moved to position 88
Game: 1 :- Player 1 rolled a 1 and moved to position 30
Game: 2 :- Player 5 rolled a 5 and moved to position 72
Game: 2 :- Player 4 rolled a 6 and moved to position 77
Game: 1 :- Player 2 rolled a 5 and moved to position 29
Game: 2 :- Player 5 rolled a 5 and moved to position 77
Game: 1 :- Player 3 rolled a 4 and moved to position 92
Game: 1 :- Player 1 rolled a 3 and moved to position 33
Game: 2 :- Player 4 rolled a 6 and moved to position 83
Game: 2 :- Player 5 rolled a 4 and moved to position 81
Game: 1 :- Player 2 rolled a 2 and moved to position 31
Game: 1 :- Player 3 rolled a 5 and moved to position 97
Game: 2 :- Player 4 rolled a 5 and moved to position 88
Game: 1 :- Player 1 rolled a 5 and moved to position 38
Game: 2 :- Player 5 rolled a 6 and moved to position 87
Game: 2 :- Player 4 rolled a 5 and moved to position 73
Game: 1 :- Player 2 rolled a 6 and moved to position 37
Game: 1 :- Player 3 rolled a 2 and moved to position 99
Game: 2 :- Player 5 rolled a 2 and moved to position 89
Game: 2 :- Player 4 rolled a 3 and moved to position 76
Game: 1 :- Player 1 rolled a 1 and moved to position 39
Game: 1 :- Player 2 rolled a 3 and moved to position 40
Game: 2 :- Player 5 rolled a 2 and moved to position 91
Game: 2 :- Player 4 rolled a 1 and moved to position 77
Game: 2 :- Player 5 rolled a 1 and moved to position 92
Game: 1 :- Player 1 rolled a 3 and moved to position 42
Game: 2 :- Player 4 rolled a 4 and moved to position 81
Game: 1 :- Player 2 rolled a 2 and moved to position 42
Game: 2 :- Player 5 rolled a 4 and moved to position 96
Game: 2 :- Player 4 rolled a 6 and moved to position 87
Game: 1 :- Player 1 rolled a 3 and moved to position 45
Game: 1 :- Player 2 rolled a 5 and moved to position 47
Game: 2 :- Player 4 rolled a 4 and moved to position 91
Game: 1 :- Player 3 rolled a 1 and moved to position 100
For Game 1 :- Player 3 wins!
Game: 2 :- Player 5 rolled a 4 and moved to position 100
For Game 2 :- Player 5 wins!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant