bug fix v2
This commit is contained in:
parent
2b829714ac
commit
2ff85f9abb
4
board.py
4
board.py
@ -44,7 +44,7 @@ class Board:
|
||||
}
|
||||
|
||||
def generate_board(self):
|
||||
self.board = [[random.choice([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) for _ in range(cols)] for _ in range(rows)]
|
||||
self.board = [[random.choice([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) for _ in range(cols)] for _ in range(rows)]
|
||||
self.vegetables = [
|
||||
[None for _ in range(cols)] for _ in range(rows)
|
||||
]
|
||||
@ -53,7 +53,7 @@ class Board:
|
||||
]
|
||||
for row in range(rows):
|
||||
for col in range(cols):
|
||||
if self.board[row][col] in (6, 7, 8, 9, 10, 11):
|
||||
if self.board[row][col] in (6, 7, 8, 9):
|
||||
vegetable_type = random.choice(list(self.warzywa_images.keys()))
|
||||
vegetable_image = random.choice(self.warzywa_images[vegetable_type])
|
||||
self.vegetables[row][col] = vegetable_image
|
||||
|
@ -56,6 +56,10 @@ class Tractor:
|
||||
else:
|
||||
return # Nie możemy się ruszyć poza planszę
|
||||
|
||||
if next_row >= len(board.vegetable_names) or next_col >= len(board.vegetable_names[0]):
|
||||
print(f"Next position ({next_row}, {next_col}) is out of range")
|
||||
return
|
||||
|
||||
vegetable_name = None
|
||||
|
||||
if board.vegetables[next_row][next_col]:
|
||||
@ -86,7 +90,7 @@ class Tractor:
|
||||
}
|
||||
|
||||
should_water = predict(self.model, self.feature_columns, sample)
|
||||
print(f"Predykcja dla pola ({next_row}, {next_col}) z cechami {sample}: {should_water}")
|
||||
print(f"Predykcja dla pola ({next_row}, {next_col}): {should_water}")
|
||||
if should_water[0].strip() == 'tak':
|
||||
board.set_soil(next_row, next_col)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user