Last active
September 27, 2021 07:24
-
-
Save TheBonnec/67f6d29f6191b3932cbe80e3f7f79aca to your computer and use it in GitHub Desktop.
Echec
This file contains 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
from math import * | |
from kandinsky import * | |
# ---------- Couleurs ---------- | |
black = (0,30,40) | |
gray = (180,180,200) | |
white = (255,255,255) | |
blue = (70,120,180) | |
# ---------- Pions ---------- | |
queenImage = [[0,0,0,1,0,0,0],[0,0,1,1,1,0,0],[0,0,0,1,0,0,0],[1,0,1,1,1,0,1],[2,0,0,7,3]] | |
kingImage = [[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[1,0,0,1,0,0,1],[1,0,1,1,1,0,1],[2,0,0,7,3]] | |
tourImage = [[0,1,0,1,0,1,0],[2,1,0,5,1],[2,2,0,3,3],[2,1,0,5,1],[2,0,0,7,1]] | |
cavalierImage = [[2,2,0,3,1],[2,1,0,6,2],[2,1,0,4,2],[2,1,0,5,1],[2,0,0,7,1]] | |
fouImage = [[2,2,0,3,1],[0,1,0,0,1,1,0],[2,3,0,3,1],[2,2,0,3,2],[2,1,0,5,1],[2,0,0,7,1]] | |
pionImage = [[2,2,0,3,1],[2,1,0,5,1],[2,1,0,5,1],[2,2,0,3,2],[2,1,0,5,1],[2,0,0,7,1]] | |
class Figure: | |
def __init__(self,caseX,caseY,image,color): | |
self.caseX = caseX | |
self.caseY = caseY | |
self.image = image | |
self.color = color | |
pqb = Figure(5,8,queenImage,white) | |
pqn = Figure(5,1,queenImage,black) | |
pkb = Figure(4,8,kingImage,white) | |
pkn = Figure(4,1,kingImage,black) | |
ptb1 = Figure(1,8,tourImage,white) | |
ptb2 = Figure(8,8,tourImage,white) | |
ptn1 = Figure(1,1,tourImage,black) | |
ptn2 = Figure(8,1,tourImage,black) | |
pfb1 = Figure(2,8,fouImage,white) | |
pfb2 = Figure(7,8,fouImage,white) | |
pfn1 = Figure(2,1,fouImage,black) | |
pfn2 = Figure(7,1,fouImage,black) | |
pcb1 = Figure(3,8,cavalierImage,white) | |
pcb2 = Figure(6,8,cavalierImage,white) | |
pcn1 = Figure(3,1,cavalierImage,black) | |
pcn2 = Figure(6,1,cavalierImage,black) | |
ppb1 = Figure(1,7,pionImage,white) | |
ppb2 = Figure(2,7,pionImage,white) | |
ppb3 = Figure(3,7,pionImage,white) | |
ppb4 = Figure(4,7,pionImage,white) | |
ppb5 = Figure(5,7,pionImage,white) | |
ppb6 = Figure(6,7,pionImage,white) | |
ppb7 = Figure(7,7,pionImage,white) | |
ppb8 = Figure(8,7,pionImage,white) | |
ppn1 = Figure(1,2,pionImage,black) | |
ppn2 = Figure(2,2,pionImage,black) | |
ppn3 = Figure(3,2,pionImage,black) | |
ppn4 = Figure(4,2,pionImage,black) | |
ppn5 = Figure(5,2,pionImage,black) | |
ppn6 = Figure(6,2,pionImage,black) | |
ppn7 = Figure(7,2,pionImage,black) | |
ppn8 = Figure(8,2,pionImage,black) | |
figures = [pqb,pqn,pkb,pkn,ptb1,ptb2,ptn1,ptn2,pfb1,pfb2,pfn1,pfn2,pcb1,pcb2,pcn1,pcn2,ppb1,ppb2,ppb3,ppb4,ppb5,ppb6,ppb7,ppb8,ppn1,ppn2,ppn3,ppn4,ppn5,ppn6,ppn7,ppn8] | |
def plateau(): | |
k,l = 0,0 | |
for i in range(8): | |
for j in range(8): | |
fill_rect(10+(27*k), 27*l, | |
27, 27, gray if (l+k)%2 == 0 else blue) | |
k += 1 | |
k = 0 | |
l += 1 | |
def draw(x,y,p,c): | |
#fill_rect(x,y,27,27,gray) | |
x += 3 | |
y += 3 | |
k,l = 0,0 | |
for i in p: | |
for j in i: | |
if j != 2: | |
if j == 1: | |
fill_rect(x+3*l, y+3*k, | |
3,3, c) | |
l += 1 | |
else: | |
fill_rect(x+(3*l)+(i[1]*3), | |
y+(3*k)+(i[2]*3), | |
i[3]*3, i[4]*3, c) | |
k += i[4]-1 | |
break | |
print(k) | |
k += 1 | |
l = 0 | |
plateau() | |
for f in figures: | |
draw(10+f.caseX*27-27 ,f.caseY*27-27, f.image, f.color) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment