Skip to content

Commit bc5e734

Browse files
committed
New resting states
1 parent 6243a11 commit bc5e734

File tree

3 files changed

+40
-28
lines changed

3 files changed

+40
-28
lines changed

bot/coder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ def change_game_position(h_message, delta=1):
209209
return update_game_position(h_message, game_position)
210210

211211

212-
def new_game(h_message):
213-
h_message = update_game_position(h_message, 0)
212+
def play_again_me_first(h_message):
213+
h_message = update_game_position(h_message, 4)
214214
return h_message[: CHARS_PER_BYTE * (GAME_OFFSET + F_WIDTH * 2)]
215215

216216

bot/player.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ def _transfer_stake(hex_message, multiplier=1):
5050

5151
def check_end_of_game(hex_message):
5252
if strategy.check_win(hex_message):
53-
hex_message = coder.update_game_position(hex_message, 3)
53+
hex_message = coder.update_game_position(hex_message, 2)
5454
return transfer_double_stake(hex_message)
5555
if strategy.check_draw(hex_message):
56-
hex_message = coder.update_game_position(hex_message, 4)
56+
hex_message = coder.update_game_position(hex_message, 3)
5757
return transfer_stake(hex_message)
5858
return transfer_double_stake(hex_message)
5959

@@ -78,10 +78,6 @@ def play_cross_move(hex_message):
7878
return coder.update_crosses(hex_message, crosses)
7979

8080

81-
def from_resting(_hex_message):
82-
return [coder.update_noughts, transfer_stake, play_cross_move, coder.change_game_position]
83-
84-
8581
def from_oplay(_hex_message):
8682
return [play_cross_move,
8783
lambda h_message: coder.change_game_position(h_message, -1), check_end_of_game]
@@ -95,19 +91,29 @@ def from_victory(hex_message):
9591
if not coder.get_state_balance(hex_message, 0) or not coder.get_state_balance(hex_message, 1):
9692
wallet.clear_wallet_channel(hex_message, g.bot_addr)
9793
return [coder.conclude]
98-
return [coder.new_game]
94+
return [coder.play_again_me_first]
9995

10096

10197
def from_draw(_hex_message):
102-
return [coder.new_game]
98+
return [coder.play_again_me_first]
99+
100+
101+
def from_play_again_me_first(_hex_message):
102+
return [coder.change_game_position]
103+
104+
105+
def from_play_again_me_second(_hex_message):
106+
return [coder.update_noughts, transfer_stake, play_cross_move,
107+
lambda h_message: coder.update_game_position(h_message, 0)]
103108

104109

105110
GAME_STATES = (
106-
from_resting,
107111
from_xplay,
108112
from_oplay,
109113
from_victory,
110114
from_draw,
115+
from_play_again_me_first,
116+
from_play_again_me_second,
111117
)
112118

113119

0 commit comments

Comments
 (0)