Last active
April 21, 2025 14:52
-
-
Save gwire/c4ec20dbd52137523e7903055c42f9bc to your computer and use it in GitHub Desktop.
Script to solve the steampipe puzzle in "Vampire The Masquerade - Swansong"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
In scene 07 of the game Vampire: The Masquerade - Swansong, you need to turn three valves | |
on three pipes, in order to set all three gauges to 12. | |
Each valve has a different effect across all three gagues. | |
If the gagues go over 12 they wrap around to zero. | |
Online guides suggest a specific sequence of turns, but this isn't a solution as it assumes | |
a known starting position. | |
I tried describing the problem to ChatGPT, requesting a python script to solve the problem, | |
and it gave an outline - but I ended up having to write the correct logic in turn_valve() myself. | |
""" | |
from collections import deque | |
# Define the effects of turning each valve | |
valve_effects = { | |
'A': (2, 6, 2), | |
'B': (4, 2, 2), | |
'C': (4, 6, 2) | |
} | |
def turn_valve(gauges, valve, direction): | |
effect = valve_effects[valve] | |
new_gauges = [] | |
for g, e in zip(gauges, effect): | |
if direction == 'clockwise': | |
if g + e > 12: | |
new_value = g + e - 14 | |
else: | |
new_value = g + e | |
else: | |
if g - e < 0: | |
new_value = 14 + (g - e) | |
else: | |
new_value = g - e | |
new_gauges.append(new_value) | |
return tuple(new_gauges) | |
def bfs(starting_gauges): | |
queue = deque([(starting_gauges, [])]) # (current_gauges, sequence_of_turns) | |
visited = set() | |
visited.add(starting_gauges) | |
while queue: | |
current_gauges, sequence = queue.popleft() | |
# Check if all gauges are at 12 | |
if all(g == 12 for g in current_gauges): | |
return sequence | |
for valve in valve_effects.keys(): | |
for direction in ['clockwise', 'anticlockwise']: | |
new_gauges = turn_valve(current_gauges, valve, direction) | |
if new_gauges not in visited: | |
visited.add(new_gauges) | |
queue.append((new_gauges, sequence + [(valve, direction)])) | |
return None # No solution found | |
def main(): | |
# Example starting values for the gauges | |
starting_gauges = (10, 4, 10) # Change this to any starting values between 0 and 12 | |
print(f"Starting gauges: {starting_gauges}") # Print starting values | |
solution = bfs(starting_gauges) | |
if solution is not None: | |
print("\nSequence of valve turns to reach (12, 12, 12):") | |
current_gauges = starting_gauges | |
for valve, direction in solution: | |
current_gauges = turn_valve(current_gauges, valve, direction) | |
print(f"Turn valve {valve} {direction}: New gauges = {current_gauges}") | |
else: | |
print("No solution found.") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment