Spaces:
Runtime error
Runtime error
Started work on logger
Browse files- .gitignore +0 -0
- requirements.txt +1 -1
- src/game_database.py +2 -0
- src/logger.py +46 -0
.gitignore
ADDED
File without changes
|
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
#To download requirements, use 'python -m pip install -r requirements.txt'
|
2 |
-
#python-chess
|
|
|
1 |
#To download requirements, use 'python -m pip install -r requirements.txt'
|
2 |
+
#python-chess==1.10.0
|
src/game_database.py
CHANGED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
class game_database:
|
2 |
+
pass
|
src/logger.py
CHANGED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
|
3 |
+
class logger:
|
4 |
+
def __init__(self, model_1: str, model_2: str):
|
5 |
+
self.model_1 = model_1
|
6 |
+
self.model_2 = model_2
|
7 |
+
|
8 |
+
current_moves = "" #FEN notation
|
9 |
+
cheat_attempts = "" #format?
|
10 |
+
winner = ""
|
11 |
+
|
12 |
+
#Internal Work
|
13 |
+
def get_stockfish_results(self, prev_state: str, current_state: str, depth: int = 5) -> float:
|
14 |
+
#returns the stockfish analysis of the last move
|
15 |
+
#Example URL: https://stockfish.online/api/stockfish.php?fen=r2q1rk1/ppp2ppp/3bbn2/3p4/8/1B1P4/PPP2PPP/RNB1QRK1 w - - 5 11&depth=5&mode=eval
|
16 |
+
current_FEN = "?fen=" + current_state
|
17 |
+
prev_FEN = "?fen=" + prev_state
|
18 |
+
|
19 |
+
endpoint = "https://stockfish.online/api/stockfish.php"
|
20 |
+
current_extra = current_FEN + "&depth=" + str(depth) + "&mode=eval"
|
21 |
+
prev_extra = prev_FEN + "&depth=" + str(depth) + "&mode=eval"
|
22 |
+
current_response = requests.get(endpoint + current_extra)
|
23 |
+
prev_response = requests.get(endpoint + prev_extra)
|
24 |
+
|
25 |
+
#response format is: {'success': True, 'data': 'Total evaluation: -1.79 (white side)'}
|
26 |
+
|
27 |
+
#return current_score - prev_score
|
28 |
+
def format_game(self):
|
29 |
+
pass
|
30 |
+
|
31 |
+
#Interface with the Model Interface
|
32 |
+
def add_legal_move(self, current_moves: str): #current_moves should be all moves so far, in FEN notation
|
33 |
+
#updates sequence of moves stored
|
34 |
+
pass
|
35 |
+
def add_cheat(self, cheater_name: str):
|
36 |
+
#adds cheats parallel to the sequence of moves
|
37 |
+
pass
|
38 |
+
def add_checkmate(self, winner_name: str):
|
39 |
+
#logs the winner and stops recording
|
40 |
+
pass
|
41 |
+
|
42 |
+
#Interface with game_database
|
43 |
+
def return_formatted_game(self, game_num: int):
|
44 |
+
pass
|
45 |
+
|
46 |
+
|