diff --git a/__pycache__/nim.cpython-313.pyc b/__pycache__/nim.cpython-313.pyc index 9065861..181141d 100644 Binary files a/__pycache__/nim.cpython-313.pyc and b/__pycache__/nim.cpython-313.pyc differ diff --git a/nim.py b/nim.py index 8056c8b..bce6111 100644 --- a/nim.py +++ b/nim.py @@ -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 diff --git a/test.py b/test.py index 0731673..dfa2c8b 100644 --- a/test.py +++ b/test.py @@ -10,6 +10,11 @@ def test_get_q_value(ai): def test_update_q_value(ai): print("\n--- Testing update_q_value ---") + state = (2, 1, 1, 0) + action = (0, 1) + print(ai.q) + print(ai.update_q_value([2, 1, 1, 0], (0, 1), 0.2, 1, 0.8)) + print(ai.q) def test_best_future_reward(ai):