Reprezentacja_wiedzy #1
@ -1,8 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module type="PYTHON_MODULE" version="4">
|
<module type="PYTHON_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$" />
|
<content url="file://$MODULE_DIR$">
|
||||||
<orderEntry type="inheritedJdk" />
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.10 (Traktor)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (Traktor)" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
BIN
source/__pycache__/crop_protection_product.cpython-311.pyc
Normal file
BIN
source/__pycache__/crop_protection_product.cpython-311.pyc
Normal file
Binary file not shown.
BIN
source/__pycache__/ground.cpython-311.pyc
Normal file
BIN
source/__pycache__/ground.cpython-311.pyc
Normal file
Binary file not shown.
BIN
source/__pycache__/plant.cpython-311.pyc
Normal file
BIN
source/__pycache__/plant.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -3,7 +3,7 @@ import pygame
|
|||||||
|
|
||||||
WIDTH, HEIGHT = 1000, 1000
|
WIDTH, HEIGHT = 1000, 1000
|
||||||
FIELD_WIDTH, FIELD_HEIGHT = 660, 330
|
FIELD_WIDTH, FIELD_HEIGHT = 660, 330
|
||||||
ROWS, COLS = 10, 5
|
ROWS, COLS = 20, 20
|
||||||
# number of tiles in a row and column
|
# number of tiles in a row and column
|
||||||
TILE_SIZE = FIELD_WIDTH//ROWS
|
TILE_SIZE = FIELD_WIDTH//ROWS
|
||||||
PLANT = ""
|
PLANT = ""
|
||||||
|
@ -24,7 +24,6 @@ def createTiles():
|
|||||||
for y in range(0, COLS):
|
for y in range(0, COLS):
|
||||||
for x in range(0, ROWS):
|
for x in range(0, ROWS):
|
||||||
tile = Tile(x*TILE_SIZE, y*TILE_SIZE)
|
tile = Tile(x*TILE_SIZE, y*TILE_SIZE)
|
||||||
tile.randomize_photo()
|
|
||||||
tile.randomizeContent()
|
tile.randomizeContent()
|
||||||
tiles.append(tile)
|
tiles.append(tile)
|
||||||
positionFieldElements()
|
positionFieldElements()
|
||||||
|
@ -1,9 +1,60 @@
|
|||||||
|
from crop_protection_product import CropProtectionProduct
|
||||||
|
|
||||||
|
|
||||||
class Tractor:
|
class Tractor:
|
||||||
x = None
|
x = None
|
||||||
y = None
|
y = None
|
||||||
image = 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
|
# etc
|
||||||
|
|
||||||
def __init__(self, x, y):
|
def __init__(self, x, y):
|
||||||
self.x = x
|
self.x = x
|
||||||
self.y = y
|
self.y = y
|
||||||
self.image = 'resources/images/tractor.png'
|
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")
|
||||||
|
4
source/crop_protection_product.py
Normal file
4
source/crop_protection_product.py
Normal file
@ -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
|
@ -1,6 +1,26 @@
|
|||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
class Dirt:
|
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 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
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
import pygame
|
import pygame
|
||||||
|
import time
|
||||||
|
import random
|
||||||
|
|
||||||
from area.constants import WIDTH, HEIGHT
|
from area.constants import WIDTH, HEIGHT
|
||||||
from area.field import drawWindow
|
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))
|
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
|
||||||
pygame.display.set_caption('Intelligent tractor')
|
pygame.display.set_caption('Intelligent tractor')
|
||||||
|
|
||||||
@ -15,6 +21,19 @@ def main():
|
|||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
run = False
|
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
|
# in loop move tractor
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
@ -1,8 +1,25 @@
|
|||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
class Plant:
|
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
|
# more properties
|
||||||
|
|
||||||
|
|
||||||
# add init, getters,setters
|
# add init, getters,setters
|
||||||
|
|
||||||
|
@ -44,5 +44,4 @@ class Tile:
|
|||||||
self.image = "resources/images/dirt.png"
|
self.image = "resources/images/dirt.png"
|
||||||
self.photo = "resources/images/background.jpg"
|
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.)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user