Skip to content

Commit 2762034

Browse files
committed
Merge branch 'master' of https://github.com/r2dev2bb8/ChessData
2 parents 9125405 + 4070517 commit 2762034

22 files changed

Lines changed: 1610829 additions & 5 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ pgns/*
55
stockfish/
66
stockfish.zip
77
__MAC*
8+
*cpython*

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Ronak Badhe
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Current fen databases being analysed:
4141
| @oliver-ni | BenkoGambit2.txt | generating |
4242
| @oliver-ni | Caro-KannAdv.txt | generating |
4343
| @oliver-ni | PircOtherBlack3.txt | generating |
44-
| Luke Zhao | Albert.txt | generating |
44+
| Luke Zhao | Alburt.txt | Finished |
4545
| @oliver-ni | FourKnights.txt | generating |
4646
| @oliver-ni | English1g6.txt | generating |
4747
| @r2dev2bb8 | Alekhine4Pawns.txt | Finished |
@@ -50,11 +50,11 @@ Current fen databases being analysed:
5050
| @Chubtato | AlekhineExchange.txt | generating |
5151
| @r2dev2bb8 | Alekseev.txt | Finished |
5252
| @Kunal-Shirvastav| Anand.txt| generating |
53-
| @r2dev2bb8 | Beliavsky.txt | generating |
53+
| @r2dev2bb8 | Beliavsky.txt | Finished |
5454
| Francis Chua| Bacrot.txt | generating |
5555
| Aryan Dwivedi| BecerraRivero.txt | generating |
5656
| @AarushiM | Andreiken.txt | generating |
57-
| Bennie Chang| Benjamin.txt | generating |
57+
| Bennie Chang| Benjamin.txt | Finished |
5858
| Saadhan Pittala | Azmaiparashvilieval.txt | generating |
5959
| @r2dev2bb8 | Bogo4Nbd2.txt | generating |
6060
| @r2dev2bb8 | Sic2Nc6-4Qc7-4Qb6.txt | generating |
@@ -72,4 +72,6 @@ Current fen databases being analysed:
7272
| @Chubtato | RuyLopezExchange.txt | generating |
7373
| @Chubtato | RuyLopezFlohr-Zaitsev.txt| generating |
7474
| @Chubtato | RuyLopezModSteinitz.txt | generating |
75+
| Luke Zhao | Blackburne.txt | generating |
76+
| Bennie Chang| Bu.txt | generating |
7577

contribute/auto.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import os
2+
import sys
3+
import zipfile
4+
from pathlib import Path
5+
from subprocess import call
6+
from typing import *
7+
8+
import evalfen
9+
from getFile import downloadName, getAvailableNames
10+
from send import sendFile, sendNotification
11+
12+
STOCKFISH_DOWNLOAD = {
13+
"win32": "https://stockfishchess.org/files/stockfish-11-win.zip",
14+
"linux": "https://stockfishchess.org/files/stockfish-11-linux.zip",
15+
"linux32": "https://stockfishchess.org/files/stockfish-11-linux.zip",
16+
"darwin": "https://stockfishchess.org/files/stockfish-11-mac.zip"
17+
}
18+
19+
20+
def unzip(filepath, resultpath):
21+
with zipfile.ZipFile(filepath, 'r') as zip_ref:
22+
zip_ref.extractall(resultpath)
23+
24+
25+
def promptNames(names: List[str]) -> str:
26+
for i, name in enumerate(names):
27+
print(i, name, sep='\t')
28+
uin = int(input("Which number? "))
29+
return names[uin]
30+
31+
32+
def promptDownload() -> bool:
33+
uin = input("Do you need to download any other dataset?(y)es/(n)o ")
34+
return 'y' in uin
35+
36+
37+
def downloadStockfish() -> None:
38+
link = STOCKFISH_DOWNLOAD[sys.platform]
39+
call(["curl", "-o", "stockfish.zip", link])
40+
unzip("stockfish.zip", "stockfish/")
41+
42+
43+
def findStockfish() -> Path:
44+
pass
45+
46+
47+
def promptStockfish() -> Path:
48+
uin = input("Do you have stockfish in your current directory?(y)es/(n)o ")
49+
needsfish = 'y' in uin
50+
if needsfish:
51+
downloadStockfish()
52+
53+
54+
def main() -> None:
55+
if promptDownload():
56+
names = list(getAvailableNames())
57+
names.sort()
58+
name = promptNames(names)
59+
downloadName(name)
60+
print("Done for now")
61+
62+
63+
if __name__ == "__main__":
64+
main()

contribute/email.function

848 Bytes
Binary file not shown.

evalfen.py renamed to contribute/evalfen.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ def read(self, no):
2222
def readlines(self):
2323
pass
2424

25+
def lineCount(filename):
26+
try:
27+
with open(filename, 'r') as fin:
28+
l = len(fin.readlines())
29+
except FileNotFoundError:
30+
l = 0
31+
return l
32+
2533
def evalFENThread(output, i, fen, engine, d):
2634
board = chess.Board(fen)
2735
info = engine.analyse(board, chess.engine.Limit(depth=d))
@@ -80,8 +88,7 @@ def main(filein, fileout, d, threads, linetostart, enginepath):
8088
parser.add_argument("-s", help="Source file with fens")
8189
parser.add_argument("-d", help="Destination evaluation file")
8290
parser.add_argument("-t", help="Number of threads to use", default=5)
83-
parser.add_argument("-l", help="Line number to start with", default=0)
8491
parser.add_argument("-e", help="Path to chess engine", default="stockfish")
8592
args = parser.parse_args()
86-
main(args.s, args.d, 22, int(args.t), int(args.l), args.e)
93+
main(args.s, args.d, 22, int(args.t), lineCount(args.d), args.e)
8794

contribute/getFile.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from typing import *
2+
3+
import requests
4+
5+
6+
HEADERS = {"user-agent": "chess-contributing-app"}
7+
8+
def grep(search: str, contents: Iterable) -> Generator[str, None, None]:
9+
for s in contents:
10+
if search in s:
11+
yield s
12+
13+
def getAllNames() -> Set[str]:
14+
fenurl = "https://github.com/r2dev2bb8/ChessData/tree/master/fens"
15+
r = requests.get(fenurl, HEADERS)
16+
rawnames = grep("</a", grep(".txt", r.content.decode().split('>')))
17+
return {name[:-3] for name in rawnames}
18+
19+
def getTakenNames() -> Set[str]:
20+
readmeurl = "https://raw.githubusercontent.com/r2dev2bb8/ChessData/master/README.md"
21+
r = requests.get(readmeurl, HEADERS)
22+
rawnames = grep(".txt", r.content.decode().split('\n'))
23+
return {s.split('|')[2].strip() for s in rawnames}
24+
25+
def getAvailableNames() -> Set[str]:
26+
allnames = getAllNames()
27+
taken = getTakenNames()
28+
return {name for name in allnames if name not in taken}
29+
30+
def downloadName(name: str) -> None:
31+
fenurl = "https://raw.githubusercontent.com/r2dev2bb8/ChessData/master/fens/"
32+
r = requests.get(fenurl + name, HEADERS)
33+
with open("../" + name, 'w+') as fout:
34+
fout.write(r.content.decode())
35+
36+
def main():
37+
names = list(getAvailableNames())
38+
names.sort()
39+
print(names)
40+
41+
if __name__ == "__main__":
42+
main()

contribute/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dill==0.3.1.1

contribute/send.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import smtplib
2+
from email.message import EmailMessage
3+
import dill
4+
5+
# send takes in msg and text file and sends it to me
6+
with open("email.function", 'rb') as fin:
7+
send = dill.load(fin)
8+
9+
def sendNotification(username: str, filename: str) -> None:
10+
send(f"{username} is starting {filename}.")
11+
12+
def sendFile(username: str, filename: str) -> None:
13+
send(f"{username} has finished {filename}.", filename)
14+
15+
def main():
16+
send("Test mail")
17+
18+
if __name__ == "__main__":
19+
main()

0 commit comments

Comments
 (0)