Skip to content

Ecoldev/gothic-lock-solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gothic Lock Solver

Video Tutorial: https://youtu.be/NQkDHOd0v6U

Overview

Gothic Lock Solver is a command-line tool for solving lock puzzles in Gothic 1 Remake.

The solver supports locks with any number of plates and automatically discovers lock dependencies, calculates the shortest solution using Breadth-First Search (BFS), and can execute the solution directly inside the game.

Current Version: v2.2.1


Features

  • Supports Gothic 1 Remake locks
  • Dynamic plate count (P1-Pn)
  • Guided dependency discovery
  • Automatic dependency modeling
  • Breadth-First Search (BFS) shortest-path solver
  • Automatic lock execution inside the game
  • Automatic lock reset before execution
  • Automatic navigation to P1
  • Automatic plate navigation
  • Keyboard input simulation
  • JSON profile storage
  • Invalid move detection
  • Support for large lock configurations
  • Support for plate numbers above P9 (P10, P11, P12...)

How It Works

Every lock contains one or more plates.

When creating a new lock profile, the solver asks for the number of plates and automatically creates:

P1 ... Pn

Plate numbering:

TOP
 │
 ├─ P1
 ├─ P2
 ├─ P3
 │
 ├─ ...
 │
 └─ Pn
BOTTOM

Position range:

1 = far left
7 = far right

The objective is to move every plate to position 4.

Example:

P1 = 4
P2 = 4
P3 = 4
P4 = 4
P5 = 4

Dynamic Plate Support

Examples:

5 plates
P1-P5

6 plates
P1-P6

7 plates
P1-P7

10 plates
P1-P10

15 plates
P1-P15

The solver automatically adjusts:

  • Dependency discovery
  • State generation
  • Goal generation
  • BFS search
  • Solution calculation
  • Profile storage

Step 1 - Discover Dependencies

The solver guides you through discovering lock behavior.

Example:

Testing P1

Move P1 one step in the game.

Observe which additional plates moved.

Input:

P2=R

Meaning:

P2 moved in the SAME direction.

Example:

P2=R,P3=L

Meaning:

P2 moved in the SAME direction.
P3 moved in the OPPOSITE direction.

Direction codes:

R = same direction
L = opposite direction

If no other plates moved:

Press ENTER

Note:

Each plate automatically affects itself.

Only additional affected plates should be entered.


Step 2 - Enter Current Positions

Example:

P1: 7
P2: 5
P3: 7
P4: 6
P5: 1

The solver calculates the shortest possible solution.


Example Output

SOLUTION

01. P1+A
02. P1+A
03. P2+A
04. P4+D
05. P5+A

Number of moves: 5

Legend:

A = move right
D = move left

Automatic Execution

Starting with version 2.2.1, the solver can execute solutions directly inside Gothic 1 Remake.

Workflow:

Discover lock
↓
Enter current positions
↓
Calculate shortest solution
↓
Open lock in Gothic
↓
Press ENTER
↓
Lock reset
↓
Automatic navigation to P1
↓
Automatic execution

The executor automatically:

  • Resets the lock
  • Navigates to P1
  • Navigates between plates
  • Simulates keyboard input
  • Executes the full solution

Example:

Number of moves: 45

Execute solution in Gothic automatically? [Y/n]
Y

OPEN THE LOCK IN GOTHIC

Press ENTER when ready...

Starting in 3...
Starting in 2...
Starting in 1...

Resetting lock position...
Starting from P1...

01. P1+A
02. P1+A
03. P2+A
...

Controls

Default controls:

A = move right
D = move left
W = move up
S = move down
R = reset lock

The executor automatically switches between plates and performs the required actions.


Installation

Requirements:

  • Python 3.10+

Install dependencies:

pip install pydirectinput pygetwindow pywin32

Clone repository:

git clone https://github.com/Ecoldev/gothic-lock-solver.git
cd gothic-lock-solver

Run:

python solver.py

Build Windows EXE

Install PyInstaller:

python -m pip install pyinstaller

Build executable:

python -m PyInstaller --onefile --console --name GothicLockSolver solver.py

Output:

dist/GothicLockSolver.exe

Example Workflow

How many plates does this lock have? 5

Enter lock name:
Warehouse Lock

STEP 1/2 - DISCOVER DEPENDENCIES

Testing P1
Move P1 one step in the game.

Which OTHER plates moved?
P2=R,P4=L

...

STEP 2/2 - SOLVE LOCK

P1: 3
P2: 5
P3: 7
P4: 6
P5: 7

Solving...

SOLUTION

01. P1+A
02. P1+A
03. P2+A
...

Number of moves: 45

Execute solution in Gothic automatically? [Y/n]
Y

OPEN THE LOCK IN GOTHIC

Press ENTER when ready...

Starting in 3...
Starting in 2...
Starting in 1...

Resetting lock position...
Starting from P1...

01. P1+A
02. P1+A
03. P2+A
...

Known Limitations

The solver uses Breadth-First Search (BFS) to guarantee the shortest solution.

The number of states grows exponentially with the number of plates.

Examples:

6 plates = 117,649 states
7 plates = 823,543 states
8 plates = 5,764,801 states

Very large locks may require significant memory and processing time.

Automatic execution depends on the game accepting simulated keyboard input.


Support

If this project helped you:

https://buymeacoffee.com/paweldev


License

This project is licensed under the MIT License.

See LICENSE for details.

About

Automatically discovers and solves Gothic 1 Remake lock puzzles. Supports dynamic lock sizes (P1-Pn) and shortest-path solving.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors