-
-
Notifications
You must be signed in to change notification settings - Fork 48.7k
minimax algorithm added #11678
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
minimax algorithm added #11678
Conversation
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
board = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] | ||
|
||
|
||
def Gameboard(board): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file maths/Game Theory/AlphaBetaPruning/alphabetapruning.py
, please provide doctest for the function Gameboard
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: Gameboard
Please provide return type hint for the function: Gameboard
. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: board
print("===============") | ||
|
||
|
||
def Clearboard(board): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file maths/Game Theory/AlphaBetaPruning/alphabetapruning.py
, please provide doctest for the function Clearboard
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: Clearboard
Please provide return type hint for the function: Clearboard
. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: board
board[x][y] = 0 | ||
|
||
|
||
def winningPlayer(board, player): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file maths/Game Theory/AlphaBetaPruning/alphabetapruning.py
, please provide doctest for the function winningPlayer
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: winningPlayer
Please provide return type hint for the function: winningPlayer
. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: board
Please provide type hint for the parameter: player
return False | ||
|
||
|
||
def gameWon(board): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file maths/Game Theory/AlphaBetaPruning/alphabetapruning.py
, please provide doctest for the function gameWon
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: gameWon
Please provide return type hint for the function: gameWon
. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: board
return winningPlayer(board, 1) or winningPlayer(board, -1) | ||
|
||
|
||
def printResult(board): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file maths/Game Theory/AlphaBetaPruning/alphabetapruning.py
, please provide doctest for the function printResult
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: printResult
Please provide return type hint for the function: printResult
. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: board
|
||
# Game play input validation | ||
# Input is considered valid only if its one of the 3 availiable options and does not cause a negative amount of cubes on the table. | ||
def validateInput(message): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file maths/Game Theory/minimax/minimax.py
, please provide doctest for the function validateInput
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: validateInput
Please provide return type hint for the function: validateInput
. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: message
print(f"Wrong choice, try again. Availiable options are: 1 or 2 or {K}: ") | ||
|
||
|
||
def plural(choice): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file maths/Game Theory/minimax/minimax.py
, please provide doctest for the function plural
Please provide return type hint for the function: plural
. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: choice
# ==================== 1. MiniMax for the optimal choice from MAX ================== | ||
# It recursively expands the whole tree and returns the list [score, move], | ||
# meaning the pair of best score tighten to the actual move that caused it. | ||
def MiniMax(state, player): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file maths/Game Theory/minimax/minimax.py
, please provide doctest for the function MiniMax
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: MiniMax
Please provide return type hint for the function: MiniMax
. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: state
Please provide type hint for the parameter: player
0, | ||
] # We really do not care on the move at this point | ||
|
||
availiableChoices = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: availiableChoices
|
||
# ===== Παίζει ο χρήστης ===== | ||
else: | ||
userChoice = validateInput( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: userChoice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
# If the current state is not final, we don't care on the current evaluation so we simply initialise it to 0. | ||
|
||
|
||
def evaluate(state, player): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file maths/Game Theory/minimax/minimax.py
, please provide doctest for the function evaluate
Please provide return type hint for the function: evaluate
. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: state
Please provide type hint for the parameter: player
return 0 | ||
|
||
|
||
def gameOver(remainingCubes, player): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file maths/Game Theory/minimax/minimax.py
, please provide doctest for the function gameOver
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: gameOver
Please provide return type hint for the function: gameOver
. If the function does not return a value, please provide the type hint as: def function() -> None:
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: remainingCubes
Please provide type hint for the parameter: remainingCubes
Please provide type hint for the parameter: player
|
||
|
||
# M input validation | ||
def validateM(message): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file maths/Game Theory/minimax/minimax.py
, please provide doctest for the function validateM
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: validateM
Please provide return type hint for the function: validateM
. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: message
|
||
|
||
# K input validation | ||
def validateK(message): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file maths/Game Theory/minimax/minimax.py
, please provide doctest for the function validateK
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: validateK
Please provide return type hint for the function: validateK
. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: message
|
||
# Game play input validation | ||
# Input is considered valid only if its one of the 3 availiable options and does not cause a negative amount of cubes on the table. | ||
def validateInput(message): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file maths/Game Theory/minimax/minimax.py
, please provide doctest for the function validateInput
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: validateInput
Please provide return type hint for the function: validateInput
. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: message
print(f"Wrong choice, try again. Availiable options are: 1 or 2 or {K}: ") | ||
|
||
|
||
def plural(choice): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file maths/Game Theory/minimax/minimax.py
, please provide doctest for the function plural
Please provide return type hint for the function: plural
. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: choice
# ==================== 1. MiniMax for the optimal choice from MAX ================== | ||
# It recursively expands the whole tree and returns the list [score, move], | ||
# meaning the pair of best score tighten to the actual move that caused it. | ||
def MiniMax(state, player): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file maths/Game Theory/minimax/minimax.py
, please provide doctest for the function MiniMax
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: MiniMax
Please provide return type hint for the function: MiniMax
. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: state
Please provide type hint for the parameter: player
0, | ||
] # We really do not care on the move at this point | ||
|
||
availiableChoices = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: availiableChoices
|
||
# ===== Παίζει ο χρήστης ===== | ||
else: | ||
userChoice = validateInput( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: userChoice
Closing require_type_hints PRs to prepare for Hacktoberfest |
Describe your change:
Added Three algorithms under python/maths/gametheory/
Algorithms added:
Checklist: