-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhpx.py
More file actions
114 lines (86 loc) · 3.08 KB
/
hpx.py
File metadata and controls
114 lines (86 loc) · 3.08 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import random
from collections import deque, defaultdict
def HyperBeam(prev_play, opponent_name, opponent_history=["R","R"]): # hpx1
opponent_history.append(prev_play)
if len(opponent_history) > 2:
opponent_history.pop(0)
guess = "R"
if opponent_history[-1] == "R":
guess = "P"
elif opponent_history[-1] == "P":
guess = "S"
elif opponent_history[-1] == "S":
guess = "R"
return guess
def LRS(arr):
n = len(arr)
for size in range(5, 0, -1):
temp = arr[-size:]
for start in range(n - 2*size + 1):
if arr[start:start+size] == temp:
return temp
return []
def EldenRing(prev_play, opponent_name, opponent_history=[], my_moves=[]): # hpx2
moves = {'P': 'S', 'R': 'P', 'S': 'R'}
if prev_play:
opponent_history.append(prev_play)
if len(opponent_history) < 10:
move = random.choice(["R", "P", "S"])
my_moves.append(move)
return move
if len(opponent_history) > 10:
opponent_history.pop(0)
if len(my_moves) > 10:
my_moves.pop(0)
pattern = LRS(opponent_history)
if pattern:
next_move = pattern[-1]
move = moves[next_move]
else:
move = random.choice(["R", "P", "S"])
my_moves.append(move)
return move
def Maverick(prev_play, opponent_name, opponent_history=[], play_order=defaultdict(int), repeat=3):
if not prev_play:
prev_play = random.choice(['R', 'P', 'S'])
opponent_history.append(prev_play)
if len(opponent_history) > repeat:
recent_sequence = "".join(opponent_history[-repeat:])
play_order[recent_sequence] += 1
if len(opponent_history) > repeat:
possible_next = ["".join(opponent_history[-repeat+1:]) + "R",
"".join(opponent_history[-repeat+1:]) + "P",
"".join(opponent_history[-repeat+1:]) + "S"]
prediction = max(possible_next, key=lambda seq: play_order[seq])[-1]
else:
prediction = random.choice(['R', 'P', 'S'])
ideal_response = {'P': 'S', 'R': 'P', 'S': 'R'}
return ideal_response[prediction]
def DragonDance(prev_play, opponent_name, opponent_history=[]): # hpx4
if prev_play:
opponent_history.append(prev_play)
if prev_play == '':
prev_play = "R"
moves = {'P': 'S', 'R': 'P', 'S': 'R'}
return moves[prev_play]
def SuperBaby(prev_play, opponent_name, opponent_history=[]): # hpx5
if not prev_play:
prev_play = "S"
if opponent_name == "taylor_strategy":
if len(opponent_history) == 1:
return "S"
else:
moves = {'P': 'S', 'R': 'P', 'S': 'R'}
return moves[moves[prev_play]]
else:
opponent_history.append(prev_play)
if len(opponent_history) > 2:
opponent_history.pop(0)
guess = "R"
if opponent_history[-1] == "R":
guess = "P"
elif opponent_history[-1] == "P":
guess = "S"
elif opponent_history[-1] == "S":
guess = "R"
return guess