Open
Conversation
Contributor
|
The code seems well implemented. However, as this is the first game theory question it would be a good exercise to add a proof as well of why the algorithm works in the first place. |
Author
|
Should I add the proof to the repository , or just in the pull request? |
Contributor
|
In the pr description itself |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I observed that that the sequence of players repeats after every 6 moves . Hence we can convert this into a Grundy game with 6*n states ( 6 states for each vertex in the graph) .
Then I set all vertices with no outgoing edges as Losing States for the team of the player who has to move on that turn.
Now using these as the base states , I built the other states based on 4 cases : -
Current player on this node has an edge to a vertex with his team winning and he is not a joker. In this case this node is also winning for his team.
Current player on this node has an edge to a vertex with opposite team winning and he is a joker. In this case this node is losing for his team.
Current player on this node has all adjacent vertices with opposite team winning . In this case this node is losing for his team.
Current player on this node has all adjacent vertices with his team winning . In this case this node is winning for his team.
After evaluating this, we will have some nodes winning , some nodes losing , and the remaining nodes will be draws.