Hengband  2.1.4
 全て データ構造 ファイル 関数 変数 型定義 マクロ定義 ページ
関数 | 変数
generate.c

ダンジョンの生成 / Dungeon generation [詳細]

#include "angband.h"
#include "generate.h"
#include "grid.h"
#include "rooms.h"
#include "streams.h"
generate.cのインクルード依存関係図

関数

static int next_to_walls (int y, int x)
 上下左右の外壁数をカウントする / Count the number of walls adjacent to the given grid. [詳細]
 
static bool alloc_stairs_aux (int y, int x, int walls)
 alloc_stairs()の補助として指定の位置に階段を生成できるかの判定を行う / Helper function for alloc_stairs(). [詳細]
 
static bool alloc_stairs (int feat, int num, int walls)
 外壁に隣接させて階段を生成する / Places some staircases near walls [詳細]
 
static void alloc_object (int set, int typ, int num)
 フロア上のランダム位置に各種オブジェクトを配置する / Allocates some objects (using "place" and "type") [詳細]
 
static int next_to_corr (int y1, int x1)
 隣接4マスに存在する通路の数を返す / Count the number of "corridor" grids adjacent to the given grid. [詳細]
 
static bool possible_doorway (int y, int x)
 ドアを設置可能な地形かを返す / Determine if the given location is "between" two walls, and "next to" two corridor spaces. [詳細]
 
static void try_door (int y, int x)
 ドアの設置を試みる / Places door at y, x position if at least 2 walls found [詳細]
 
bool place_quest_monsters (void)
 クエストに関わるモンスターの配置を行う / Place quest monsters [詳細]
 
static void set_bound_perm_wall (cave_type *c_ptr)
 マスにフロア端用の永久壁を配置する / Set boundary mimic and add "solid" perma-wall [詳細]
 
static void gen_caverns_and_lakes (void)
 フロアに洞窟や湖を配置する / Generate various caverns and lakes [詳細]
 
static bool cave_gen (void)
 ダンジョン生成のメインルーチン / Generate a new dungeon level [詳細]
 
static void build_arena (void)
 闘技場用のアリーナ地形を作成する / Builds the arena after it is entered -KMW- [詳細]
 
static void arena_gen (void)
 闘技場への入場処理 / Town logic flow for generation of arena -KMW- [詳細]
 
static void build_battle (void)
 モンスター闘技場のフロア生成 / Builds the arena after it is entered -KMW- [詳細]
 
static void battle_gen (void)
 モンスター闘技場への導入処理 / Town logic flow for generation of arena -KMW- [詳細]
 
static void quest_gen (void)
 固定マップクエストのフロア生成 / Generate a quest level [詳細]
 
static bool level_gen (cptr *why)
 ダンジョン時のランダムフロア生成 / Make a real level [詳細]
 
void wipe_generate_cave_flags (void)
 フロアに存在する全マスの記憶状態を初期化する / Wipe all unnecessary flags after cave generation [詳細]
 
void clear_cave (void)
 フロアの全情報を初期化する / Clear and empty the cave [詳細]
 
void generate_cave (void)
 ダンジョンのランダムフロアを生成する / Generates a random dungeon level -RAK- [詳細]
 

変数

int dun_tun_rnd
 ダンジョンの通路方向を掻き回す頻度(一回の試行ごとにで判定している) [詳細]
 
int dun_tun_chg
 ダンジョンの通路をクランクさせる頻度(一回の試行ごとにで判定している) [詳細]
 
int dun_tun_con
 ダンジョンの通路を継続して引き延ばす頻度(一回の試行ごとにで判定している) [詳細]
 
int dun_tun_pen
 ダンジョンの部屋入口にドアを設置する頻度(一回の試行ごとにで判定している) [詳細]
 
int dun_tun_jct
 ダンジョンの通路交差地点付近にドアを設置する頻度(一回の試行ごとにで判定している) [詳細]
 
dun_datadun
 Dungeon generation data – see "cave_gen()". [詳細]
 

説明

ダンジョンの生成 / Dungeon generation

日付
2014/01/04
作者
Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
This software may be copied and distributed for educational, research,
and not for profit purposes provided that this copyright and statement
are included in all such copies. Other copyrights may also apply.
2014 Deskull rearranged comment for Doxygen.

Note that Level generation is not an important bottleneck,
though it can be annoyingly slow on older machines... Thus
we emphasize "simplicity" and "correctness" over "speed".

This entire file is only needed for generating levels.
This may allow smart compilers to only load it when needed.

Consider the "v_info.txt" file for vault generation.

In this file, we use the "special" granite and perma-wall sub-types,
where "basic" is normal, "inner" is inside a room, "outer" is the
outer wall of a room, and "solid" is the outer wall of the dungeon
or any walls that may not be pierced by corridors. Thus the only
wall type that may be pierced by a corridor is the "outer granite"
type. The "basic granite" type yields the "actual" corridors.

