def prepareLot(matrix, p, height_map, biome):

	areaScore = utilityFunctions.getScoreArea_type1(height_map, p[2],p[3], p[4], p[5], height_map[p[2]][p[4]])
	logging.info("Preparing lot {} with score {}".format(p, areaScore))

	if areaScore != 0:
		terrain_height = flattenPartition(matrix, p[2],p[3], p[4], p[5], height_map, biome)
		logging.info("Terrain was flattened at height {}".format(terrain_height))
		utilityFunctions.updateHeightMap(height_map, p[2], p[3], p[4], p[5], terrain_height)
		h = matrix.getMatrixY(terrain_height)
	else:
		heightCounts = utilityFunctions.getHeightCounts(height_map, p[2],p[3], p[4], p[5])
		terrain_height = max(heightCounts, key=heightCounts.get)
		logging.info("No changes in terrain were necessary, terrain at height {}".format(terrain_height))
		utilityFunctions.updateHeightMap(height_map, p[2], p[3], p[4], p[5], terrain_height)
		# update the ground with the grass block
		for x in range(x_min, x_max):
			for z in range(z_min,z_max):
				matrix.setValue(terrain_height, x, z, ground)
		h = matrix.getMatrixY(terrain_height)


	logging.info("Index of height {} in selection box matrix: {}".format(terrain_height, h))

	return h
示例#2
0
def generateHouse(matrix, p, height_map, usable_wood, biome):
    logging.info("Generating a house in lot {}".format(p))
    logging.info("Terrain before flattening: ")
    for x in range(p[2], p[3]):
        line = ""
        for z in range(p[4], p[5]):
            line += str(height_map[x][z]) + " "
        logging.info(line)

    h = prepareLot(matrix, p, height_map, biome)

    logging.info("Terrain after flattening: ")
    for x in range(p[2], p[3]):
        line = ""
        for z in range(p[4], p[5]):
            line += str(height_map[x][z]) + " "
        logging.info(line)
    house = GenerateHouse.generateHouse(matrix, h, p[1], p[2], p[3], p[4],
                                        p[5], biome, usable_wood)

    utilityFunctions.updateHeightMap(height_map, p[2] + 1, p[3] - 1, p[4] + 1,
                                     p[5] - 1, -1)

    logging.info("Terrain after construction: ")
    for x in range(p[2], p[3]):
        line = ""
        for z in range(p[4], p[5]):
            line += str(height_map[x][z]) + " "
        logging.info(line)

    return house
def generateCrous(matrix, p, height_map):
    logging.info("Generating a crous apt in lot {}".format(p))
    logging.info("Terrain before flattening: ")
    for x in range(p[2], p[3]):
        line = ""
        for z in range(p[4], p[5]):
            line += str(height_map[x][z]) + " "
        logging.info(line)

    h = prepareLot(matrix, p, height_map)

    logging.info("Terrain after flattening: ")
    for x in range(p[2], p[3]):
        line = ""
        for z in range(p[4], p[5]):
            line += str(height_map[x][z]) + " "
        logging.info(line)

    crous = GenerateCrous.generateCrous(matrix, h, p[1], p[2], p[3], p[4],
                                        p[5])

    utilityFunctions.updateHeightMap(height_map, p[2] + 1, p[3] - 1, p[4] + 1,
                                     p[5] - 1, -1)

    logging.info("Terrain after construction: ")
    for x in range(p[2], p[3]):
        line = ""
        for z in range(p[4], p[5]):
            line += str(height_map[x][z]) + " "
        logging.info(line)

    return crous
示例#4
0
def generateWell(matrix, p, height_map, biome):
    h = prepareLot(matrix, p, height_map, biome)
    well = GenerateWell.generateWell(matrix, h, p[1], p[2], p[3], p[4], p[5],
                                     biome)
    utilityFunctions.updateHeightMap(height_map, p[2] + 1, p[3] - 2, p[4] + 1,
                                     p[5] - 2, -1)
    return well
def generateBuilding(matrix, p, height_map):

    h = prepareLot(matrix, p, height_map)
    building = GenerateBuilding.generateBuilding(matrix, h, p[1], p[2], p[3],
                                                 p[4], p[5])
    utilityFunctions.updateHeightMap(height_map, p[2] + 1, p[3] - 2, p[4] + 1,
                                     p[5] - 2, -1)
    return building
示例#6
0
def generateGreenhouse(matrix, p, height_map, usable_wood, biome):
    h = prepareLot(matrix, p, height_map, biome)
    greenhouse = GenerateGreenhouse.generateGreenhouse(matrix, h, p[1], p[2],
                                                       p[3], p[4], p[5],
                                                       usable_wood, biome)
    utilityFunctions.updateHeightMap(height_map, p[2] + 3, p[3] - 3, p[4] + 2,
                                     p[5] - 2, -1)
    return greenhouse
