|
import pygame |
|
import sys |
|
|
|
y = 0 |
|
|
|
H = 15 |
|
W = 14 |
|
|
|
bo = [[(10 if y == 0 or x == 0 or x == W - 1 else 0) for x in range(W)] for y in range(H)] |
|
|
|
|
|
# puyos = [[(i)%4+1,(i+1)%4+1] for i in range(100)] |
|
|
|
def load_v2(fn): |
|
v = open(fn,'rb').read() |
|
if b'Wrong' in v: |
|
v = v.split(b'W')[0] |
|
def tt(x): |
|
return (x[0],x[1]) |
|
return [tt(v[i*2:][:2]) for i in range(len(v)//2)] |
|
|
|
|
|
def main(): |
|
puyos = load_v2('opuyo') |
|
puyos = load_v2('remote_o2') |
|
puyos += [(0,0) for _ in range(1000)] |
|
# ihs = load_v2('ihs') |
|
|
|
# (cat save_3; python -c "print(b'\x00'*100)") | nc reaction.seccon.games 5000 |
|
ihs = load_v2('save_4') |
|
ihs = [(x+1,d) for x,d in ihs] # XXX:!! |
|
|
|
my_hands = [] |
|
|
|
pygame.init() |
|
screen = pygame.display.set_mode((800, 800)) |
|
font = pygame.font.SysFont(None, 50) |
|
|
|
cs = { |
|
0: " ", |
|
1: "R", |
|
2: "G", |
|
3: "B", |
|
4: "Y", |
|
10: "X" |
|
} |
|
|
|
cs = {k: font.render(s,True, |
|
(255,0,0) if s == "R" else |
|
(0,255,0) if s == "G" else |
|
(0,0,255) if s == "B" else |
|
(255,255,0) if s == "Y" else |
|
(255,255,255) |
|
) for k,s in cs.items()} |
|
|
|
dx, dd = 1,0 |
|
ds = [(-1,0),(0,1),(1,0),(0,-1)] |
|
|
|
def get_d2p(): |
|
ddy,ddx = ds[dd] |
|
tx = dx |
|
if ddx == -1: |
|
tx += 1 |
|
return [ |
|
(H-2, tx), |
|
(H-2+ddy,tx+ddx) |
|
] |
|
|
|
running = True |
|
nps = puyos |
|
dx,dd = ihs[0] |
|
|
|
while running: |
|
screen.fill((0,0,0)) |
|
|
|
for y in range(H): |
|
for x in range(W): |
|
screen.blit(cs[bo[y][x]], (x*30,(H-y+1)*30)) |
|
|
|
ofs = get_d2p() |
|
screen.blit(cs[nps[0][0]], (ofs[0][1]*30,(H-ofs[0][0]+1)*30)) |
|
screen.blit(cs[nps[0][1]], (ofs[1][1]*30,(H-ofs[1][0]+1)*30)) |
|
|
|
for i in range(20): |
|
for j in range(2): |
|
screen.blit(cs[nps[1:][i][j]], (i*30,j*30+700)) |
|
|
|
|
|
|
|
pygame.display.update() |
|
|
|
for event in pygame.event.get(): |
|
if event.type == pygame.QUIT: |
|
running = False |
|
pygame.quit() |
|
|
|
elif event.type == pygame.KEYDOWN: |
|
if event.key == pygame.K_w: |
|
wh = [(x-1,d) for x,d in my_hands] |
|
# XXX: ! |
|
open('gen_h','wb').write(b''.join(bytes(v) for v in wh)) |
|
print("Wrote") |
|
if event.key == pygame.K_LEFT: |
|
dx = max(dx-1,1) |
|
elif event.key == pygame.K_RIGHT: |
|
ddx = ds[dd][1] |
|
dx = min(dx+1,W-2-(0 if ddx == 0 else 1)) |
|
elif event.key == pygame.K_UP: |
|
ddx = ds[dd][1] |
|
if ddx == 0 and dx == W-2: |
|
continue |
|
dd = (dd + 1) % 4 |
|
if event.key == pygame.K_DOWN: |
|
np = nps[0] |
|
nps = nps[1:] |
|
|
|
my_hands.append((dx,dd)) |
|
ofs = get_d2p() |
|
bo[ofs[0][0]][ofs[0][1]] = np[0] |
|
bo[ofs[1][0]][ofs[1][1]] = np[1] |
|
|
|
for x in range(W): |
|
mo = True |
|
while mo: |
|
y = 0 |
|
mo = False |
|
for y in range(H-1): |
|
if bo[y][x] == 0 and bo[y+1][x] != 0: |
|
bo[y][x] = bo[y+1][x] |
|
bo[y+1][x] = 0 |
|
mo = True |
|
|
|
|
|
ihs = ihs[1:] |
|
if len(ihs) > 0: |
|
dx,dd = ihs[0] |
|
else: |
|
dx,dd = 0,0 |
|
|
|
main() |