Note that we use the special "solid" granite wall type to prevent
multiple corridors from piercing a wall in two adjacent locations,
which would be messy, and we use the special "outer" granite wall
to indicate which walls "surround" rooms, and may thus be "pierced"
by corridors entering or leaving the room.

Note that a tunnel which attempts to leave a room near the "edge"
of the dungeon in a direction toward that edge will cause "silly"
wall piercings, but will have no permanently incorrect effects,
as long as the tunnel can eventually exit from another side.
And note that the wall may not come back into the room by the
hole it left through, so it must bend to the left or right and
then optionally re-enter the room (at least 2 grids away). This
is not a problem since every room that is large enough to block
the passage of tunnels is also large enough to allow the tunnel
to pierce the room itself several times.

Note that no two corridors may enter a room through adjacent grids,
they must either share an entryway or else use entryways at least
two grids apart. This prevents "large" (or "silly") doorways.

To create rooms in the dungeon, we first divide the dungeon up
into "blocks" of 11x11 grids each, and require that all rooms
occupy a rectangular group of blocks. As long as each room type
reserves a sufficient number of blocks, the room building routines
will not need to check bounds. Note that most of the normal rooms
actually only use 23x11 grids, and so reserve 33x11 grids.

Note that the use of 11x11 blocks (instead of the old 33x11 blocks)
allows more variability in the horizontal placement of rooms, and
at the same time has the disadvantage that some rooms (two thirds
of the normal rooms) may be "split" by panel boundaries. This can
induce a situation where a player is in a room and part of the room
is off the screen. It may be annoying enough to go back to 33x11
blocks to prevent this visual situation.

Note that the dungeon generation routines are much different (2.7.5)
and perhaps "DUN_ROOMS" should be less than 50.

XXX XXX XXX Note that it is possible to create a room which is only
connected to itself, because the "tunnel generation" code allows a
tunnel to leave a room, wander around, and then re-enter the room.

XXX XXX XXX Note that it is possible to create a set of rooms which
are only connected to other rooms in that set, since there is nothing
explicit in the code to prevent this from happening. But this is less
likely than the "isolated room" problem, because each room attempts to
connect to another room, in a giant cycle, thus requiring at least two
bizarre occurances to create an isolated section of the dungeon.

Note that (2.7.9) monster pits have been split into monster "nests"
and monster "pits". The "nests" have a collection of monsters of a
given type strewn randomly around the room (jelly, animal, or undead),
while the "pits" have a collection of monsters of a given type placed
around the room in an organized manner (orc, troll, giant, dragon, or
demon). Note that both "nests" and "pits" are now "level dependant",
and both make 16 "expensive" calls to the "get_mon_num()" function.

Note that the cave grid flags changed in a rather drastic manner
for Angband 2.8.0 (and 2.7.9+), in particular, dungeon terrain
features, such as doors and stairs and traps and rubble and walls,
are all handled as a set of 64 possible "terrain features", and
not as "fake" objects (440-479) as in pre-2.8.0 versions.

The 64 new "dungeon features" will also be used for "visual display"
but we must be careful not to allow, for example, the user to display
hidden traps in a different way from floors, or secret doors in a way
different from granite walls, or even permanent granite in a different
way from granite. XXX XXX XXX

関数

static void alloc_object ( int  set,
int  typ,
int  num 
)
static

フロア上のランダム位置に各種オブジェクトを配置する / Allocates some objects (using "place" and "type")

引数
set配置したい地形の種類
typ配置したいオブジェクトの種類
num配置したい数
戻り値
規定数通りに生成に成功したらTRUEを返す。

関数の呼び出しグラフ:

呼出しグラフ:

static bool alloc_stairs ( int  feat,
int  num,
int  walls 
)
static

外壁に隣接させて階段を生成する / Places some staircases near walls

引数
feat配置したい地形ID
num配置したい階段の数
walls最低減隣接させたい外壁の数
戻り値
規定数通りに生成に成功したらTRUEを返す。

関数の呼び出しグラフ:

呼出しグラフ:

static bool alloc_stairs_aux ( int  y,
int  x,
int  walls 
)
static

alloc_stairs()の補助として指定の位置に階段を生成できるかの判定を行う / Helper function for alloc_stairs().

Is this a good location for stairs?

引数
y基準のy座標
x基準のx座標
walls最低減隣接させたい外壁の数
戻り値
階段を生成して問題がないならばTRUEを返す。

関数の呼び出しグラフ:

呼出しグラフ:

static void arena_gen ( void  )
static

闘技場への入場処理 / Town logic flow for generation of arena -KMW-

戻り値
なし

関数の呼び出しグラフ:

呼出しグラフ:

static void battle_gen ( void  )
static

モンスター闘技場への導入処理 / Town logic flow for generation of arena -KMW-

戻り値
なし

