Skip to content

Commit

Permalink
Réglage du Bug lier à la génération de point lors de la fin du jeu
Browse files Browse the repository at this point in the history
  • Loading branch information
gabeta committed Jul 13, 2017
1 parent ab9d799 commit a607b8b
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 233 deletions.
10 changes: 10 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

301 changes: 86 additions & 215 deletions .idea/workspace.xml

Large diffs are not rendered by default.

46 changes: 28 additions & 18 deletions IA/IrisIA.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
########################################################

from random import randrange
import random
import time

from Environnement.pivot import Pivot
Expand All @@ -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
Expand Down Expand Up @@ -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())

Expand Down
Binary file modified IA/__pycache__/IrisIA.cpython-35.pyc
Binary file not shown.
Binary file modified IA/__pycache__/irisCpIA.cpython-35.pyc
Binary file not shown.
5 changes: 5 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import random

foo = ['battery', 'correct', 'horse', 'staple']
secure_random = random.SystemRandom()
print(secure_random.choice(foo))
2 changes: 2 additions & 0 deletions vsCpIris.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a607b8b

Please sign in to comment.