「ダンジョンジェネレータ」の編集履歴(バックアップ)一覧はこちら

ダンジョンジェネレータ」(2008/05/07 (水) 23:23:24) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

I. A Dungeon is a Maze I. A土牢は、迷宮です First of all, it is helpful to think of any dungeon as simply a maze?a collection of corridors that turn every which way. The first part of generating any dungeon, then, is to create a random maze. まず第一に、単に迷宮としていくらかの(どんな)土牢のことを考えることは、役立ちます?四方八方回転するまとまった廊下。最初のいくらかの(どんな)土牢を発生させることの一部分は、その時、ランダムな迷宮を作り出すはず(こと,予定)です。 Now, there are lots of different ways to generate mazes (for some idea of how many different types of mazes and algorithms there are, check out the Maze Algorithms page at Think Labyrinth). For the dungeon generator, I just picked a straightforward algorithm that I'm pretty familiar with?it's a variation on the "Hunt-and-Kill" algorithm. The algorithm creates a 2D, normal, orthoganol, perfect maze, which simply means that the maze is rectangular, with all passages intersecting at right angles, and that there are no loops or inaccessible areas in the maze. 今、多くの迷宮を発生させる異なる方法があります(迷宮、およびそこでのアルゴリズムがそうであるところでは、チェックのいくつの異なる型で外へ迷宮アルゴリズムがめくるかについてのある考えのために、迷路を思って下さい)。土牢ジェネレータのために、私は、ちょうど、私がそうであるところでは、親友をきれいにする安直なアルゴリズムを選びました?それは、「狩り-および-殺し」アルゴリズムの変化です。アルゴリズムは、2D、普通、orthoganol、完全迷宮を作り出します、(単に迷宮が直角ですべての論争で横切って、長方形だ、および迷宮にいかなるループ(もなく)、あるいはアクセス不可のエリアがあるということを意味する)。 Here's how the algorithm I picked works. Feel free to substitute this one with any other algorithm. ここで(に)は、どのように私が選んだアルゴリズムが働くかです。自由にこれを他のどの(いずれかの)アルゴリズムで置き換えて下さい。 Start with a rectangular grid, x units wide and y units tall. Mark each cell in the grid unvisited. 大げさに広いそしてyユニット(で)ユニット(で)長方形の格子、xで始まって下さい。格子のそれぞれのセルを訪れる者がないと印をつけて下さい。 Pick a random cell in the grid and mark it visited. This is the current cell. 格子でランダムなセルを選んで下さい、そして、それを訪れられたと印をつけて下さい。これは現在のセルです。 From the current cell, pick a random direction (north, south, east, or west). If (1) there is no cell adjacent to the current cell in that direction, or (2) if the adjacent cell in that direction has been visited, then that direction is invalid, and you must pick a different random direction. If all directions are invalid, pick a different random visited cell in the grid and start this step over again. 現在のセルから、ランダムな方向(北の、南の、東の、あるいは西である)を選んで下さい。(1)その方向に現在のセルに隣接するいかなるセルもありません、または、(2)もし隣のその方向のセルが訪れられたら、その方向が無効におよびあなたかは、異なるランダムな方向を選ばなくてはいけません。もし前後左右が無効なら、格子で異なるでたらめに訪れられたセルを選んでもう一度このステップを開始して下さい。 Let's call the cell in the chosen direction C. Create a corridor between the current cell and C, and then make C the current cell. Mark C visited. 選ばれている方向C. Createでセルを呼びましょう現在のセルとCとの間の廊下、そしてその時Cを現在のセルにして下さい。マークCは訪れました。 Repeat steps 3 and 4 until all cells in the grid have been visited. 格子のすべてのセルが訪れられたときまでステップ3および4を繰り返して下さい。 Once that process finishes, you'll have your maze! There are a few variations you can do to make the maze more interesting; for example, my dungeon generator has a parameter called "randomness". This is a percentage value (0?100) that determines how often the direction of a corridor changes. If the value of randomness is 0, the corridors go straight until they run into a wall or another corridor?you wind up with a maze with lots of long, straight halls. If the randomness is 100, you get the algorithm given above?corridors that twist and turn unpredictably from cell to cell. 一旦そのプロセスが終われば、あなたはあなたの迷宮を持つでしょう!迷宮をより面白くするために、あなたがすることができる少しの変化があります;例えば、私の土牢ジェネレータは、「任意」と呼ばれるパラメーターを持っています。これはパーセンテージ価値です(0?100)それは、どのくらいしばしば廊下のディレクションが変わるかを決定します。彼(それ)らがウォール、あるいはもう一つの廊下にぶつかるときまで、もし任意の価値が0なら、廊下はまともな生活をします?あなたは、多くの長い、連続のホールで迷宮でワインド・アップします。もし任意が100なら、あなたは、アルゴリズムを上を(で)与えさせます?セルからセルへ予測がつかずによじれて回転する廊下。 II. Mazes vs. Dungeons 2。迷宮対土牢 It is important to note that the algorithm given above results in no loops in the maze. It is also important to note that the algorithm results in a dense maze?that is, every cell contains a corridor. 上記のアルゴリズム既知の事実が迷宮でいかなるループも結果にならないと述べることは、重要です。アルゴリズムが密集している迷宮の結果になると述べることは、また重要です?すなわち、すべてのセルは廊下を含みます。 This "pure" maze is probably not what you had in mind when you asked for a dungeon. For example, sometimes a dungeon passage intersects with another passage, or with itself, forming a loop. Also, an underground dungeon may cover a lot of territory, but not fill every square meter of rock?it is probably sparse, as opposed to dense. この「純粋な」迷宮は、たぶんあなたが土牢を求めたときに、あなたが心で持っていたものではありません。例えば、時々、土牢経過は、もう一つの経過で横切ります、またはそれ自身でループを形づくります。また、地下の土牢がすべての平方メートル(で)多くの領土、(しかしいっぱいではない)をカバーするかもしれません、岩?それはたぶん人口希薄です、反対しているとしてへの密集しています。 There are two steps I used to convert the maze into something more like a dungeon (though still lacking rooms). 土牢のようにさらに何かへ迷宮を変えるのが慣れているステップIがあります(静かな不足していることが下宿するにもかかわらず)。 The first step involves a parameter I called sparseness. It is an integer value; you may want to experiment with it to arrive at a value (or set of values) that work best for you. It is used as follows: 第一歩は、まばらと呼ばれるパラメーターIを含みます。 それは整数値です;あなたのために最も最高に働く値(あるいは値のセット)に到着するために、それで実験したくてもよいです。以下のように、それは使われます: Look at every cell in the maze grid. If the given cell contains a corridor that exits the cell in only one direction (in otherwords, if the cell is the end of a dead-end hallway), "erase" that cell by removing the corridor. 迷宮格子のすべてのセルで見えて下さい。与えられたセルが終了する廊下を含むかたった1(人)方向のセル( otherwordsで、セルが行き止まり玄関の終り(端)か)、廊下をリムーブすることによってそのセルを「消して下さい」。 Repeat step #1 sparseness times (ie, if sparseness is 5, repeat step #1 five times). リピート、ステップ#1まばら時間( ieがもしまばらが5なら、ステップ#1を繰り返します5回)。 After sparsifying the maze, you should wind up with large "blank" gaps, where no passages go. The maze, however, is still perfect, meaning that it has no loops, and that no corridor is inaccessible from any other corridor. sparsifyingの後で、迷宮、あなたが大きい「ブランク」ギャップでワインド・アップすべきですが,そこでいかなる論争も行きません。それがいかなるループもない、およびいかなる廊下も他のどの(いずれかの)廊下からアクセス不可でないということを意味して、迷宮は、しかしながら、まだ完全です。 The next step is to remove dead-ends by adding loops to the maze. The "deadends removed" parameter of my generator is a percentage value that represents the chance a given dead-end in the maze has of being removed. It is used as follows: 次のステップは、迷宮にループを加えることによって行き止まりをリムーブするはず(こと,予定)です。 私のジェネレータの「リムーブされたdeadends」パラメーターが迷宮で行き止まりな既知の事実が持っているチャンスを表すパーセンテージ値です、存在はリムーブしました。以下のように、それは使われます: Look at every cell in the maze grid. If the given cell is a dead-end cell (meaning that a corridor enters but does not exit the cell), it is a candidate for "dead-end removal." 迷宮格子のすべてのセルで見えて下さい。与えられたセルが行き止まりセルか(つまり廊下が加わりますが終了しませんセル)、それは、「行き止まり除去」のための立候補者です。 Roll d% (ie, pick a number between 1 and 100, inclusive). If the result is less than or equal to the "deadends removed" parameter, this deadend should be removed. Otherwise, proceed to the next candidate cell. d %を転がします( ie、1から100番を選んで下さい、包括的です)。もし結果は(それよりも)より小さくあります、または、「リムーブされたdeadends」パラメーター、このdeadendへのイコールがリムーブされるべきなら。さもなければ、次の立候補者の細胞に進んで下さい。 Remove the dead-end by performing step #3 of the maze generation algorithm, above, except that a cell is not considered invalid if it has been visited. Stop when you intersect an existing corridor. もしそれが訪れられたら、セルが無効だと考えられない以外は(上の)迷宮世代アルゴリズムのステップ#3を実行することによって行き止まりをリムーブして下さい。あなたが現存する廊下を横切るときに、止まって下さい。 So, now you have something looking more like a dungeon. All it lacks, now, are rooms… したがって、今、あなたは、土牢のようにもっと何か見えるものを持っています。それが不足しているすべては、今、rooms…です III. Room Generation and Placement 3。空間世代、および配置 This was perhaps the trickiest step. Looking at my generator, you'll see three parameters: "room count" (Rn), "room width", (Rw), and "room height" (Rh). これは、たぶん最も一筋縄にはいかないステップでした。私のジェネレータを見て、あなたは3つのパラメーターを見るでしょう:「空間カウント」( Rn )、「空間幅」、( Rw )、そして「空間高さ」( Rh )。 Generating rooms is actually easy: Rw is just a random number between the minimum and maximum widths. Rh is generated similarly. 発生させている空間は実際には簡単です:Rwは、最小と最大限の幅の間にちょうどランダムな数です。Rhは同様に発生させられます。 Placing the rooms was trickier. The idea is to find a place in the maze where the given room overlaps a minimum of corridors and other rooms, but where the room touches a corridor in at least on place. To this end, I implemented a weighting system. 空間を置くことはより一筋縄にはいかなかったです。そのアイデアは、場所を与えられた空間が少なくとも場所で廊下および他の空間、しかしどこでか(場所)で空間が廊下に触るかの最小を部分的に重ねる迷宮で見つけるはず(こと,予定)です。この目的のために、私は上積み手当システムを実行しました。 The program tries to put the room at every possible place in the dungeon. The algorithm works as follows: プログラムは、すべての可能な場所の空間を土牢に入れるよう試みます。以下のように、アルゴリズムは働きます: Set the "best" score to infinity (or some arbitrarily huge number). 無限(あるいはある随意に巨大な数)への最も「よい」スコアーをセットして下さい。 Generate a room such that Wmin <= Rw <= Wmax and Hmin <= Rh <= Hmax. 空間を発生させますようにWmin <= Rw <= Wmax、およびHmin <= Rh <= Hmax。 For each cell C in the dungeon, do the following: それぞれの土牢のセルCのために、下記のようにしてください: Put the upper-left corner of the room at C. Set the "current" score to 0. 「電流」が0に得点するC.セットで空間の覚醒剤が去ったコーナーを置いて下さい。 For each cell of the room that is adjacent to a corridor, add 1 to the current score. 廊下に隣接する空間のそれぞれのセルのために、現在のスコアーに1を加えて下さい。 For each cell of the room that overlaps a corridor, add 3 to the current score. 廊下を部分的に重ねる空間のそれぞれのセルのために、現在のスコアーに3を加えて下さい。 For each cell of the room that overlaps a room, add 100 to the current score. 空間を部分的に重ねる空間のそれぞれのセルのために、現在のスコアーに100を加えて下さい。 If the current score is less than the best score, set the best score to the current score and note C as the best position seen yet. もし現在のスコアーがもう見られた最もよい位置として(現在のスコアーへの最もよいスコアーをセットされた)最もよいスコアー、およびノートCよりも小さければ。 Place the room at the best position (where the best score was found). 最もよい位置に空間を置いて下さい(最もよいスコアーが見つけられた)。 For every place where the room is adjacent to a corridor or a room, add a door. (If you don't want doors everywhere, add another parameter that determines when a door should be placed, and when an empty doorway [ie, archway, etc.] should be placed). 空間が廊下、あるいは空間に隣接するすべての場所のために、ドアを加えて下さい。(もしあなたがどこでもドアが欲しくなければ、いつドアが置かれるべきか、およびいつ空っぽの出入り口[ ie、アーチの下の通路、etcです。]が置かれるべきかを決定するもう一つのパラメーターを加えて下さい)。 Repeat steps 2 through 6 until all rooms have been placed. すべての空間が置かれたときまで、リピートは2から6を踏みます。 IV. Populating the Dungeon 4。土牢を住むこと I won't go into any great detail here, since I took the algorithms for this part straight from the Dungeon Master's Guide. The idea is simply to put something in each room of the dungeon: hidden treasure, a monster, some description, etc. At this stage, you also determine whether any given door is secret or concealed, and also what the door's properties are (wooden, locked, trapped, etc, etc.). Random tables work quite well to determine all of this. 私は、土牢マスターのガイドからアルゴリズムをこの部品まっすぐと考えて以来、ここで(に)いくらかの(どんな)すばらしい詳細に入らないでしょう。そのアイデアは、単に何かを土牢のそれぞれの空間に入れるはず(こと,予定)です:隠された宝、モンスター、ある記述、etc。この段階で、あなたは、また、いくらかの(どんな)与えられたドアが秘密の、あるいは隠されるかどうかを決定します、そして、また、どんなドアが小道具かは、そうです(木製の、ロックされた、罠にかけられてetc、etcです。)。ランダムな表は、これのすべてを決めるために、とても十分に働きます。 V. Finis V.完 And that, as they say, is the proverbial that. All that remains is to display the dungeon, and that has nothing to do with dungeon generation algorithms. :) そして、それ、彼(それ)らが言うように、ことわざであること(人)はそれですか。残るすべてのことは、土牢を表示するはず(こと,予定)です、そして、それは、土牢世代アルゴリズムとは何の関係もないです。:) Feel free to download the source code for my dungeon generator?that's where you'll find the real technical explanation. The sources are a bastardized mix of C and C++, but fairly readable for all of that. The "jbmaze.cpp" file contains the maze generation algorithms, and the "jbdungeon.cpp" file contains the dungeon generation stuff. The "jbdungeondata.cpp" file populates the dungeon. 自由に私の土牢ジェネレータのためのソース・コードをダウンロードして下さい?それは、どこで(に)あなたが現実の技術的な説明を見つけるだろうかです。ソースは、C、およびC++の落とされたミックス、しかしそれのすべてにとってとても読みやすいです。「jbmaze.cpp」ファイルは、迷宮世代アルゴリズムを含みます、そして、「jbdungeon.cpp」ファイルは、土牢世代材料を含みます。「jbdungeondata.cpp」ファイルは、土牢を住みます。

表示オプション

横に並べて表示:
変化行の前後のみ表示: