kyu_5.tic_tac_toe_checker package
Submodules
kyu_5.tic_tac_toe_checker.checker module
Solution for -> Tic-Tac-Toe Checker.
Created by Egor Kostan. GitHub: https://github.com/ikostan
- kyu_5.tic_tac_toe_checker.checker.check_cols(board) int | None[source]
Check board by column.
- Parameters:
board – list
- Returns:
1, 2, or None
- kyu_5.tic_tac_toe_checker.checker.check_diagonals(board) int | None[source]
Check board by diagonal.
- Parameters:
board – list
- Returns:
1, 2, or None
- kyu_5.tic_tac_toe_checker.checker.check_rows(board: list) int | None[source]
Check board by row.
- Parameters:
board – list
- Returns:
1, 2, or None
- kyu_5.tic_tac_toe_checker.checker.is_solved(board) int[source]
is_solved function.
Checks whether the board’s current state is solved: -1 if the board is not yet finished (there are empty spots), 1 if “X” won, 2 if “O” won, 0 if it’s a cat’s game (i.e. a draw). :param board: list :return: -1, 0, 1, or 2
kyu_5.tic_tac_toe_checker.test_checker module
Test for -> is_solved function.
Created by Egor Kostan. GitHub: https://github.com/ikostan
- class kyu_5.tic_tac_toe_checker.test_checker.IsSolvedTestCase(methodName='runTest')[source]
Bases:
TestCaseTesting is_solved function.
- _classSetupFailed = False
- _class_cleanups = []
- test_is_solved = None
- test_is_solved_0(**kw)
Testing is_solved function with various test data [with board=[[0, 0, 1], [0, 1, 2], [2, 1, 0]], expected=-1, message=’not yet finished’].
The function should return whether the board’s current state is solved.
We want our function to return:
-1 if the board is not yet finished (there are empty spots), 1 if “X” won, 2 if “O” won, 0 if it’s a cat’s game (i.e. a draw).
- Returns:
- test_is_solved_1(**kw)
Testing is_solved function with various test data [with board=[[1, 1, 1], [0, 2, 2], [0, 0, 0]], expected=1, message=’winning row’].
The function should return whether the board’s current state is solved.
We want our function to return:
-1 if the board is not yet finished (there are empty spots), 1 if “X” won, 2 if “O” won, 0 if it’s a cat’s game (i.e. a draw).
- Returns:
- test_is_solved_2(**kw)
Testing is_solved function with various test data [with board=[[2, 1, 2], [2, 1, 1], [1, 1, 2]], expected=1, message=’winning column’].
The function should return whether the board’s current state is solved.
We want our function to return:
-1 if the board is not yet finished (there are empty spots), 1 if “X” won, 2 if “O” won, 0 if it’s a cat’s game (i.e. a draw).
- Returns:
- test_is_solved_3(**kw)
Testing is_solved function with various test data [with board=[[2, 1, 2], [2, 1, 1], [1, 2, 1]], expected=0, message=’draw’].
The function should return whether the board’s current state is solved.
We want our function to return:
-1 if the board is not yet finished (there are empty spots), 1 if “X” won, 2 if “O” won, 0 if it’s a cat’s game (i.e. a draw).
- Returns:
- test_is_solved_4(**kw)
Testing is_solved function with various test data [with board=[[1, 2, 0], [0, 1, 2], [0, 0, 1]], expected=1, message=’wining diagonal’].
The function should return whether the board’s current state is solved.
We want our function to return:
-1 if the board is not yet finished (there are empty spots), 1 if “X” won, 2 if “O” won, 0 if it’s a cat’s game (i.e. a draw).
- Returns:
Module contents
Tic-Tac-Toe Checker.