カタン、Pythonでは?―― トークンの位置、強引に

強引にやろう。要素一つずつならできるかもしれない。配列をフラットにして、ひとつひとつintにして、改めてリストにして、配列にして、形を整える。

import numpy as np

tile12 = np.load('tileA.npy')

tt24 = np.array([0,60])
tt25 = tile12[:,0,:]
tt26 = tt25+tt24
tt27 = tt26.flatten()
tt28 = [ ]

for ii in tt27:
    iii = int(ii)
    tt28.append(iii)

tt29 = np.array(tt28)
tt30 = tt29.reshape(19,2)
    
print(tt30)
||< 

ほとんど、いや、完全にアホみたいな作業だが、まあいい。なんとかできた。

>|python|
import numpy as np
import pygame

tile12 = np.load('tileA.npy')
tile2 = np.loadtxt(fname='dataC.csv', dtype=float, delimiter=",", skiprows=1)

tt24 = np.array([0,60])
tt25 = tile12[:,0,:]
tt26 = tt25+tt24

gray = (237, 237, 237)
white = (255, 255, 255)

pygame.init()
screen = pygame.display.set_mode((1280, 720))
myclock = pygame.time.Clock()
screen.fill(gray)

np.random.shuffle(tile2)

for hec, token in zip(tile12, tile2):
    poslist = hec
    tok1 = token
    pygame.draw.polygon(screen, tok1, poslist)

    
tt24 = np.array([0,60])
tt25 = tile12[:,0,:]
tt26 = tt25+tt24
tt27 = tt26.flatten()
tt28 = [ ]

for ii in tt27:
    iii = int(ii)
    tt28.append(iii)

tt29 = np.array(tt28)
tt30 = tt29.reshape(19,2)

for tok2 in tt30:
    pygame.draw.circle(screen, white, tok2, 20)
    
pygame.display.flip()
endflag = 0
    
while endflag ==0:
    for event in pygame.event.get():
        if event.type == pygame.QUIT: endflag = 1
    myclock.tick(60)
    
pygame.quit()

f:id:chamcham5628:20201005000812p:plain

しかし、〇の位置がずれてる。
それ以上に、ド素人から見てもはっきりわかる、美しさのかけらもないコードだ。