Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
def affine_lines(n: int) -> list: | |
return ( | |
[[[x + ((t * x + u) % n) * n for x in range(n)] for u in range(n)] for t in range(0, n)] + | |
[[[x + y * n for y in range(n)] for x in range(n)]] | |
) |
This file contains 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
IRR_POLYNOMIALS = [2, 7, 11, 19] | |
class BinaryFiniteField: | |
""" Basic arithmetic operations on finite fields or Galois field of order 2^n | |
Params: | |
- a (int) element of the 2^n set | |
- n (int) exponent | |
- r (int): irreducible polynomial over GF(2^n) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
from tic_tac_toe.utils.permutations import get_all_boards | |
symmetry_classes, all_boards = get_all_boards(exclude_winners=False) | |
counts = [len(sc) for sc in symmetry_classes] | |
counts_all = [len(b) for b in all_boards] | |
print(f"Unique boards: {counts}, sum: {sum(counts)}") | |
print(f"All boards: {counts_all}, sum: {sum(counts_all)}") | |
symmetry_classes_menace, all_boards_menace = get_all_boards(exclude_winners=True) |
This file contains 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
def get_score(board: Ternary, depth: int, player: int = 2) -> Tuple[int, bool]: | |
winner = whois_winner(board) | |
if winner == player: | |
return 10 - depth, True | |
elif winner < 1: | |
return 0, winner == 0 | |
else: | |
return depth - 10, True |