added useful functions for tile selection and more
This commit is contained in:
parent
9e978d6032
commit
fb0ec5057c
Binary file not shown.
Binary file not shown.
@ -52,4 +52,11 @@ def get_tile_coordinates(index):
|
||||
tile = tiles[index]
|
||||
return tile.x, tile.y
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
def get_tile_index():
|
||||
valid_indices = []
|
||||
for index, tile in enumerate(tiles):
|
||||
if tile.image=="resources/images/sampling.png":
|
||||
valid_indices.append(index)
|
||||
return random.choice(valid_indices)
|
@ -1,5 +1,7 @@
|
||||
import random
|
||||
import os
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# path to plant images folder (used in randomize_photo function)
|
||||
folder_path = "resources/images/plant_photos"
|
||||
@ -48,4 +50,9 @@ class Tile:
|
||||
self.image = "resources/images/rock_dirt.png"
|
||||
|
||||
|
||||
# DISCLAMER check column and choose plant type ("potato","wheat" etc.)
|
||||
def displayPhoto(self):
|
||||
img = self.photo
|
||||
img = img / 2 + 0.5 # unnormalize
|
||||
npimg = img.numpy()
|
||||
plt.imshow(np.transpose(npimg, (1, 2, 0)))
|
||||
plt.show()
|
||||
|
Loading…
Reference in New Issue
Block a user