TEMP
This commit is contained in:
parent
d7ae68a8c7
commit
dd721993cd
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9
board.py
9
board.py
@ -59,7 +59,14 @@ class Board:
|
|||||||
self.vegetable_names[row][col] = vegetable_type
|
self.vegetable_names[row][col] = vegetable_type
|
||||||
self.soil_features = self.generate_soil_features()
|
self.soil_features = self.generate_soil_features()
|
||||||
print(f"Shared soil features: {self.soil_features}")
|
print(f"Shared soil features: {self.soil_features}")
|
||||||
|
def count_vegetable_type(self, vegetable_type):
|
||||||
|
# Funkcja zliczająca ilość pól z określonym typem warzywa
|
||||||
|
count = 0
|
||||||
|
for row in range(rows):
|
||||||
|
for col in range(cols):
|
||||||
|
if self.vegetable_names[row][col] == vegetable_type:
|
||||||
|
count += 1
|
||||||
|
return count
|
||||||
def generate_soil_features(self):
|
def generate_soil_features(self):
|
||||||
return {
|
return {
|
||||||
"wilgotnosc_gleby": random.randint(30, 70),
|
"wilgotnosc_gleby": random.randint(30, 70),
|
||||||
|
@ -59,6 +59,15 @@ class Board:
|
|||||||
"brokul": 11
|
"brokul": 11
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def count_vegetable_type(self, vegetable_type):
|
||||||
|
# Funkcja zliczająca ilość pól z określonym typem warzywa
|
||||||
|
count = 0
|
||||||
|
for row in range(rows):
|
||||||
|
for col in range(cols):
|
||||||
|
if self.vegetable_names[row][col] == None:
|
||||||
|
count += 1
|
||||||
|
return count
|
||||||
|
|
||||||
# Metoda do generowania początkowej planszy
|
# Metoda do generowania początkowej planszy
|
||||||
def generate_board(self):
|
def generate_board(self):
|
||||||
# Zwiększenie prawdopodobieństwa generowania trawy i kamieni
|
# Zwiększenie prawdopodobieństwa generowania trawy i kamieni
|
||||||
@ -93,7 +102,7 @@ class Board:
|
|||||||
def evaluate(self):
|
def evaluate(self):
|
||||||
score = 0
|
score = 0
|
||||||
directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] # Kierunki: prawo, dół, lewo, góra
|
directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] # Kierunki: prawo, dół, lewo, góra
|
||||||
|
type_0_count = self.count_vegetable_type(0)
|
||||||
# Sprawdzanie sąsiednich pól dla każdego warzywa
|
# Sprawdzanie sąsiednich pól dla każdego warzywa
|
||||||
for row in range(rows):
|
for row in range(rows):
|
||||||
for col in range(cols):
|
for col in range(cols):
|
||||||
@ -103,6 +112,10 @@ class Board:
|
|||||||
if 0 <= new_row < rows and 0 <= new_col < cols:
|
if 0 <= new_row < rows and 0 <= new_col < cols:
|
||||||
if self.vegetable_names[row][col] == self.vegetable_names[new_row][new_col]:
|
if self.vegetable_names[row][col] == self.vegetable_names[new_row][new_col]:
|
||||||
score += 1
|
score += 1
|
||||||
|
|
||||||
|
if type_0_count < 35:
|
||||||
|
score -= (35 - type_0_count) * 2
|
||||||
|
|
||||||
return score
|
return score
|
||||||
|
|
||||||
# Metoda mutująca planszę
|
# Metoda mutująca planszę
|
||||||
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 767 KiB After Width: | Height: | Size: 684 KiB |
14
kolejka.py
14
kolejka.py
@ -1,10 +1,11 @@
|
|||||||
from constant import rows, cols
|
from constant import rows, cols
|
||||||
|
import random
|
||||||
class Stan:
|
class Stan:
|
||||||
def __init__(self, row, col, direction):
|
def __init__(self, row, col, direction):
|
||||||
self.p = []
|
self.p = []
|
||||||
self.a = ""
|
self.a = ""
|
||||||
self.row = row
|
self.row = row
|
||||||
|
self.cost = random.randint(1, 100)
|
||||||
self.col = col
|
self.col = col
|
||||||
self.direction = direction
|
self.direction = direction
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@ -14,7 +15,18 @@ class Stan:
|
|||||||
if len(self.p) == 0:
|
if len(self.p) == 0:
|
||||||
self.p.append(stan)
|
self.p.append(stan)
|
||||||
self.a = action
|
self.a = action
|
||||||
|
def __lt__(self, other):
|
||||||
|
return self.cost < other.cost
|
||||||
|
|
||||||
|
def __le__(self, other):
|
||||||
|
return self.cost <= other.cost
|
||||||
|
|
||||||
|
def __gt__(self, other):
|
||||||
|
return self.cost > other.cost
|
||||||
|
|
||||||
|
def __ge__(self, other):
|
||||||
|
return self.cost >= other.cost
|
||||||
|
|
||||||
def succ(self, action, board):
|
def succ(self, action, board):
|
||||||
move_offsets = {
|
move_offsets = {
|
||||||
"up": {"up": (-1, 0), "left": (0, -1), "down": (1, 0), "right": (0, 1)},
|
"up": {"up": (-1, 0), "left": (0, -1), "down": (1, 0), "right": (0, 1)},
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user