def generateFarm(matrix, p, height_map, simple_height_map, farmType=None):
    logging.info("Generating a farm in lot {}".format(p))
    h = prepareLot(matrix, p, height_map, None)
    farm = GenerateFarm.generateFarm(matrix, h, p[1], p[2], p[3], p[4], p[5],
                                     farmType)
    utilityFunctions.updateHeightMap(height_map, p[2] + 1, p[3] - 2, p[4] + 1,
                                     p[5] - 2, -1)
    utilityFunctions.updateHeightMap(simple_height_map, p[2] + 1, p[3] - 2,
                                     p[4] + 1, p[5] - 2, -1)
    return farm
def generateHouse(matrix, p, height_map, simple_height_map):
    logging.info("Generating a house in lot {}".format(p))
    h = prepareLot(matrix, p, height_map, None)
    house = GenerateHouse.generateHouse(matrix, h, p[1], p[2], p[3], p[4],
                                        p[5])
    utilityFunctions.updateHeightMap(height_map, p[2] + 1, p[3] - 1, p[4] + 1,
                                     p[5] - 1, -1)
    utilityFunctions.updateHeightMap(simple_height_map, p[2] + 1, p[3] - 1,
                                     p[4] + 1, p[5] - 1, -1)
    return house
def generateBuilding(matrix, p, height_map, simple_height_map):
    logging.info("Generating a building in lot {}".format(p))
    h = prepareLot(matrix, p, height_map, (43, 8))
    building = GenerateBuilding.generateBuilding(matrix, h, p[1], p[2], p[3],
                                                 p[4], p[5])
    utilityFunctions.updateHeightMap(height_map, p[2] + 1, p[3] - 1, p[4] + 1,
                                     p[5] - 1, -1)
    utilityFunctions.updateHeightMap(simple_height_map, p[2] + 1, p[3] - 1,
                                     p[4] + 1, p[5] - 1, -1)
    return building
def generateTower(matrix, p, height_map, simple_height_map):
    logging.info("Generating a tower in lot {}".format(p))
    tower = GenerateTower.generateTower(matrix, p[2], p[3], p[4], p[5],
                                        height_map)
    utilityFunctions.updateHeightMap(height_map, tower.buildArea.x_min,
                                     tower.buildArea.x_max,
                                     tower.buildArea.z_min,
                                     tower.buildArea.z_max, -1)
    utilityFunctions.updateHeightMap(simple_height_map, tower.buildArea.x_min,
                                     tower.buildArea.x_max,
                                     tower.buildArea.z_min,
                                     tower.buildArea.z_max, -1)
    return tower
示例#11
0
def prepareLot(matrix, p, height_map, block):

    areaScore = utilityFunctions.getScoreArea_type4(height_map, p[2], p[3],
                                                    p[4], p[5])
    logging.info("Preparing lot {} with score {}".format(p, areaScore))

    if areaScore != 0:
        terrain_height = flattenPartition(matrix, p[2], p[3], p[4], p[5],
                                          height_map, block)
        logging.info(
            "Terrain was flattened at height {}".format(terrain_height))
        utilityFunctions.updateHeightMap(height_map, p[2], p[3], p[4], p[5],
                                         terrain_height)
        h = matrix.getMatrixY(terrain_height)
    else:
        heightCounts = utilityFunctions.getHeightCounts(
            height_map, p[2], p[3], p[4], p[5])
        terrain_height = max(heightCounts, key=heightCounts.get)
        logging.info(
            "No changes in terrain were necessary, terrain at height {}".
            format(terrain_height))
        utilityFunctions.updateHeightMap(height_map, p[2], p[3], p[4], p[5],
                                         terrain_height)
        # update the ground with the most occured block
        if block == None:
            block = utilityFunctions.getMostOcurredGroundBlock(
                matrix, height_map, p[2], p[3], p[4], p[5])
            if block == (3, 0):
                block = (2, 0)
        for x in range(p[2], p[3] + 1):
            for z in range(p[4], p[5] + 1):
                matrix.setValue(terrain_height, x, z, block)
        h = matrix.getMatrixY(terrain_height)

    logging.info("Index of height {} in selection box matrix: {}".format(
        terrain_height, h))

    return h
def prepareArea(matrix, p, height_map, biome):
	terrain_height = flattenPartition(matrix, p[2],p[3], p[4], p[5], height_map, biome, 6)
	logging.info("Terrain was flattened at height {}".format(terrain_height))
	utilityFunctions.updateHeightMap(height_map, p[2], p[3], p[4], p[5], terrain_height)