Add randomly change the plate from full to empty

This commit is contained in:
s450026 2020-06-09 15:06:03 +02:00
parent 35d84146d9
commit 14299fbe63
14 changed files with 34 additions and 12 deletions

16
main.py
View File

@ -51,7 +51,17 @@ if __name__ == "__main__":
[9, 3], [9, 6], [9, 9], [11, 3], [11, 8]]
plateArr = []
def changePlate():
if plateArr and len(plateArr) > 0:
if randrange(30) == 17:
plate = random.choice(plateArr)
if not plate.empty:
randomPlate = randrange(5)+10
plate.changePlate('plate-empty.png', 'test-{}'.format(randomPlate))
while True:
changePlate()
for event in pygame.event.get():
# rabbit.check(waiter.matrix, waiter.X, waiter.Y)
@ -87,7 +97,7 @@ if __name__ == "__main__":
rand = randrange(9)
# if this plate is exists
print('check{}{}{}'.format(plateArr, len(plateArr), rand))
print(rand)
if plateArr and len(plateArr) >= rand and plateArr[rand] in plateArr:
randGo = rand
goal = (plateArr[randGo].table[0], plateArr[randGo].table[1])
@ -117,11 +127,15 @@ if __name__ == "__main__":
path = waiter.translatePath(path)
print('sec-2')
go = 1
else:
if plateArr[randGo].checked:
predict = 'CHECKED'
else:
predict = use_model_to_predict(plateArr[randGo].pictureAI)
if predict == 1:
predict = 'EMPTY'
plateArr[randGo].checkPlate()
else:
predict = 'FOOD'
print('sec-3')

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 857 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

@ -80,10 +80,12 @@ class Graphics:
def drawFullPlate(self, x, y, picture):
self.screen.blit(pygame.image.load(relative_path + picture),
(x * self.block_size, y * self.block_size))
def drawEmptyPlate(self, x, y):
def drawEmptyPlate(self, x, y, picture):
self.screen.blit(self.image['floor'],
(x * self.block_size, y * self.block_size))
self.screen.blit(self.image['table'],
(x * self.block_size, y * self.block_size))
self.screen.blit(self.image['plate-full'],
self.screen.blit(pygame.image.load(relative_path + picture),
(x * self.block_size, y * self.block_size))
def clearPlate(self, x, y):
self.screen.blit(self.image['table'],

View File

@ -1,13 +1,19 @@
class Plate:
def __init__(self, graphics, plate, table, picture, pictureAI):
self.plate = plate
self.table = table
self.picture = picture
self.pictureAI = pictureAI
self.graphics = graphics
self.empty = False
self.checked = False
graphics.drawFullPlate(self.plate[0], self.plate[1], picture)
def changePlate(self, newPicture, newPictureAI):
self.graphics.drawEmptyPlate(self.plate[0], self.plate[1], newPicture)
self.picture = newPicture
self.pictureAI = newPictureAI
self.empty = True
def changePlate(self):
print('keep')
def checkPlate(self):
self.checked = True