added world matrix to improve ID3 decisions
This commit is contained in:
parent
637aff9e2a
commit
a9491252bb
Binary file not shown.
@ -1,8 +1,8 @@
|
||||
from cmath import sqrt
|
||||
|
||||
|
||||
screen_width=936
|
||||
screen_height=936
|
||||
screen_width=1200#936
|
||||
screen_height=1000#936
|
||||
SIZE = (screen_width, screen_height)
|
||||
SPECIES=["carrot","potato","beetroot","wheat"]
|
||||
# size in pixels of one tile = 36px/36px
|
||||
@ -12,6 +12,6 @@ road_coords = [0, 5, 10, 15, 20, 25]
|
||||
field_width = 4
|
||||
field_height = 4
|
||||
field_size = field_width*field_height
|
||||
fields_amount = 26
|
||||
fields_amount = 25
|
||||
|
||||
directions = {0: 'UP', 90: 'RIGHT', 180: 'DOWN', 270: 'LEFT'}
|
9
src/Road.py
Normal file
9
src/Road.py
Normal file
@ -0,0 +1,9 @@
|
||||
from pygame.sprite import Sprite
|
||||
|
||||
class Road(Sprite):
|
||||
def __init__(self,x,y):
|
||||
super().__init__()
|
||||
self.x=x
|
||||
self.y=y
|
||||
self.type='Road'
|
||||
self.cost=200
|
BIN
src/__pycache__/Road.cpython-310.pyc
Normal file
BIN
src/__pycache__/Road.cpython-310.pyc
Normal file
Binary file not shown.
Binary file not shown.
43
src/map.py
43
src/map.py
@ -4,6 +4,8 @@ from settings import screen_height, screen_width, SIZE, SPECIES, block_size, til
|
||||
from src.Plant import Plant
|
||||
import random
|
||||
from src.Field import Field
|
||||
from src.Road import Road
|
||||
import csv
|
||||
|
||||
|
||||
def get_type_by_position(fields, x, y):
|
||||
@ -30,18 +32,26 @@ def get_cost_by_type(plant_type):
|
||||
|
||||
fields = pygame.sprite.Group()
|
||||
|
||||
|
||||
world_matrix = [[0 for _ in range(fields_amount+1)] for _ in range(fields_amount+1)]
|
||||
|
||||
def drawRoads(screen):
|
||||
#drawing roads:
|
||||
road = pygame.image.load("assets/road.jpeg")
|
||||
road = pygame.transform.scale(road, tile)
|
||||
for x in road_coords:
|
||||
for block in range(26):
|
||||
for block in range(int(fields_amount)+1):
|
||||
screen.blit(road, (x*block_size, block * 36))
|
||||
fields.add(Field('road', x*block_size, block * 36, None, get_cost_by_type('road'), None, None, None, None, 'road', None, None))
|
||||
tmp_field=Field('road', x*block_size, block * 36, None, get_cost_by_type('road'), None, None, None, None, 'road', None, None)
|
||||
fields.add(tmp_field)
|
||||
world_matrix[x][block]=Road(x,block)
|
||||
for y in road_coords:
|
||||
for block in range(26):
|
||||
screen.blit(road, (block * 36, y*block_size))
|
||||
fields.add(Field('road', block * 36, y*block_size, None, get_cost_by_type('road'), None, None, None, None, 'road', None, None))
|
||||
for block in range(int(fields_amount)+1):
|
||||
screen.blit(road, (block * block_size, y*block_size))
|
||||
tmp_field=Field('road', block * block_size, y*block_size, None, get_cost_by_type('road'), None, None, None, None, 'road', None, None)
|
||||
fields.add(tmp_field)
|
||||
world_matrix[block][y]=Road(block,y)
|
||||
|
||||
|
||||
barn_img = pygame.image.load('assets/barn.png')
|
||||
barn = pygame.transform.scale(barn_img, tile)
|
||||
@ -52,17 +62,34 @@ def drawRoads(screen):
|
||||
def seedForFirstTime():
|
||||
plant_group = pygame.sprite.Group()
|
||||
for field in range(fields_amount):
|
||||
plant = random.choice(SPECIES)
|
||||
plant_name = random.choice(SPECIES)
|
||||
blocks_seeded_in_field = 0
|
||||
while (blocks_seeded_in_field < field_size):
|
||||
|
||||
x = (((field%5)*((block_size*(field_width+1)))) + ((blocks_seeded_in_field % field_width)*block_size) + ((3/2)*block_size))
|
||||
y = ((int(field/5)*((block_size*(field_width+1)))) + ((int(blocks_seeded_in_field/field_height))*block_size) + ((3/2)*block_size))
|
||||
new_plant = Plant(plant,0, x, y)
|
||||
|
||||
new_plant = Plant(plant_name,0, x, y)
|
||||
blocks_seeded_in_field = blocks_seeded_in_field + 1
|
||||
plant_group.add(new_plant)
|
||||
fields.add(Field('field', x-18, y-18, None, get_cost_by_type(plant), None, None, None, None, plant, None, None))
|
||||
tmp_field_plant = Field('field', x-18, y-18, None, get_cost_by_type(plant_name), None, None, None, None, plant_name, None, None)
|
||||
fields.add(tmp_field_plant)
|
||||
|
||||
mx = int((x-18)/36)
|
||||
my = int((y-18)/36)
|
||||
world_matrix[mx][my]=tmp_field_plant
|
||||
|
||||
# for i in range(1,4):
|
||||
# world_matrix[mx][my+i]=tmp_field_plant
|
||||
#debug
|
||||
print(world_matrix)
|
||||
#end of debug
|
||||
|
||||
return plant_group
|
||||
|
||||
def put_to_matrix():
|
||||
return 0
|
||||
|
||||
def return_fields_list():
|
||||
return fields
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user