関数の呼び出しグラフ:

呼出しグラフ:

static void build_arena ( void  )
static

闘技場用のアリーナ地形を作成する / Builds the arena after it is entered -KMW-

戻り値
なし

関数の呼び出しグラフ:

呼出しグラフ:

static void build_battle ( void  )
static

モンスター闘技場のフロア生成 / Builds the arena after it is entered -KMW-

戻り値
なし

関数の呼び出しグラフ:

呼出しグラフ:

static bool cave_gen ( void  )
static

ダンジョン生成のメインルーチン / Generate a new dungeon level

Note that "dun_body" adds about 4000 bytes of memory to the stack.

戻り値
ダンジョン生成が全て無事に成功したらTRUEを返す。

関数の呼び出しグラフ:

呼出しグラフ:

void clear_cave ( void  )

フロアの全情報を初期化する / Clear and empty the cave

戻り値
なし

関数の呼び出しグラフ:

呼出しグラフ:

static void gen_caverns_and_lakes ( void  )
static

フロアに洞窟や湖を配置する / Generate various caverns and lakes

There were moved from cave_gen().

戻り値
なし

関数の呼び出しグラフ:

呼出しグラフ:

void generate_cave ( void  )

ダンジョンのランダムフロアを生成する / Generates a random dungeon level -RAK-

戻り値
なし
覚え書き
Hack – regenerate any "overflow" levels

関数の呼び出しグラフ:

呼出しグラフ:

static bool level_gen ( cptr why)
static

ダンジョン時のランダムフロア生成 / Make a real level

戻り値
フロアの生成に成功したらTRUE

関数の呼び出しグラフ:

呼出しグラフ:

static int next_to_corr ( int  y1,
int  x1 
)
static

隣接4マスに存在する通路の数を返す / Count the number of "corridor" grids adjacent to the given grid.

引数
y1基準となるマスのY座標
x1基準となるマスのX座標
戻り値
通路の数
覚え書き
Assumes "in_bounds(y1, x1)"

XXX XXX This routine currently only counts actual "empty floor"
grids which are not in rooms. We might want to also count stairs,
open doors, closed doors, etc.

呼出しグラフ:

static int next_to_walls ( int  y,
int  x 
)
static

上下左右の外壁数をカウントする / Count the number of walls adjacent to the given grid.

引数
y基準のy座標
x基準のx座標
戻り値
隣接する外壁の数
覚え書き
Assumes "in_bounds(y, x)"

We count only granite walls and permanent walls.

呼出しグラフ:

bool place_quest_monsters ( void  )

クエストに関わるモンスターの配置を行う / Place quest monsters

戻り値
成功したならばTRUEを返す

関数の呼び出しグラフ:

呼出しグラフ:

static bool possible_doorway ( int  y,
int  x 
)
static

ドアを設置可能な地形かを返す / Determine if the given location is "between" two walls, and "next to" two corridor spaces.

引数
y判定を行いたいマスのY座標
x判定を行いたいマスのX座標
戻り値
ドアを設置可能ならばTRUEを返す
覚え書き
Assumes "in_bounds(y1, x1)"

XXX XXX XXX
Assumes "in_bounds(y, x)"

関数の呼び出しグラフ:

呼出しグラフ:

static void quest_gen ( void  )
static

固定マップクエストのフロア生成 / Generate a quest level

戻り値
なし

関数の呼び出しグラフ:

呼出しグラフ:

static void set_bound_perm_wall ( cave_type c_ptr)
static

マスにフロア端用の永久壁を配置する / Set boundary mimic and add "solid" perma-wall

引数
c_ptr永久壁を廃止したいマス構造体の参照ポインタ
戻り値
なし

関数の呼び出しグラフ:

呼出しグラフ:

static void try_door ( int  y,
int  x 
)
static

ドアの設置を試みる / Places door at y, x position if at least 2 walls found

引数
y設置を行いたいマスのY座標
x設置を行いたいマスのX座標
戻り値
なし

関数の呼び出しグラフ:

呼出しグラフ:

void wipe_generate_cave_flags ( void  )

フロアに存在する全マスの記憶状態を初期化する / Wipe all unnecessary flags after cave generation

戻り値
なし

呼出しグラフ:

変数

dun_data* dun

Dungeon generation data – see "cave_gen()".

int dun_tun_chg

ダンジョンの通路をクランクさせる頻度(一回の試行ごとにで判定している)

int dun_tun_con

ダンジョンの通路を継続して引き延ばす頻度(一回の試行ごとにで判定している)

int dun_tun_jct

ダンジョンの通路交差地点付近にドアを設置する頻度(一回の試行ごとにで判定している)

int dun_tun_pen

ダンジョンの部屋入口にドアを設置する頻度(一回の試行ごとにで判定している)

int dun_tun_rnd

ダンジョンの通路方向を掻き回す頻度(一回の試行ごとにで判定している)