Symetries.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. ##############
  2. # Barriere : #
  3. ##############
  4. def barriere_symetrie_verticale(plateau, barriere) :
  5. sym = barriere.copie()
  6. sym.x = plateau.lg - 2 - sym.x
  7. return sym
  8. def barriere_symetrie_horizontale(plateau, barriere) :
  9. sym = barriere.copie()
  10. sym.y = plateau.ht - 2 - sym.y
  11. return sym
  12. ##########
  13. # Coup : #
  14. ##########
  15. def coup_symetrie_verticale(plateau, coup) :
  16. sym = coup.copie()
  17. if sym.type == "M" :
  18. (x,y) = sym.case
  19. sym.case = (x, plateau.lg - 1 - y)
  20. else :
  21. sym.barriere = barriere_symetrie_verticale(plateau, sym.barriere)
  22. return sym
  23. def coup_symetrie_horizontale(plateau, coup) :
  24. sym = coup.copie()
  25. if sym.type == "M" :
  26. (x,y) = sym.case
  27. sym.case = (x, plateau.ht - 1 - y)
  28. else :
  29. sym.barriere = barriere_symetrie_horizontale(plateau, sym.barriere)
  30. return sym
  31. #############
  32. # Plateau : #
  33. #############
  34. def plateau_symetrie_verticale(plateau) :
  35. sym = plateau.copie_complete()
  36. for i in range(2) :
  37. sym.pions[i][0] = sym.lg - 1 - sym.pions[i][0]
  38. for b in sym.liste_barrieres :
  39. b.x = sym.lg - 2 - b.x
  40. return sym
  41. def plateau_symetrie_horizontale(plateau) :
  42. sym = plateau.copie_complete()
  43. (sym.barrieres_restantes[1], sym.barrieres_restantes[0]) = (sym.barrieres_restantes[0], sym.barrieres_restantes[1])
  44. sym.tour = 1 - sym.tour
  45. for num in (0,1) :
  46. sym.barrieres_restantes[num] = plateau.barrieres_restantes[1 - num]
  47. sym.pions[num][0] = plateau.pions[1 - num][0]
  48. sym.pions[num][1] = sym.ht - 1 - plateau.pions[1 - num][1]
  49. for b in sym.liste_barrieres :
  50. b.y = sym.ht - 2 - b.y
  51. return sym