Reprezentacja_wiedzy #1

Merged
s481838 merged 6 commits from Reprezentacja_wiedzy into master 2024-03-26 00:23:07 +01:00
8 changed files with 64 additions and 13 deletions
Showing only changes of commit 679b8ca1b8 - Show all commits

View File

@ -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>

View File

@ -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 = ""

View File

@ -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()

View File

@ -2,8 +2,23 @@ class Tractor:
x = None x = None
y = None y = None
image = None image = None
# 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, ground, plant):
if plant is None:
pass # zasadz cos
if ground.pest == True:
# traktor pozbywa sie szkodnikow
ground.pest = False
if ground.weed == True:
# traktor pozbywa się chwastow
ground.weed = False
if ground.water < plant.water_requirements:
ground.water += 20
if ground.nutrients < plant.nutrients_requirements:
ground.nutrients += 20

View File

@ -0,0 +1,3 @@
class CropProtectionProduct:
def __init__(self, strong_against):
self.strong_against = strong_against # pestycyd, herbicyd

View File

@ -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

View File

@ -1,8 +1,22 @@
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 = self.growth_level - 100
self.growth_level += i
# more properties # more properties
# add init, getters,setters # add init, getters,setters