게임 환경을 위한 절차적 콘텐츠 생성 전문가
Wikiprompt, 무료 프롬프트 백과사전에서
게임 환경을 위한 절차적 콘텐츠 생성 전문가 PCG 전문가로서 AI의 역할을 할당하는 프롬프트로, 반복되지 않는 게임 환경을 생성하기 위한 알고리즘을 설계하며, 첫 번째 특정 작업은 2D 던전 생성기를 위한 것입니다.
프롬프트 내용저장
🌐
[요청사항]
[PCG 전문가 역할 수행]
[2D 무한 던전 생성기 설계]
[Cellular Automata 기반 동굴 벽 생성]
[BSP 기반 방 연결 로직 분리]
[엔트로피/밀도/시드 기반 난수성 중점]
[도달 가능성 검증 포함]
[의사코드]
```
function GenerateInfiniteDungeon(seed, chunkSize, density, entropy):
rng = SeedRandom(seed)
chunkMap = Dictionary<Vector2Int, ChunkData>
for each activeChunk in GetActiveChunks():
if not chunkMap.ContainsKey(activeChunk):
chunkMap[activeChunk] = GenerateChunk(activeChunk, rng, chunkSize, density, entropy)
return chunkMap
function GenerateChunk(chunkPos, rng, chunkSize, density, entropy):
// 1. Cellular Automata for cave walls
caveGrid = InitializeGrid(chunkSize, rng, density)
for iteration in range(4):
caveGrid = ApplyCellularAutomata(caveGrid, entropy)
// 2. BSP for room connectivity
roomTree = BuildBSP(chunkSize, rng, minRoomSize, maxRoomSize)
roomList = ExtractRooms(roomTree)
connectRooms(roomList, caveGrid)
// 3. Reachability check
if not IsFullyReachable(caveGrid, startPoint):
caveGrid = AddCorridors(caveGrid, roomList, rng)
return ChunkData(caveGrid, roomList)
function ApplyCellularAutomata(grid, entropy):
newGrid = CopyGrid(grid)
for each cell in grid:
wallCount = CountNeighborWalls(cell)
if wallCount > 4:
newGrid[cell] = WALL
elif wallCount < 3:
newGrid[cell] = FLOOR
else:
newGrid[cell] = grid[cell] // 유지
return newGrid
function BuildBSP(size, rng, minSize, maxSize):
root = Node(0, 0, size, size)
SplitNode(root, rng, minSize, maxSize)
return root
function SplitNode(node, rng, minSize, maxSize):
if node.width < minSize*2 or node.height < minSize*2:
return
splitHorizontal = rng.NextBool()
if splitHorizontal:
splitPos = rng.Range(minSize, node.height - minSize)
node.left = Node(node.x, node.y, node.width, splitPos)
node.right = Node(node.x, node.y + splitPos, node.width, node.height - splitPos)
else:
splitPos = rng.Range(minSize, node.width - minSize)
node.left = Node(node.x, node.y, splitPos, node.height)
node.right = Node(node.x + splitPos, node.y, node.width - splitPos, node.height)
SplitNode(node.left, rng, minSize, maxSize)
SplitNode(node.right, rng, minSize, maxSize)
function connectRooms(roomList, caveGrid):
for i from 1 to roomList.Count - 1:
roomA = roomList[i-1]
roomB = roomList[i]
corridor = CreateCorridor(roomA.center, roomB.center)
CarveCorridor(caveGrid, corridor)
function IsFullyReachable(grid, start):
visited = FloodFill(grid, start)
return visited.Count == CountFloorCells(grid)
function AddCorridors(grid, roomList, rng):
// 추가 연결을 위한 최소 스패닝 트리 또는 랜덤 연결
for each room in roomList:
nearestRoom = FindNearestUnconnectedRoom(room, roomList)
corridor = CreateCorridor(room.center, nearestRoom.center)
CarveCorridor(grid, corridor)
return grid
```
[데이터 구조]
```
ChunkData:
Grid<CellType> cells
List<Room> rooms
Vector2Int chunkPosition
CellType:
FLOOR
WALL
Room:
Rect bounds
Vector2Int center
Node (BSP):
Rect bounds
Node left
Node right
```
[도달 가능성 로직]
- Flood Fill 알고리즘 사용: 시작점에서 모든 FLOOR 셀을 방문 가능한지 확인
- BFS/DFS 기반 구현, 방문 셀 수와 전체 FLOOR 셀 수 비교
- 불일치 시 BSP 방 사이에 추가 복도 생성 (최소 스패닝 트리 기반)
[파라미터 설명]
- entropy: Cellular Automata 반복 횟수 및 임계값 조절 (높을수록 복잡한 벽)
- density: 초기 벽 생성 확률 (0.4~0.6 권장)
- seed: 전역 난수 시드로 청크 간 일관성 보장
[출력 제한]
- 의사코드만 제공
- 내러티브/UI 요소 제외
- 구조 1:1 유지
전체 프롬프트를 보려면 로그인하세요
Continue with:
By logging in, you agree to our Terms of Use and Privacy Policy
사용법
이 프롬프트는 coding와 함께 사용하도록 설계되었습니다. 위의 프롬프트 내용을 복사하여 원하는 AI 도구에 붙여넣으세요.
최상의 결과를 얻으려면 자리 표시자(대괄호 또는 대문자로 표시)를 특정 요구 사항으로 사용자 지정할 수 있습니다.
토론
댓글 0개