-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from karol-brejna-i/import-cleanups
Remove unused import; resolve some python code style violations
- Loading branch information
Showing
12 changed files
with
119 additions
and
134 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,6 @@ Stockfish | |
slack_key.txt | ||
venv | ||
*pgn | ||
.idea/ | ||
.venv | ||
.DS_Store |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ class bcolors: | |
FAIL = '\033[91m' | ||
ENDC = '\033[0m' | ||
BOLD = '\033[1m' | ||
UNDERLINE = '\033[4m' | ||
UNDERLINE = '\033[4m' |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,33 @@ | ||
import chess | ||
|
||
|
||
def sign(a): | ||
if a > 0: | ||
return 1 | ||
elif a < 0: | ||
return -1 | ||
else: | ||
return 0 | ||
return (a > 0) - (a < 0) | ||
|
||
|
||
def material_value(board): | ||
return sum(v * (len(board.pieces(pt, True)) + len(board.pieces(pt, False))) for v, pt in zip([0,3,3,5.5,9], chess.PIECE_TYPES)) | ||
return sum(v * (len(board.pieces(pt, True)) + len(board.pieces(pt, False))) for v, pt in | ||
zip([0, 3, 3, 5.5, 9], chess.PIECE_TYPES)) | ||
|
||
|
||
def material_count(board): | ||
return chess.popcount(board.occupied) | ||
|
||
|
||
def investigate(a, b, board): | ||
# determine if the difference between position A and B | ||
# is worth investigating for a puzzle. | ||
if a.cp is not None and b.cp is not None: | ||
if (((a.cp > -110 and a.cp < 850 and b.cp > 200 and b.cp < 850) | ||
or (a.cp > -850 and a.cp < 110 and b.cp < -200 and b.cp > -850)) | ||
and material_value(board) > 3 | ||
and material_count(board) > 6): | ||
if (((-110 < a.cp < 850 and 200 < b.cp < 850) | ||
or (-850 < a.cp < 110 and -200 > b.cp > -850)) | ||
and material_value(board) > 3 | ||
and material_count(board) > 6): | ||
return True | ||
elif (a.cp is not None | ||
and b.mate is not None | ||
and material_value(board) > 3): | ||
if ((a.cp < 110 and sign(b.mate) == -1) or (a.cp > -110 and sign(b.mate) == 1) ): | ||
elif a.cp is not None and b.mate is not None and material_value(board) > 3: | ||
if (a.cp < 110 and sign(b.mate) == -1) or (a.cp > -110 and sign(b.mate) == 1): | ||
return True | ||
elif (a.mate is not None | ||
and b.mate is not None): | ||
if sign(a.mate) == sign(b.mate): #actually means that they're opposite | ||
and b.mate is not None): | ||
if sign(a.mate) == sign(b.mate): # actually means that they're opposite | ||
return True | ||
return False | ||
return False |
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
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
Oops, something went wrong.