diff --git a/source/__pycache__/tile.cpython-311.pyc b/source/__pycache__/tile.cpython-311.pyc index a51e17d..c5f25ec 100644 Binary files a/source/__pycache__/tile.cpython-311.pyc and b/source/__pycache__/tile.cpython-311.pyc differ diff --git a/source/area/__pycache__/field.cpython-311.pyc b/source/area/__pycache__/field.cpython-311.pyc index 8d3ebef..5ce4b04 100644 Binary files a/source/area/__pycache__/field.cpython-311.pyc and b/source/area/__pycache__/field.cpython-311.pyc differ diff --git a/source/area/field.py b/source/area/field.py index 89ddba9..25c1c7b 100644 --- a/source/area/field.py +++ b/source/area/field.py @@ -52,4 +52,11 @@ def get_tile_coordinates(index): tile = tiles[index] return tile.x, tile.y else: - return None \ No newline at end of file + 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) \ No newline at end of file diff --git a/source/tile.py b/source/tile.py index 654f59b..9d2a815 100644 --- a/source/tile.py +++ b/source/tile.py @@ -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()