sigmoidneuron123 commited on
Commit
5e8d074
·
verified ·
1 Parent(s): b18f040

Update selfchess.py

Browse files
Files changed (1) hide show
  1. selfchess.py +5 -5
selfchess.py CHANGED
@@ -157,11 +157,11 @@ def game_gen(engine_side):
157
  keys = list(evaling.keys())
158
  logits = torch.tensor(list(evaling.values())).to(device)
159
  probs = torch.softmax(logits,dim=0)
160
- bests = torch.multinomial(probs,num_samples=CONFIG["epsilon"])
161
- bestl = []
162
- for idx in bests:
163
- bestl += [logits[idx].item()]
164
- move = keys[torch.argmax(bestl).item()]
165
  else:
166
  result = engine.play(board, lim)
167
  move = result.move
 
157
  keys = list(evaling.keys())
158
  logits = torch.tensor(list(evaling.values())).to(device)
159
  probs = torch.softmax(logits,dim=0)
160
+ epsilon = min(CONFIG["epsilon"],len(keys))
161
+ bests = torch.multinomial(probs,num_samples=epsilon,replacement=False)
162
+ best_idx = bests[torch.argmax(logits[bests])]
163
+ move = keys[best_idx.item()]
164
+
165
  else:
166
  result = engine.play(board, lim)
167
  move = result.move