m4rzus

du_1_12

Dec 4th, 2015
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.48 KB | None | 0 0
  1. __author__ = 'marzus'
  2.  
  3. from random import randrange
  4.  
  5. def creator():
  6.     matica = []
  7.     for i in range(0,8):
  8.         riadok = []
  9.         for j in range(8):
  10.             riadok.append(False)
  11.         matica.append(riadok)
  12.     return matica
  13.  
  14. matica = creator()
  15.  
  16. def randomPosition():
  17.     randomPositions = []
  18.     for i in range(2):
  19.         randomPosition1 = randrange(0,8)
  20.         randomPosition2 = randrange(0,8)
  21.         randomPositions.append(randomPosition1)
  22.         randomPositions.append(randomPosition2)
  23.     matica[randomPosition1][randomPosition2] = True
  24.     return randomPositions
  25.  
  26. positions = randomPosition()
  27.  
  28. """funguje"""
  29.  
  30. def danger():
  31.     randomPosition1_1 = positions[0]
  32.     randomPosition1_2 = positions[1]
  33.     randomPosition2_1 = positions[2]
  34.     randomPosition2_2 = positions[3]
  35.     s = randomPosition1_1 + randomPosition1_2
  36.     d = randomPosition2_1 + randomPosition2_2
  37.     f = randomPosition1_1 - randomPosition1_2
  38.     g = randomPosition2_1 - randomPosition2_2
  39.     print("_Positions_", "\n", randomPosition1_1, "x", randomPosition1_2, "\n", randomPosition2_1, "x", randomPosition2_2, "\n")
  40.     if randomPosition1_1 == randomPosition2_1:
  41.         print(True)
  42.     elif randomPosition1_2 == randomPosition2_2:
  43.         print(True)
  44.     elif randomPosition1_1 == randomPosition1_2 and randomPosition2_1 == randomPosition2_2:
  45.         print(True)
  46.     elif s == d:
  47.         print(True)
  48.     elif f == g:
  49.         print(True)
  50.     else:
  51.         print(False)
  52.  
  53. danger()
Advertisement
Add Comment
Please, Sign In to add comment