summaryrefslogtreecommitdiff
path: root/example.py
diff options
context:
space:
mode:
authorbthink <bthink@fake.com>2026-06-22 13:48:26 +0200
committerbthink <bthink@fake.com>2026-06-22 13:48:26 +0200
commitf026a84a32ace7cff2cb200254353ddf2ac2ff47 (patch)
tree90a1c937c1934810d5cf9c7681018fe36ffc74b6 /example.py
first commit
Diffstat (limited to 'example.py')
-rw-r--r--example.py221
1 files changed, 221 insertions, 0 deletions
diff --git a/example.py b/example.py
new file mode 100644
index 0000000..7fb2dbe
--- /dev/null
+++ b/example.py
@@ -0,0 +1,221 @@
+import gothpick
+
+# example 01
+# scatty's chest in his house
+numOfBlocks = 5
+numOfPins = 7
+initialPositions = {
+0:6,
+1:3,
+2:2,
+3:1,
+4:7
+}
+
+edges = {
+0:[(1,0),(1,3)],
+1:[(1,1),(1,4)],
+2:[(1,2),(-1,4)],
+3:[(1,3),(-1,4),(-1,2),(1,1)],
+4:[(1,4)]
+}
+
+gothpick.PrintInput(initialPositions,edges)
+solvedpath = gothpick.lockpick(numOfBlocks,numOfPins,initialPositions,edges)
+gothpick.TranslateResults(solvedpath,False)
+
+'''
+Gothic 1 Remake - lockpick help
+_______________________________
+step-by-step [y] or complete list [n]? : n
+How many blocks?: 5
+How many pin slots in a block?: 7
+Initial State
+enter initial pin position for block 1: 6
+enter initial pin position for block 2: 3
+enter initial pin position for block 3: 2
+enter initial pin position for block 4: 1
+enter initial pin position for block 5: 7
+connections
+format: comma separated block IDs
+if the connected block moves in opposite direction, prefix with -
+basically positive and negative integers
+enter connections for block 1: 1,4
+enter connections for block 2: 2,5
+enter connections for block 3: 3,-5
+enter connections for block 4: 4,-5,-3,2
+enter connections for block 5: 5
+========SETUP========
+pins
+ 1: 6
+ 2: 3
+ 3: 2
+ 4: 1
+ 5: 7
+connections
+ 1: 1,4
+ 2: 2,5
+ 3: 3,-5
+ 4: 4,-5,-3,2
+ 5: 5
+=====================
+01/31: 3 -> LEFT
+
+02/31: 3 -> LEFT
+
+03/31: 4 -> LEFT
+
+04/31: 1 -> RIGHT
+
+05/31: 3 -> LEFT
+
+06/31: 5 -> LEFT
+
+07/31: 5 -> LEFT
+
+08/31: 2 -> RIGHT
+
+09/31: 4 -> LEFT
+
+10/31: 5 -> LEFT
+
+11/31: 1 -> RIGHT
+
+12/31: 3 -> LEFT
+
+13/31: 5 -> LEFT
+
+14/31: 5 -> LEFT
+
+15/31: 2 -> RIGHT
+
+16/31: 4 -> LEFT
+
+17/31: 5 -> LEFT
+
+18/31: 3 -> LEFT
+
+19/31: 5 -> LEFT
+
+20/31: 5 -> LEFT
+
+21/31: 2 -> RIGHT
+
+22/31: 4 -> LEFT
+
+23/31: 5 -> LEFT
+
+24/31: 3 -> LEFT
+
+25/31: 5 -> LEFT
+
+26/31: 5 -> LEFT
+
+27/31: 2 -> RIGHT
+
+28/31: 4 -> LEFT
+
+29/31: 5 -> LEFT
+
+30/31: 3 -> LEFT
+
+31/31: 5 -> LEFT
+
+Done.
+
+'''
+
+########################################################################
+# example 02
+# guard post above torrez
+numOfBlocks = 5
+numOfPins = 7
+
+initialPositions = {
+0:1,
+1:6,
+2:1,
+3:1,
+4:6
+}
+
+edges = {
+0:[(1,0),(-1,2),(1,3)],
+1:[(1,1),(1,2)],
+2:[(1,2),(1,1),(-1,0)],
+3:[(1,3),(-1,1),(-1,0)],
+4:[(1,4),(1,3),(-1,1)]
+}
+gothpick.PrintInput(initialPositions,edges)
+solvedpath = gothpick.lockpick(numOfBlocks,numOfPins,initialPositions,edges)
+gothpick.TranslateResults(solvedpath,False)
+
+'''
+expected output:
+01/33: 5 -> LEFT
+
+02/33: 2 -> LEFT
+
+03/33: 3 -> RIGHT
+
+04/33: 4 -> LEFT
+
+05/33: 2 -> LEFT
+
+06/33: 3 -> RIGHT
+
+07/33: 2 -> LEFT
+
+08/33: 4 -> LEFT
+
+09/33: 2 -> LEFT
+
+10/33: 3 -> RIGHT
+
+11/33: 2 -> LEFT
+
+12/33: 3 -> RIGHT
+
+13/33: 2 -> LEFT
+
+14/33: 3 -> RIGHT
+
+15/33: 2 -> LEFT
+
+16/33: 4 -> LEFT
+
+17/33: 5 -> RIGHT
+
+18/33: 3 -> RIGHT
+
+19/33: 2 -> LEFT
+
+20/33: 4 -> LEFT
+
+21/33: 5 -> RIGHT
+
+22/33: 3 -> RIGHT
+
+23/33: 2 -> LEFT
+
+24/33: 4 -> LEFT
+
+25/33: 5 -> RIGHT
+
+26/33: 3 -> RIGHT
+
+27/33: 2 -> LEFT
+
+28/33: 4 -> LEFT
+
+29/33: 1 -> RIGHT
+
+30/33: 3 -> RIGHT
+
+31/33: 2 -> LEFT
+
+32/33: 3 -> RIGHT
+
+33/33: 2 -> LEFT
+
+'''