diff options
author | Marianne Chevrot <blackmoor+git@devys.org> | 2020-05-05 23:53:46 +0200 |
---|---|---|
committer | Marianne Chevrot <blackmoor+git@devys.org> | 2020-05-05 23:53:46 +0200 |
commit | ae0d3e0ebb4a6f25c705f499faae03c75a9d6e1d (patch) | |
tree | 395c23cf7989052942dbd5a6aa85d1ea8ee45b53 | |
parent | 4e9ad30ac8a1bc35ed2c2548793d70579e30732e (diff) | |
download | kana_quest_solver-ae0d3e0ebb4a6f25c705f499faae03c75a9d6e1d.tar.gz kana_quest_solver-ae0d3e0ebb4a6f25c705f499faae03c75a9d6e1d.tar.bz2 kana_quest_solver-ae0d3e0ebb4a6f25c705f499faae03c75a9d6e1d.zip |
Add fblk = froz empty block
-rw-r--r-- | levels/level_4.16.yaml | 12 | ||||
-rwxr-xr-x | solver.py | 27 |
2 files changed, 29 insertions, 10 deletions
diff --git a/levels/level_4.16.yaml b/levels/level_4.16.yaml new file mode 100644 index 0000000..45cb826 --- /dev/null +++ b/levels/level_4.16.yaml @@ -0,0 +1,12 @@ +# kana quest grid level 1.01 +size: [7, 4] +max_actions: 15 +#max_actions: 16 +target_score: 7 +grid: [ + [empt, null], [empt, null], [empt, null], [empt, null], [empt, null], [empt, null], [froz, 'no'], + [empt, null], [empt, null], [empt, null], [empt, null], [empt, null], [empt, null], [empt, null], + [empt, null], [empt, null], [rock, ni ], [empt, null], [rock, so ], [empt, null], [empt, null], + [fblk, null], [rock, se ], [froz, sa ], [empt, null], [empt, null], [rock, su ], [froz, ne ], +] +# The kana 'no' need to be protected else the program convert it into False... @@ -20,7 +20,7 @@ import yaml class Kana: - types_without_kana = ('void', 'empt') + types_without_kana = ('void', 'empt', 'fblk') types_valid_for_chain = ('norm', 'froz', 'rock', 'ar_u', 'ar_l', 'ar_d', 'ar_r') types_with_kana = types_valid_for_chain + ('myst', ) types_all = types_with_kana + types_without_kana @@ -69,13 +69,14 @@ class KanaGrid: kana1 = self.get_kana(pos1) kana2 = self.get_kana(pos2) table_ok = { - 'norm': ('norm', 'empt', 'froz', 'ar_u', 'ar_r', 'ar_d', 'ar_l'), - 'empt': ('norm', 'froz', 'ar_u', 'ar_r', 'ar_d', 'ar_l'), - 'froz': ('norm', 'empt', 'ar_u', 'ar_r', 'ar_d', 'ar_l'), - 'ar_u': ('norm', 'empt', 'froz', 'ar_d' ), - 'ar_r': ('norm', 'empt', 'froz', 'ar_l'), - 'ar_d': ('norm', 'empt', 'froz', 'ar_u' ), - 'ar_l': ('norm', 'empt', 'froz', 'ar_r' ), + 'norm': ('norm', 'empt', 'froz', 'fblk', 'ar_u', 'ar_r', 'ar_d', 'ar_l'), + 'empt': ('norm', 'froz', 'fblk', 'ar_u', 'ar_r', 'ar_d', 'ar_l'), + 'froz': ('norm', 'empt', 'ar_u', 'ar_r', 'ar_d', 'ar_l'), + 'fblk': ('norm', 'empt', 'ar_u', 'ar_r', 'ar_d', 'ar_l'), + 'ar_u': ('norm', 'empt', 'froz', 'fblk', 'ar_d' ), + 'ar_r': ('norm', 'empt', 'froz', 'fblk', 'ar_l'), + 'ar_d': ('norm', 'empt', 'froz', 'fblk', 'ar_u' ), + 'ar_l': ('norm', 'empt', 'froz', 'fblk', 'ar_r' ), } if kana1.type_name in table_ok: if kana2.type_name in table_ok[kana1.type_name]: @@ -189,7 +190,7 @@ class KanaGrid: def swap_kana(self, pos1, pos2): kana_dst = self.get_kana(pos2) - if kana_dst.type_name == 'froz': + if kana_dst.type_name in ('froz', 'fblk'): pos_tmp = pos1 pos1 = pos2 pos2 = pos_tmp @@ -206,7 +207,7 @@ class KanaGrid: self.set_kana(pos_src, kana_dst) self.set_kana(pos_dst, kana_src) - if kana_src.type_name != 'froz': + if kana_src.type_name not in ('froz', 'fblk') : break pos_src = pos_dst @@ -248,6 +249,7 @@ def repr_grid(grid, grid_size): 'ar_d': ('\x1b[30m∨\x1b[0m', '\x1b[30m∨\x1b[0m'), 'ar_l': ('\x1b[30m<\x1b[0m', '\x1b[30m<\x1b[0m'), 'froz': (' \x1b[36m', '\x1b[0m '), + 'fblk': (' \x1b[36m[]', '\x1b[0m '), 'rock': (' \x1b[1;40m', '\x1b[0m '), 'myst': ('\x1b[33m?', '?\x1b[0m'), } @@ -262,6 +264,11 @@ def repr_grid(grid, grid_size): line += ' ' elif tname == 'empt': line += '| |' + elif tname == 'fblk': + line += '|%s%s|' % ( + indicator_map[tname][0], + indicator_map[tname][1], + ) elif tname in indicator_map: line += '|%s%s%s|' % ( indicator_map[tname][0], |