-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestRPSPlayer
26 lines (22 loc) · 1.01 KB
/
TestRPSPlayer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import unittest
from RPS import player
class TestRPSPlayer(unittest.TestCase):
def test_player_first_game(self):
# Test the player function for the first game with no previous play
move = player("", [])
self.assertIn(move, ["R", "P", "S"]) # Assert that the move is valid
def test_player_subsequent_games(self):
# Test the player function for subsequent games with previous plays
prev_play = "R"
opponent_history = ["S", "P", "R", "R"]
move = player(prev_play, opponent_history)
self.assertIn(move, ["R", "P", "S"]) # Assert that the move is valid
def test_player_strategy(self):
# Test if the player function follows a specific strategy
prev_play = "R"
opponent_history = ["S", "P", "R", "R"]
move = player(prev_play, opponent_history)
# Assert specific moves based on strategy (e.g., if opponent plays R, player should play P)
self.assertEqual(move, "P")
if __name__ == '__main__':
unittest.main()