Created
September 14, 2025 02:38
-
-
Save shuantsu/6fc86fae9c771416fb25d9ff06e89940 to your computer and use it in GitHub Desktop.
encode script
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
| import random | |
| import time | |
| import pprint | |
| import json | |
| bp = json.load(open('bp.json')) | |
| def decode(i): | |
| l = [] | |
| [l.extend(o[1::2]) for o in i.split(':')] | |
| return l | |
| def encode(l): | |
| groups = ':'.join([''.join(['c'+str(k) for k in l[i:i+4]]) for i in range(0, len(l), 4)]) | |
| return groups | |
| island1 = bp['BP']['Entries'][0]['B']['Entries'] | |
| island2 = bp['BP']['Entries'][1]['B']['Entries'] | |
| island3 = bp['BP']['Entries'][2]['B']['Entries'] | |
| island4 = bp['BP']['Entries'][3]['B']['Entries'] | |
| island1 = [[n,decode(i)] for n,i in [[n,i.get('C-decoded')] for n,i in enumerate(island1)] if i] | |
| island2 = [[n,decode(i)] for n,i in [[n,i.get('C-decoded')] for n,i in enumerate(island2)] if i] | |
| island3 = [[n,decode(i)] for n,i in [[n,i.get('C-decoded')] for n,i in enumerate(island3)] if i] | |
| island4 = [[n,decode(i)] for n,i in [[n,i.get('C-decoded')] for n,i in enumerate(island4)] if i] | |
| tiles = [island1,island2,island3,island4] | |
| def get_val(idx): | |
| island_index, b = divmod(idx,192) | |
| col, cell = divmod(b, 16) | |
| return tiles[island_index][col][1][cell] | |
| def set_val(idx, val): | |
| global tiles | |
| island_index, b = divmod(idx,192) | |
| col, cell = divmod(b, 16) | |
| tiles[island_index][col][1][cell] = val | |
| ii = 0 | |
| colors = 'rrrrrrrrrrrrrrrrggggggggbbbb' | |
| for x in range(48): | |
| [set_val(i,random.choice(colors)) for i in range((x*16),(x*16)+16)] | |
| _island1 = [[n,encode(i)] for n,i in island1] | |
| _island2 = [[n,encode(i)] for n,i in island2] | |
| _island3 = [[n,encode(i)] for n,i in island3] | |
| _island4 = [[n,encode(i)] for n,i in island4] | |
| _tiles = [_island1,_island2,_island3,_island4] | |
| for n,_t in enumerate(_tiles): | |
| for nn,o in _t: | |
| bp['BP']['Entries'][n]['B']['Entries'][nn]['C-decoded'] = o | |
| # print(bp['BP']['Entries'][n]['B']['Entries'][nn]['C-decoded']) | |
| # print(n,nn,o) | |
| json.dump(bp, open(f'output-{time.time()}.json','w',encoding='utf8')) | |
| print('ok') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment