diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index f60fa15..0603b9a 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -64,6 +64,16 @@ diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 3e3115e..6b6ecd2 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,7 +4,6 @@ - @@ -21,32 +20,12 @@ - - - - - - - - - - - - - - - - - + + - - - - - - - - + + + @@ -54,75 +33,41 @@ - - + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - + + + - - + + - - + + - - - - - + @@ -167,10 +112,11 @@ @@ -214,6 +160,7 @@ + @@ -256,7 +203,6 @@ - @@ -306,53 +252,53 @@ @@ -588,26 +534,6 @@ - - - - - - - - - - - - - - - - - - - - @@ -633,12 +559,6 @@ - - - - - - @@ -674,12 +594,6 @@ - - - - - - @@ -701,12 +615,6 @@ - - - - - - @@ -721,12 +629,6 @@ - - - - - - @@ -928,99 +830,68 @@ + + + + + + + + + + + + + + - + - - - - - - - - + - - - - - - - - + + + - + - - - - - - - - + + + - + - - + + - - - - - - - - - - - - - - - - - - - - + - - + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + diff --git a/IA/IrisIA.py b/IA/IrisIA.py index 42776b8..24f9d82 100644 --- a/IA/IrisIA.py +++ b/IA/IrisIA.py @@ -10,7 +10,7 @@ # ######################################################## -from random import randrange +import random import time from Environnement.pivot import Pivot @@ -26,9 +26,31 @@ class IrisIA(object): defenseDico = {} onePointDico = {} twoPointDico = {} + randomList = [] + randomListX = [] + randomListY = [] +#540 +#630 def __init__(self,color): self.color = color + self.makeRandomList() + + def makeRandomList(self): + x = 30 + while x<630 : + y = 30 + while y<540 : + coord = str(str(x)+'_'+str(y)) + self.randomList.append(coord) + y = y + 30 + + x = x + 30 + + + def updateRandomList(self,coord): + self.randomList.remove(coord) + def buildDico(self,dico,point_dico,space,attack): #Parcourt le dictionnaire @@ -137,24 +159,12 @@ def canBuild(self): def randPoint(self,can,point_dico): r = 5 - boucle = True - while boucle: - - y = randrange(30, (540 - 30)) - yMod = y % 30 - x = randrange(30, (630 - 30)) - xMod = x % 30 - - point = str(str(x)+'_'+str(y)) - - if (yMod) | (xMod): - boucle = True - else: - if point in point_dico: - boucle = True - else: - boucle = False + secure_random = random.SystemRandom() + coord = secure_random.choice(self.randomList) + array = coord.split('_') + x = int(array[0]) + y = int(array[1]) can.create_oval(x-r, y-r, x+r, y+r, fill=self.getColor()) diff --git a/IA/__pycache__/IrisIA.cpython-35.pyc b/IA/__pycache__/IrisIA.cpython-35.pyc index 0ef4a6f..c1a8f9f 100644 Binary files a/IA/__pycache__/IrisIA.cpython-35.pyc and b/IA/__pycache__/IrisIA.cpython-35.pyc differ diff --git a/IA/__pycache__/irisCpIA.cpython-35.pyc b/IA/__pycache__/irisCpIA.cpython-35.pyc index c67af2e..f772366 100644 Binary files a/IA/__pycache__/irisCpIA.cpython-35.pyc and b/IA/__pycache__/irisCpIA.cpython-35.pyc differ diff --git a/test.py b/test.py new file mode 100644 index 0000000..61e45f3 --- /dev/null +++ b/test.py @@ -0,0 +1,5 @@ +import random + +foo = ['battery', 'correct', 'horse', 'staple'] +secure_random = random.SystemRandom() +print(secure_random.choice(foo)) diff --git a/vsCpIris.py b/vsCpIris.py index b966343..bc7f681 100644 --- a/vsCpIris.py +++ b/vsCpIris.py @@ -137,6 +137,7 @@ def point(event): makeCarre(event.x,event.y) P2.setOtherDico(value,current_p.getColor()) + P2.updateRandomList(value) global current_p current_p = P2 @@ -203,6 +204,7 @@ def IAtour(): #Enregistrer les cordonnées de l'IA dans son dico P2.setOwnDico(coord) + P2.updateRandomList(coord) #Tentative de faire un carré si possible makeCarre(x,y)