36 lines
819 B
Python
36 lines
819 B
Python
from nim import NimAI
|
|
|
|
def test_get_q_value(ai):
|
|
print("\n--- Testing get_q_value ---")
|
|
state = (0, 0, 0, 2)
|
|
action = (3, 2)
|
|
value = ai.get_q_value(state, action)
|
|
print(f"Q-value for state {state}, action {action}: {value}")
|
|
|
|
|
|
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):
|
|
print("\n--- Testing best_future_reward ---")
|
|
|
|
|
|
def test_choose_action(ai):
|
|
print("\n--- Testing choose_action ---")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
ai = NimAI()
|
|
|
|
test_get_q_value(ai)
|
|
test_update_q_value(ai)
|
|
test_best_future_reward(ai)
|
|
test_choose_action(ai)
|
|
|
|
print("\nAll tests completed.")
|