diff --git a/.idea/Traktor AI.iml b/.idea/Traktor AI.iml
index d9e6024..078ddf5 100644
--- a/.idea/Traktor AI.iml
+++ b/.idea/Traktor AI.iml
@@ -1,8 +1,10 @@
-
-
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 8d93904..6c75bb3 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/source/__pycache__/crop_protection_product.cpython-311.pyc b/source/__pycache__/crop_protection_product.cpython-311.pyc
new file mode 100644
index 0000000..d4e10b4
Binary files /dev/null and b/source/__pycache__/crop_protection_product.cpython-311.pyc differ
diff --git a/source/__pycache__/ground.cpython-311.pyc b/source/__pycache__/ground.cpython-311.pyc
new file mode 100644
index 0000000..440582a
Binary files /dev/null and b/source/__pycache__/ground.cpython-311.pyc differ
diff --git a/source/__pycache__/plant.cpython-311.pyc b/source/__pycache__/plant.cpython-311.pyc
new file mode 100644
index 0000000..4dca0be
Binary files /dev/null and b/source/__pycache__/plant.cpython-311.pyc differ
diff --git a/source/__pycache__/tile.cpython-311.pyc b/source/__pycache__/tile.cpython-311.pyc
index 2a1b0b4..afdea50 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__/__init__.cpython-311.pyc b/source/area/__pycache__/__init__.cpython-311.pyc
index ff938c7..a319c59 100644
Binary files a/source/area/__pycache__/__init__.cpython-311.pyc and b/source/area/__pycache__/__init__.cpython-311.pyc differ
diff --git a/source/area/__pycache__/constants.cpython-311.pyc b/source/area/__pycache__/constants.cpython-311.pyc
index 78daa34..fc5dca7 100644
Binary files a/source/area/__pycache__/constants.cpython-311.pyc and b/source/area/__pycache__/constants.cpython-311.pyc differ
diff --git a/source/area/__pycache__/field.cpython-311.pyc b/source/area/__pycache__/field.cpython-311.pyc
index 6fc2201..e78f0fe 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/__pycache__/tractor.cpython-311.pyc b/source/area/__pycache__/tractor.cpython-311.pyc
index 14524f3..d57462a 100644
Binary files a/source/area/__pycache__/tractor.cpython-311.pyc and b/source/area/__pycache__/tractor.cpython-311.pyc differ
diff --git a/source/area/constants.py b/source/area/constants.py
index 99a9fcd..1aff5be 100644
--- a/source/area/constants.py
+++ b/source/area/constants.py
@@ -3,7 +3,7 @@ import pygame
WIDTH, HEIGHT = 1000, 1000
FIELD_WIDTH, FIELD_HEIGHT = 660, 330
-ROWS, COLS = 10, 5
+ROWS, COLS = 20, 20
# number of tiles in a row and column
TILE_SIZE = FIELD_WIDTH//ROWS
PLANT = ""
diff --git a/source/area/field.py b/source/area/field.py
index a17e679..99f57bd 100644
--- a/source/area/field.py
+++ b/source/area/field.py
@@ -21,10 +21,9 @@ def positionFieldElements():
tractor.y += fieldY
def createTiles():
- for y in range (0,COLS):
- for x in range (0,ROWS):
+ for y in range(0, COLS):
+ for x in range(0, ROWS):
tile = Tile(x*TILE_SIZE, y*TILE_SIZE)
- tile.randomize_photo()
tile.randomizeContent()
tiles.append(tile)
positionFieldElements()
diff --git a/source/area/tractor.py b/source/area/tractor.py
index 5e1c355..dc27ee8 100644
--- a/source/area/tractor.py
+++ b/source/area/tractor.py
@@ -1,9 +1,60 @@
+from crop_protection_product import CropProtectionProduct
+
+
class Tractor:
x = None
y = None
image = None
+ cypermetryna = CropProtectionProduct("pests", "cereal")
+ diflufenikan = CropProtectionProduct("weeds", "cereal")
+ spirotetramat = CropProtectionProduct("pests", "fruit")
+ oksadiargyl = CropProtectionProduct("weeds", "fruit")
+ spinosad = CropProtectionProduct("pests", "vegetable")
+ metazachlor = CropProtectionProduct("weeds", "vegetable")
# etc
- def __init__(self,x,y):
+
+ def __init__(self, x, y):
self.x = x
self.y = y
self.image = 'resources/images/tractor.png'
+
+ def work_on_field(self, tile, ground, plant1):
+ if plant1 is None:
+ tile.randomizeContent()
+ # sprobuj zasadzic cos
+ print("Tarctor planted something")
+ elif plant1.growth_level == 100:
+ tile.plant = None
+ ground.nutrients_level -= 40
+ ground.water_level -= 40
+ print("Tractor collected something")
+ else:
+ plant1.try_to_grow(50,50) #mozna dostosowac jeszcze
+ ground.nutrients_level -= 11
+ ground.water_level -= 11
+ if ground.pest:
+ # traktor pozbywa sie szkodnikow
+ if plant1.plant_type == self.cypermetryna.plant_type:
+ t = "Tractor used Cypermetryna"
+ elif plant1.plant_type == self.spirotetramat.plant_type:
+ t = "Tractor used Spirotetramat"
+ elif plant1.plant_type == self.spinosad.plant_type:
+ t = "Tractor used Spinosad"
+ print(t)
+ ground.pest = False
+ if ground.weed:
+ # traktor pozbywa się chwastow
+ if plant1.plant_type == self.diflufenikan.plant_type:
+ t = "Tractor used Diflufenikan"
+ elif plant1.plant_type == self.oksadiargyl.plant_type:
+ t = "Tractor used Oksadiargyl"
+ elif plant1.plant_type == self.metazachlor.plant_type:
+ t = "Tractor used Metazachlor"
+ print(t)
+ ground.weed = False
+ if ground.water_level < plant1.water_requirements:
+ ground.water_level += 20
+ print("Tractor watered the plant")
+ if ground.nutrients_level < plant1.nutrients_requirements:
+ ground.nutrients_level += 20
+ print("Tractor added some nutrients")
diff --git a/source/crop_protection_product.py b/source/crop_protection_product.py
new file mode 100644
index 0000000..448591b
--- /dev/null
+++ b/source/crop_protection_product.py
@@ -0,0 +1,4 @@
+class CropProtectionProduct:
+ def __init__(self, strong_against, plant_type):
+ self.strong_against = strong_against # pestycyd, herbicyd
+ self.plant_type = plant_type
diff --git a/source/ground.py b/source/ground.py
index a564c4c..ccd1292 100644
--- a/source/ground.py
+++ b/source/ground.py
@@ -1,6 +1,26 @@
+import random
+
+
class Dirt:
- state = None
+ def __init__(self, water_level, nutrients_level):
+ self.water_level = water_level
+ self.nutrients_level = nutrients_level
+ self.pest = False
+ self.weed = False
+ self.obstacle = False
+ self.pests_and_weeds()
# add a couple new properties
-# add init, getters,setters
+ def pests_and_weeds(self):
+ i = random.randint(1, 20) # 5% szans na szkodniki, 10% na chwasty, 5 na obydwa 15 na kamien
+ if i == 1:
+ self.pest = True
+ elif i == 2 or i == 3:
+ self.weed = True
+ elif i == 4:
+ self.weed = True
+ self.pest = True
+ elif i == 5 or i == 6 or i == 7:
+ self.obstacle = True
+# add init, getters,setters
diff --git a/source/main.py b/source/main.py
index 3361f3a..2dac1b5 100644
--- a/source/main.py
+++ b/source/main.py
@@ -1,7 +1,13 @@
import pygame
+import time
+import random
from area.constants import WIDTH, HEIGHT
from area.field import drawWindow
+from area.tractor import Tractor
+from area.field import tiles
+from ground import Dirt
+from plant import Plant
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption('Intelligent tractor')
@@ -15,6 +21,19 @@ def main():
if event.type == pygame.QUIT:
run = False
+ #small test:
+ time.sleep(2)
+ tile1 = tiles[0]
+ p1 = Plant('wheat', 'cereal', random.randint(1,100), random.randint(1,100), random.randint(1,100))
+ d1 = Dirt(random.randint(1, 100), random.randint(1,100))
+ d1.pests_and_weeds()
+ tile1.ground=d1
+ t1 = Tractor(10, 10)
+ t1.work_on_field(tile1, d1, p1)
+ time.sleep(3)
+ print("\n")
+
+
# in loop move tractor
main()
diff --git a/source/plant.py b/source/plant.py
index 39f1a6c..0072b54 100644
--- a/source/plant.py
+++ b/source/plant.py
@@ -1,8 +1,25 @@
+import random
+
class Plant:
- name = None
+ def __init__(self, name, plant_type, water_requirements, nutrients_requirements, growth_level):
+ self.name = name
+ self.plant_type = plant_type
+ self.water_requirements = water_requirements
+ self.nutrients_requirements = nutrients_requirements
+ self.growth_level = growth_level
+
+ def try_to_grow(self, water, nutrients):
+ if (water >= self.water_requirements) and (nutrients >= self.nutrients_requirements):
+ i = random.randint(5, 12)
+ if self.growth_level+i > 100:
+ i = 100 - self.growth_level
+ self.growth_level += i
+ print("The plant is growing")
+ else:
+ print("Unable to grow due to bad condition of the ground")
+
# more properties
# add init, getters,setters
-
diff --git a/source/tile.py b/source/tile.py
index 1971f7f..aa2ca51 100644
--- a/source/tile.py
+++ b/source/tile.py
@@ -1,7 +1,7 @@
import random
import os
-#path to plant images folder (used in randomize_photo function)
+# path to plant images folder (used in randomize_photo function)
folder_path = "resources\images\plant_photos"
@@ -26,7 +26,7 @@ class Tile:
# called on a created tile
- #choose random photo from the folder:
+ # choose random photo from the folder:
def randomize_photo(self):
random_photo = random.choice(os.listdir(folder_path))
@@ -35,14 +35,13 @@ class Tile:
def randomizeContent(self):
photo_path = self.randomize_photo()
- i = random.randint(1, 3) #szansa 1/3
+ i = random.randint(1, 3) # szansa 1/3
if i == 1:
self.image = "resources/images/sampling.png"
self.photo = photo_path
- #self.photo losuje dodatkowo zdjecie jakies rosliny do danego rzędu
+ # self.photo losuje dodatkowo zdjecie jakies rosliny do danego rzędu
else:
self.image = "resources/images/dirt.png"
self.photo = "resources/images/background.jpg"
-# DISCLAMER check column and choose plant type ("potato","wheat" etc)
-
+# DISCLAMER check column and choose plant type ("potato","wheat" etc.)