HaileyStorm
commited on
Commit
•
7dbf659
1
Parent(s):
2bff0e5
Upload chess-gpt-eval/mamba_module.py with huggingface_hub
Browse files
chess-gpt-eval/mamba_module.py
CHANGED
@@ -127,14 +127,17 @@ class MambaPlayer:
|
|
127 |
# return ''.join([itos[id] for id in token_ids]) # Example
|
128 |
|
129 |
def get_move_from_response(self, response: str) -> str:
|
130 |
-
if not response:
|
131 |
return None
|
132 |
# Parse the response to get only the first move
|
133 |
-
|
134 |
-
|
135 |
-
|
|
|
136 |
|
137 |
-
|
|
|
|
|
138 |
|
139 |
def get_move(self, board: str, game_state: str, temperature: float) -> str:
|
140 |
completion = self.get_mamba_response(game_state, temperature, 8, self.vocab_size)
|
|
|
127 |
# return ''.join([itos[id] for id in token_ids]) # Example
|
128 |
|
129 |
def get_move_from_response(self, response: str) -> str:
|
130 |
+
if not response or len(response) == 0:
|
131 |
return None
|
132 |
# Parse the response to get only the first move
|
133 |
+
try:
|
134 |
+
moves = response.split()
|
135 |
+
first_move = moves[0]
|
136 |
+
first_move = first_move.lstrip('.') # A patch for a weird phase during training ... doesn't seem to be an issue anymore, but don't see the harm.
|
137 |
|
138 |
+
return first_move
|
139 |
+
except:
|
140 |
+
return None
|
141 |
|
142 |
def get_move(self, board: str, game_state: str, temperature: float) -> str:
|
143 |
completion = self.get_mamba_response(game_state, temperature, 8, self.vocab_size)
|