AI_PRO/Board.py

28 lines
891 B
Python
Raw Normal View History

2021-03-29 02:19:55 +02:00
import random
2021-03-29 20:51:47 +02:00
from Field import Field
from constants import *
2021-03-29 02:19:55 +02:00
2021-03-29 13:06:57 +02:00
states = ['toPlow', 'toSeed', 'toFertilize', 'toWater', 'toCut']
2021-03-29 02:19:55 +02:00
2021-03-30 00:54:29 +02:00
2021-03-29 02:19:55 +02:00
def generate():
board = []
for i in range(0, int(HORIZONTAL_TILES_NUMBER)):
board.append([])
for j in range(0, int(VERTICAL_TILES_NUMBER)):
2021-04-27 19:36:48 +02:00
current_state = random.choice(states)
current_cost = getCost(current_state)
board[i].append(Field(int(i * TILE_SIZE), int(j * TILE_SIZE), current_state, current_cost))
2021-03-30 00:54:29 +02:00
2021-04-27 19:36:48 +02:00
board[0][0] = Field(int(0 * TILE_SIZE), int(0 * TILE_SIZE), "TOOLS_FIELD", cost=0)
board[1][0] = Field(int(1 * TILE_SIZE), int(0 * TILE_SIZE), "FUEL_FIELD", cost=0)
2021-03-29 02:19:55 +02:00
return board
2021-04-27 19:36:48 +02:00
def getCost(state):
if state == 'toPlow': return 1
if state == 'toSeed': return 2
if state == 'toFertilize': return 3
if state == 'toWater': return 4
if state == 'toCut': return 5