Board generation for CitadErl

When playing Citadel of Blood, it seemed to be quite trivial to just pick random pieces and check if they match existing board. Maybe checking adjacent fields is easy for computer but there are certain conditions where more distant blocks can determine what kinds of corridors should the new piece have. This is a problem to be solved later, for now I decided to stick to (almost) basic pieces generation.

I thought it would be best to avoid completely random generation and checking the new field against conditions. Maybe it is quite unlikely but in theory very specific requirements could lead to very long generation. Taking conditions into consideration at the very beginning leads to a more complicated and maybe less efficient code but the generation time won’t extend significantly. Of course without proper benchmarks it is difficult to tell. πŸ™‚

What generation function needs is a list of limits. For now it is a piece type (corridor/room) and a minimal counts for: any, “wide” and “narrow” passages. Wide passages are ordinary corridors and narrow are doorways usually leading to rooms. If no min. values are specified, any passage (or none) is added in every direction. I know that I have to prevent adding wide passages to rooms. πŸ™‚ If specific passages are defined, they are inserted in random nth free spot in passages list.

Thinking about potential algorithm for limits definition, led me to a conclusion that two conditions will/could be also necessary:

  • Piece must have adjacent/opposite passages of specific/any type
  • Piece musn’t have more than X passages of specific type

Perhaps condition list will grow so much, it will eventually become more efficient to just rely on brute-force generation from certain point?

For a moment I was tempted by complete board generation when the game starts but there is one rule in Citadel of Blood that makes it impossible: “When a piece can be inserted in many ways, it is up to players to choose the rotation they want.” Maybe I described CitadErl as “inspired by Citadel of Blood”, but this is a nice feature to have and by inspiration I rather meant creating a modular server which rules can be later extended or removed at developer’s will.

So, this is some start. What will come next? Well, I intend to improve monster generation (now it’s a bit bugged and incomplete) and dungeon level modifiers. Code should also have function specs included and more comments butI wanted so badly to commit something that works, I forgot about such details this time. πŸ˜‰

I am aware that not much was done since I announced the project but lack of time is quite common in case of hobby projects. 😦

This entry was posted in CitadErl, Erlang and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s