Привеет! Слушайте, добавить в генератор карт: «import random def…
- User
Привеет! Слушайте, добавить в генератор карт: «import random
def generate_voxel_layer(width, height, filled=True): layer = {} for y in range(height): if filled: row = '1' * width else: row = '0' * width layer[f"Y{y}"] = f"f{row}" return layer
def generate_voxels(width, height, depth): voxels = {'Solid': {}, 'Portal0': {}, 'Portal1': {}, 'Portal2': {}} for voxel_type in voxels: voxels[voxel_type] = {} for z in range(depth + 1): voxels[voxel_type][f"Z{z}"] = {} if z == 0 or z == depth: voxels[voxel_type][f"Z{z}"] = generate_voxel_layer(width, height, filled=True) else: layer = {} for y in range(height): row = '' for x in range(width): if x == 0 or x == width - 1 or y == 0 or y == height - 1: row += '1' # Стены else: row += '0' # Пустое пространство layer[f"Y{y}"] = f"f{row}" voxels[voxel_type][f"Z{z}"] = layer return voxels
def generate_items(width, height, depth): items = [] current_index = 0 occupied_positions = set() # Множество для хранения занятых позиций
# Позиции дверей (на уровне z = 1) # Выбираем случайную стену для каждой двери walls = ['left', 'right', 'top', 'bottom'] entry_wall = random.choice(walls) exit_wall = random.choice([w for w in walls if w != entry_wall]) # Функция для получения позиции и углов двери в зависимости от стены def get_door_position(wall): if wall == 'left': x = 1 y = random.randint(1, height - 2) angles = "-90 180 0" elif wall == 'right': x = width - 2 y = random.randint(1, height - 2) angles = "-90 0 0" elif wall == 'top': x = random.randint(1, width - 2) y = height - 2 angles = "-90 90 0" elif wall == 'bottom': x = random.randint(1, width - 2) y = 1 angles = "-90 -90 0" return x, y, angles # Получаем позиции и углы дверей с проверкой на минимальное расстояние max_attempts = 10 for _ in range(max_attempts): entry_x, entry_y, entry_angles = get_door_position(entry_wall) exit_x, exit_y, exit_angles = get_door_position(exit_wall) # Проверяем минимальное расстояние между дверями if abs(entry_x - exit_x) + abs(entry_y - exit_y) >= min(width, height) // 2: break else: pass entry_z = exit_z = 1 # Уровень пола # Добавляем позиции дверей в занятые позиции occupied_positions.update({(entry_x, entry_y, entry_z), (exit_x, exit_y, exit_z)}) # Входная дверь entry_door = { "Index": str(current_index), "Type": "ITEM_ENTRY_DOOR", "Deletable": "0", "VoxelPos": f"{entry_x} {entry_y} {entry_z}", "LocalPos": "0 0 0", "Angles": entry_angles, "ITEM_PROPERTY_DOOR_IS_COOP": "0", "Facing": "0 0 0", "ConnectionVisiblity": "0", "DoorInstanceID": "6.000000", "Enabled": "1" } items.append(entry_door) entry_door_index = current_index current_index += 1 # Кооперативная входная дверь coop_entry_door = { "Index": str(current_index), "Type": "ITEM_COOP_ENTRY_DOOR", "Deletable": "0", "VoxelPos": f"{entry_x} {entry_y} {entry_z}", "LocalPos": "0 0 0", "Angles": entry_angles, "ITEM_PROPERTY_DOOR_IS_COOP": "0", "Facing": "0 0 0", "ConnectionVisiblity": "0", "DoorInstanceID": "0.000000", "Enabled": "0" } items.append(coop_entry_door) coop_entry_door_index = current_index current_index += 1 # Выходная дверь exit_door = { "Index": str(current_index), "Type": "ITEM_EXIT_DOOR", "Deletable": "0", "VoxelPos": f"{exit_x} {exit_y} {exit_z}", "LocalPos": "0 0 0", "Angles": exit_angles, "ITEM_PROPERTY_CONNECTION_COUNT": "1", "ITEM_PROPERTY_START_OPEN": "0", "ITEM_PROPERTY_DOOR_IS_COOP": "0", "Facing": "0 0 0", "ConnectionVisiblity": "0", "DoorInstanceID": "1.000000", "Enabled": "1" } items.append(exit_door) exit_door_index = current_index current_index += 1 # Кооперативная выходная дверь coop_exit_door = { "Index": str(current_index), "Type": "ITEM_COOP_EXIT_DOOR", "Deletable": "0", "VoxelPos": f"{exit_x} {exit_y} {exit_z}", "LocalPos": "0 0 0", "Angles": exit_angles, "ITEM_PROPERTY_CONNECTION_COUNT": "0", "ITEM_PROPERTY_DOOR_IS_COOP": "0", "ITEM_PROPERTY_COOP_EXIT_STARTS_LOCKED": "1", "Facing": "0 0 0", "ConnectionVisiblity": "0", "DoorInstanceID": "3.000000", "Enabled": "0" } items.append(coop_exit_door) coop_exit_door_index = current_index current_index += 1 # Кнопка (на случайной позиции в комнате) while True: button_x = random.randint(2, width - 3) button_y = random.randint(2, height - 3) button_z = 1 if (button_x, button_y, button_z) not in occupied_positions: break occupied_positions.add((button_x, button_y, button_z)) button_item = { "Index": str(current_index), "Type": "ITEM_BUTTON_FLOOR", "Deletable": "1", "VoxelPos": f"{button_x} {button_y} {button_z}", "LocalPos": "0 0 0", "Angles": "0 0 0", "ITEM_PROPERTY_BUTTON_TYPE": "0", "Facing": "0 0 0", "ConnectionVisiblity": "0" } items.append(button_item) button_index = current_index current_index += 1 # Куб (рядом с кнопкой) cube_x = button_x cube_y_options = [button_y - 1, button_y + 1] random.shuffle(cube_y_options) for cube_y_candidate in cube_y_options: if 1 <= cube_y_candidate < height - 1: cube_y = cube_y_candidate if (cube_x, cube_y, 1) not in occupied_positions: break else: # Если все позиции заняты, выберем случайную while True: cube_x = random.randint(2, width - 3) cube_y = random.randint(2, height - 3) if (cube_x, cube_y, 1) not in occupied_positions: break cube_z = 1 occupied_positions.add((cube_x, cube_y, cube_z)) cube_item = { "Index": str(current_index), "Type": "ITEM_CUBE", "Deletable": "1", "VoxelPos": f"{cube_x} {cube_y} {cube_z}", "LocalPos": "0 0 0", "Angles": "0 0 0", "ITEM_PROPERTY_CUBE_TYPE": "0", "ITEM_PROPERTY_DROPPER_ENABLED": "1", "ITEM_PROPERTY_AUTO_DROP_CUBE": "1", "ITEM_PROPERTY_AUTO_RESPAWN_CUBE": "1", "Facing": "0 0 0", "ConnectionVisiblity": "0" } items.append(cube_item) cube_index = current_index current_index += 1 # Дроппер (на потолке над кубом) dropper_z = depth - 1 # Под потолком occupied_positions.add((cube_x, cube_y, dropper_z)) dropper_item = { "Index": str(current_index), "Type": "ITEM_DROPPER_CUBE", "Deletable": "1", "VoxelPos": f"{cube_x} {cube_y} {dropper_z}", "LocalPos": "0 0 0", "Angles": "0 0 180", # Ориентация вниз "ITEM_PROPERTY_CONNECTION_COUNT": "0", "ITEM_PROPERTY_CUBE_TYPE": "0", "ITEM_PROPERTY_DROPPER_ENABLED": "1", "ITEM_PROPERTY_AUTO_DROP_CUBE": "1", "ITEM_PROPERTY_AUTO_RESPAWN_CUBE": "1", "Facing": "0 0 0", "ConnectionVisiblity": "0" } items.append(dropper_item) dropper_index = current_index current_index += 1 # Добавляем позиции дроппера в занятые позиции occupied_positions.add((cube_x, cube_y, dropper_z)) # Рандомное количество турелей num_turrets = random.randint(0, 3) for _ in range(num_turrets): attempts = 0 while attempts < 10: turret_x = random.randint(2, width - 3) turret_y = random.randint(2, height - 3) turret_z = 1 if (turret_x, turret_y, turret_z) not in occupied_positions: break attempts += 1 else: continue # Если не нашли свободное место, пропускаем турель occupied_positions.add((turret_x, turret_y, turret_z)) turret_item = { "Index": str(current_index), "Type": "ITEM_TURRET", "Deletable": "1", "VoxelPos": f"{turret_x} {turret_y} {turret_z}", "LocalPos": "0 0 0", "Angles": "0 0 0", "Facing": f"0 {random.choice([0, 90, 180, 270])} 0", "ConnectionVisiblity": "0" } items.append(turret_item) current_index += 1 return items, entry_door_index, coop_entry_door_index, exit_door_index, coop_exit_door_index, button_index, cube_index, dropper_index - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.