Implementiere update_q_value

This commit is contained in:
mia 2026-04-23 09:39:16 +02:00
parent a74be2fc31
commit 933d0c5d27
3 changed files with 14 additions and 3 deletions

12
nim.py
View file

@ -31,10 +31,16 @@ class Nim():
class NimAI():
def __init__(self, alpha=0.5, epsilon=0.1):
def __init__(self, alpha=0.5, epsilon=1):
self.q = dict() # Q-value table
self.q[(0, 0, 0, 2), (3, 2)] = -1 # Test Q-Value
self.q[(0, 0, 0, 2), (3, 1)] = 10 # Test Q-Value
# self.q[(0, 0, 0, 2), (3, 2)] = -1 # Test Q-Value
# self.q[(0, 0, 0, 2), (3, 1)] = 10 # Test Q-Value
self.q[((1,1,1,0), (0,1))] = 0.4
self.q[((1,1,1,0), (1,1))] = 0.9
self.q[((1,1,1,0), (2,1))] = 0.7
self.q[((2,1,1,0), (0,1))] = 0.2
self.alpha = alpha # Learning rate
self.epsilon = epsilon # Exploration rate