Skip to content

Commit 51d7d32

Browse files
committed
feat: Tweak teleporting when stuck
Currently qw tries to teleport at the end of its movement plan, when it's stuck, before trying random movement. This can waste valuable teleport scrolls in situations where qw is very temporarily stuck. This commit puts a random movement plan before the teleport plan that's only active if we've been stuck less than 50 turns. After 50 turns of still being stuck, qw will attempt it's plan to teleport. The final plan of the movement cascade is still the main random movement plan, which lasts for 1000 turns total before qw quits the game. We reset the stuck counter whenever a level transition is made so that this approach can work. There was no reason to make it cumulative across a session in the first place, since when qw is stuck, it's never moving between levels.
1 parent fc7b4b4 commit 51d7d32

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

source/plans-move.lua

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,15 @@ function choose_tactical_step()
228228
end
229229
end
230230

231+
function plan_quit()
232+
if stuck_turns > QUIT_TURNS or select(2, you.hp()) == 1 then
233+
magic(control('q') .. "yes\r")
234+
return true
235+
end
236+
237+
return false
238+
end
239+
231240
function plan_cloud_step()
232241
if tactical_reason == "cloud" then
233242
say("Stepping ~*~*~tactically~*~*~ (" .. tactical_reason .. ").")
@@ -328,13 +337,11 @@ end
328337
function plan_stuck()
329338
stuck_turns = stuck_turns + 1
330339
return random_step("stuck")
331-
-- panic("Stuck!")
332340
end
333341

334-
function plan_quit()
335-
if stuck_turns > QUIT_TURNS or select(2, you.hp()) == 1 then
336-
magic(control('q') .. "yes\r")
337-
return true
342+
function plan_stuck_initial()
343+
if stuck_turns <= 50 then
344+
return plan_stuck()
338345
end
339346

340347
return false
@@ -616,6 +623,7 @@ function set_plan_move()
616623
{plan_stuck_dig_grate, "try_stuck_dig_grate"},
617624
{plan_stuck_cloudy, "stuck_cloudy"},
618625
{plan_stuck_forget_map, "try_stuck_forget_map"},
626+
{plan_stuck_initial, "stuck_initial"},
619627
{plan_stuck_teleport, "stuck_teleport"},
620628
{plan_stuck, "stuck"},
621629
}

source/turn.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,18 @@ function turn_update()
125125
where_depth = you.depth()
126126
want_gameplan_update = true
127127

128+
target_stair = nil
129+
transp_zone = 0
130+
zone_counts = {}
131+
132+
clear_ignores()
133+
stuck_turns = 0
128134
if backtracked_to ~= where then
129135
backtracked_to = nil
130136
end
131137

132-
clear_ignores()
133-
target_stair = nil
134138
base_corrosion = in_branch("Dis") and 2 or 0
135139

136-
transp_zone = 0
137-
zone_counts = {}
138-
139140
if you.have_orb() and where == zot_end then
140141
ignore_traps = true
141142
else

0 commit comments

Comments
 (0)