File: random-maps

package info (click to toggle)
crossfire 1.11.0-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 24,456 kB
  • ctags: 7,800
  • sloc: ansic: 80,483; sh: 11,825; perl: 2,327; lex: 1,946; makefile: 1,149
file content (671 lines) | stat: -rw-r--r-- 23,156 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
Random Map Deployment Guide

 Using random maps:

  Any exit with "/!" as the destination map will generate a random map.
To specify random map parameters, you put parameters in the message field
for the exit.
To use the standalone random map generator, you do this:
random_map inputfile <map path>
where "inputfile" is a plaintext file containing the map parameters, andthat
<map path> is the destination of the generated map, relative to
LIBDIR/maps.

 How styles work:

  A "style" is usually a small map which contains only objects which
define the "style".  For example, a monsterstyle "orc" might be a map
generated with crossedit which has six orcs, a kobold, and a troll in it.
When monsters are placed, the generator will randomly choose monsters from the
"orc" style, and for this example, on average, it will generate 6 orcs/troll
and 1 kobold/troll.  So orcs will be very common, and there'll be occasional
trolls and kobolds.


  In principle, you may put any object in any style map.  However, the map
generator will do special things with the object depending on which directory
it is in.  Style maps are located in
maps/styles/*,
you may use crossedit to modify the style maps, or create new ones.


 Style Parameters::

  layoutstyle <style>	(special!) Pick the layout style for the map.  Currently, 
			"rogue", "spiral", "maze", "snake", "onion",
                        and "squarespiral"  are allowed. 
                        See below for more detail.

  floorstyle <style>	Load /styles/floorstyles/<style> and pick a random
			floortype from that style map for the random map.
			The entire map will be tiled with the floortype.

  multiple_floors <0/1> If set to 1, different rooms of the map will have
                        different floors (from the same map style though).
			This only works if there are doors, as the filling
			uses them to find rooms.

  wallstyle <style>	Load /styles/wallstyles/<style> and pick a random
			walltype from that style for the random map.  All
			the walls in the map will be of this type.  The walls
			are modified on insertion so that players cannot go
			through them:  this is expected for walls, but 
			the random map generator makes sure of it. A <style>
                        of "none" causes no walls or doors to be generated.

  doorstyle <style>	Load /styles/doorstyles/<style> and pick a random
			doortype from that style for the random map. A <style>
                        of "none" causes no doors to generated.

  exitstyle <style>	Put one or two exits in the map, one leading back
			to the map where we entered from (origin_map,
			origin_x, origin_y), and, if appropriate, one leading
			to another, harder, random map. A style of "none"
                        causes no exits to be generated.

  decorstyle <style>	Load /styles/decorstyles/<style> and pick the decor
			objects from that style to insert in the map.  Decor
			objects are modified on insertion so that they do
			NOT block movement, regardless of the archetype.
			They are placed randomly. A style of "none" causes no
                        decor objects to be generated.

  monsterstyle <style>  Load /styles/monsterstyles/<style>, if it exists.
			If it doesn't exist, then it will look for a directory
			of that name.  If it finds a directory, it will choose
			a style based on dungeon_level.  It will pick the style
			with the name <name>_# with the # closest to the 
			dungeon_level.  Monster objects are copied from the
			style map, so you may form style maps with modified 
			monsters which are weaker or stronger than the default 
			archetype.A style of "none" causes no monsters to be
                        generated.

  treasurestyle <style> (Special) If the style name chosen is contained in
			the lib/treasures file, it will use that for making
			treasures.  If it is NOT in the lib/treasures file, 
			it will look up /styles/treasurestyle/<style>, and
			pick random treasures from there.  If <style> matches
			neither of these, it will generate treasures
			using the "chest" treasurelist.  A style of "none"
			causes no treasures to be placed.



 Layout Parameters::


 'xsize'		size of the map:  if not set, random from 10 to 70


 'ysize'		size of the map:  if not set, random from 10 to 70


 'expand2x'             Do we double the size of the layout?  This has
                        the effect of increasing the corridor widths by about
                        2x.  Set it to a non-zero integer if this is desired.


 'symmetry <sym>'	symmetry of the layout:  You can cause the map generator
			to generate a symmetrical layout by using this flag.
			symmetry 0   random symmetry
			symmetry 1  no symmetry
			symmetry 2  symmetry about the vertical centerline
			symmetry 3  symmetry about the horizontal centerline
			symmetry 4  both 2 and 3 symmetry


  Layout Style:	Parameter:			Effect:

			
  maze		layoutoptions1 0 (default)	Sparse maze:  a maze with
						"rooms" will be made


  maze		layoutoptions1 1		Full maze:  a maze with
						no "open" spaces will be made.


   50% of the time a maze layout will be "doorified", meaning that doors
will be placed at random in the maze.


  onion		layoutoptions1 0 (default)	Pick random options
		See "Onion Rooms" below for
		the rest of the options.

  onion		layoutoptions2 0 (default)	Pick a random number of
						"onion layers"


 Map generation parameters:


  'difficulty'		Set the map difficulty.  Has no relation to the 
			"difficulty" defined in common/*.c.
			If nonzero, this map and its descendants will 
			have the same difficulty.  If zero, it'll be set
			to the value of dungeon_level and incremeneted with
			each recursive map.

  'difficulty_increase'	Sets how fast the difficulty increases.  This value
			is a float - the default value is 1.0.  Reducing
			This only applies to map without a default
			difficulty set (but that could change in the
			future).  For each level of a map, the difficulty
			is set to depth * difficulty_increase.  Setting
			this parameter to 0.5 (or other values between 0
			and 1) is a way to have deep dungeons that do not
			increase in difficulty all that rapidly.


  'dungeon_level'	Another way of setting the map difficulty.  This
			has no relation to the "difficulty" defined in
			the common/*.c source code.  The effect is to pick
			which monsters to use:  for example, if the 
			monsterstyle
			is "humanoid" and the dungeonlevel is 9, the style
			map /styles/monsterstyles/humanoid/humanoid_9 will be
			the style from which monsters are chosen.  After the
			monsters are placed, the map 
			difficulty is set according
			to the server's rule, for treasure purposes.

  'dungeon_depth'	The map generated will have an exit to another
			random map of the same style if 
			dungeon_level < dungeon_depth.  The next random map
			will have dungeon_level incremented.  If dungeon_level
			>= dungeon_depth, no exit to a more difficult map
			will be made.

  'orientation'		How the exits look:
			0		random "orientation"
			1		player arrives in the map at
					a "stairs up", he goes to harder
					levels by finding a "stairs down"
			2		reverse of 1
			3-6		exits are horizontal.  In the future
					these will be made to make exits to
					rightward, leftward, north and south.

  'origin_x'		<You shouldn't need to set this>  The exit which
			leads back from this map will go to this x.

  'origin_y'		Like origin_x

  'random_seed'		Set the random seed number used.  This number
			completely determines the random numbers:  a map
			with the same random seed and other parameters
			will always produce exactly the same map.

  'final_map'		When dungeon_level >= dungeon_depth, another exit
			isn't usually made.  However, if final_map is set
			to a map's name, then an exit to this map will
			be made.
			
  'exit_on_final_map'	The default action is to place an exit on
            the final map.  When explicitly set to 'no' this will 
			not place a return exit on the final_map.  
			If you use this setting YOU MUST PROVIDE A WAY BACK IN THE FINAL MAP!


 Misc. Parameters:


  'decoroptions' <option>	Currently, ignored.  Possibly in the future it
			will cause the decor to be patterned in some way,
			such as <put decor along walls> or <put decor
			in center of rooms>


  'treasureoptions' <opt>	Parameterizes how the treasure is placed and protected.
		0	choose random treasure options
		1	concentrate the treasure on the map in a few locations
		2	hide the treasure behind hidden doors
		4	put the treasure in a chest which must be unlocked.
			(a key will be placed somewhere in the map, probably
			in a monster.)
		8	Put locked doors around the treasure (a key to each
			door will be placed in a monster or somewhere reachable
			by the player:  one key on each side of the door.)
			In onion maps, the treasure is co-located with the
			exit to harder levels, so this makes the exit harder
			to get to.
		16	Trap the treasure.  A trap from /styles/trapstyles/traps
			is selected and inserted into the treasure chest.
		32	sparse treasure.  1/2 as much treasure is generated.
		64	rich treasure.  2x as much treasure is generated.

		If option 1 is not set, options 2-16 are ignored.  Options
		may be added together:  treasureoptions 3 means treasure
		optons 1 and 2 are set.
			
 Map Layout styles:


  Onion Maps:

   Onion rooms are like this::

    regular			   random
    centered, linear onion:        bottom/right centered, nonlinear:

    #########################     #########################
    #                       #     #                       #
    # ########  ##########  #     #   #####################
    # #                  #  #     #   #                   #
    # # ######  ######## #  #     #   #                   #
    # # #              # #  #     #   #   ######## ########
    # # # ####  ###### # #  #     #   #   #               #
    # # # #          # # #  #     #   #   #               #
    # # # ############ # #  #     #   #   #  ########### ##
    # # #              # #  #     #   #   #  #            #
    # # ################ #  #     #   #   #  #    #########
    # #                  #  #     #       #  #    #       #
    # ####################  #     #   #   #  #            #
    #                       #     #   #   #  #    #       #
    #########################     ######################### 

    options:
    0	Pick random options below
    1	"centered"
    2	linear doors (default is nonlinear)
    4	bottom "centered"
    8  	bottom-right centered
    16	outer wall off:  i.e., no outer wall.
    32	irregularly/randomly spaced layers (default: regular)


  Maze Maps:

   Maze maps are like this:

   A "sparse" maze::

    ########################################
    #   # # # #  #  #  #  #  #  #   #   #  #
    #         #  #  #     #  #  # # # # #  #
    ####   ## ## #  # ### #  ##   #   # # ##
    #  #####   # ## # # # ##  ### ##  ###  #
    ##              ### #  #       #       #
    #           ###     #  #    ####   ### #
    #           # ##    ## ##   #      # ###
    # ######    #  ###      #   # ##   #   #
    #      #   ##    ####   ##  #  #   # # #
    #  #  ##  ##  ##    ###  ## #  #   # # #
    #### ##  ##    ##     ##  ###  # ### ###
    #    #  ##      #####  #       ###     #
    ##  ##  #   ###     # ##              ##
    #  ##  ##  ## #    ## #           ###  #
    ## #   #   #  #    #  #           # ## #
    #  ### ### ## #   ## ##  ####    ##  # #
    ##   #   #  # #   #  #   #  #### #   ###
    #  ###  ## ## #   ## ##  ##    # ###   #
    ## #   ##  #  #    #  #   # # ##   #  ##
    #  #####  ## ## #### ##   # # #    ##  #
    ##        #  #  #    #   ## # ###      #
    #  # # #  #     # #  # #    #   #  # # #
    ########################################

   A "full" maze::

    ########################################
    #   #    # # #                 #       #
    #   # #  #   # # #  # # # # #    #  #  #
    ###   ## ##    ######## ### ### ### #  #
    #   # #     ##     #  ### ### #   ### ##
    # ##### ###  ##### ##         ## ## #  #
    #  #    # ## #   #  ##  ####   #  # # ##
    # #### ##  ### ####  # ##  ## ### # #  #
    #   #  #    #     #  ###    #   # #    #
    # ### ## ## ### ####      #### ## #  ###
    #  #  #  #    #  # ####  ##  # #  ## # #
    #  # ##  #### ##      # ##   # ##  #   #
    # ####  ## #   ### #### #  ### #  #### #
    #  #    #  # #   # #    # ##   #### #  #
    # #####   ####  ## ###    #  #      ## #
    #     ## ## #  ##    ##  ## ##### #  # #
    #  #   #  # ## #   #  # ##  # # ###  # #
    ## ### # ##  # # #### ###   # #   # ## #
    #  # # #    ## # #  #      ## ###   #  #
    ## # ####  ##  # #    ######  # # #### #
    #     # ####   # ######      ## ###  # #
    ### #      ## ##   #    # # ##         #
    #   #  # #    #  #    # # #    # #  #  #
    ########################################


  Spiral Maps:

   A Spiral Map::

    ###########################
    ###########################
    ########### D    ##########
    #########   ####   ########
    ########  ########  #######
    #######  ##########  ######
    ######  ############  #####
    ###### ####     #####D#####
    #####  ###  ###  ####  ####
    ##### #### #####  #### ####
    #####D#### ###### ####D####
    #####  ###  #C### #### ####
    ###### ####  >###D#### ####
    ######D########## ####D####
    ######  ########  ###  ####
    #######  ######  #### #####
    ######## D D  D ####  #####
    #################### ######
    ###################  ######
    #################   #######
    ################# <########
    ###########################
    ###########################

    layoutoptions1:

    0  pick random options
    1  Regular spiral:  distance increases constantly with angle
    2  Fine spiral:  most coils possible are fit in
    4  Fit Spiral:  scale spiral to fit rectanglar region
      (i.e., the spiral will look elliptical)


  Rogue-like Maps:

   A Rogue-like Map::

    ###############################
    #############       ###########
    #          ##       ###########
    #          DD       ###########
    #          ##       ###########
    #          ##       ####     ##
    #          #####D#######     ##
    #          D           D     ##
    ###D######D##### #######     ##
    ### ##       ###      ##     ##
    ###D D       ###       ###D####
    ### ##       D  D  <   ### ####
    ### ######D#####       ### ####
    ###D###### #####      #### ####
    ##    #### ##### #   ##### ####
    ##    #### ##### ######### ####
    ##    ####D##### ######### ####
    ##    ##     ### #     ### ####
    ##    ##     ### #     ###D####
    ##    ##     ### #     ###   ##
    ########     ### #     ###    #
    ########     D D D     ### >  #
    ########     #####     ###    #
    ########     #####     ###   ##
    ########     #####     ########
    ##################     ########
    ###############################

    layoutoptions1:

    0  pick random room shapes (i.e., mix it up)
    1  Always use rectangular rooms
    2  Always use "circular" rooms


  Snake layouts:

   No options are available for snake layouts.
   A player must touch every room to descend deeper in a snake.

   This is a basic snake layout::

    ############################
    #>                         #
    #                          #
    #                          #
    ##########################D#
    #                          #
    #                          #
    #                          #
    #D##########################
    #                          #
    #                          #
    #                          #
    ##########################D#
    #                          #
    #                          #
    #                          #
    #D##########################
    #                          #
    #                          #
    #                          #
    #                          #
    #                         <#
    ############################

   This is a roomified, xy-symmetric snake layout::

    ###################################
    #>       #     #   #     #       >#
    #        #     #   #     #        #
    ##D#######     D   D     #######D##
    #        #     #   #     #        #
    #        #     #   #     #        #
    #        D     # < #     D        #
    #        #     #   #     #        #
    #        #     #   #     #        #
    ##D#######     D   D     #######D##
    #        #     #   #     #        #
    #>       #     #   #     #       >#
    ###################################


  Square spirals

   No options are available for square spirals
   A player must touch every room to descend in a square spiral.

   This is a basic square spiral layout::

    ###############################
    #   #                         #
    #   D                         #
    #   #####################D#####
    #   #   #               #     #
    #   #   #               #     #
    #   #   D               #     #
    #   #   #############D###     #
    #   #   #   #       #   #     #
    #   #   #   #       #   #     #
    #   #   #   D       #   #     #
    #   #   #   #####D###   #     #
    #   #   #   # > #   #   #     # 
    #   #   #   D   #   #   #     #
    #   #   #########   #   #     #
    #   #   #       D   #   #     #
    #   #   #       #   #   #     #
    #   #   D       #   #   #     #
    #   #################   #     #
    #   #               D   #     #
    #   #               #   #     #
    #   D               #   #     #
    #########################     #
    #                       D     #
    #                       #     #
    #                       #     #
    #<                      #     #
    ###############################

   This is an xy-symmetric  square spiral layout::

    #####################################
    #             #   <   #             #
    ##D##########D#       #D##########D##
    #  #    #     ####D####     #    #  #
    #  ###DD###   #       #   ###DD###  #
    #  #   #> #   ##D###D##   # >#   #  #
    #  #   ####D###       ###D####   #  #
    #  #   D      #       #      D   #  #
    #  ############D#####D############  #
    #  D                             D  #
    #  #                             #  #
    #  D                             D  #
    #  ############D#####D############  #
    #  #   D      #       #      D   #  #
    #  #   ####D###       ###D####   #  #
    #  #   #> #   ##D###D##   # >#   #  #
    #  ###DD###   #       #   ###DD###  #
    #  #    #     ####D####     #    #  #
    ##D##########D#       #D##########D##
    #             #   <   #             #
    ##################################### 


 An example input file::

  layoutstyle onion
  monsterstyle humanoid
  dungeon_depth 3
  xsize 15
  ysize 15
  exitstyle cstair
  orientation 1
  decorstyle furniture
  floorstyle dirt
  wallstyle wooden
  symmetry 1


Below is the original proposal:

 Random Maps

  The major thing still missing from Crossfire, I think, is a good facility
for generating random maps:

  1.  They can be used by map creators to create a basic layout for his
quest or whatever, so that he need not start from a blank canvas.

  2.  Buildings with nothing else in them can have a random map in them.
In fact, we could have the same random map generated every time someone
enters a particular building (pick the seed off of the parent map name
and the entrance location!)  This would transform the world from finite
to infinite.

 Needed Features:

  Styles:

   Random maps would need to be "styled":  walls, doors, monsters, and other
decor should be picked from certain subsets of the total object set.  An inn
has a very different style than a castle, and from a dungeon, in both walls,
decor, and monsters.

  Ubiquity: (map configurable:  unspecified==no random maps)

   Any exit which does not have a destination specified should lead to
a random map, but WITH a sign saying "this is a random map".

  Identifiability:  (configurable)
 
   Random maps includes a sign 
which states that the map is random.

  Recursion:

   Random maps should optionally have another entrance to a random map of
the same style.  The depth of recursion should be specifiable.

  Difficulty:

   Difficulty should be specifiable.  Also, whether the map advances in
difficult with recursion should be specified.

  Quests:

   It would be cool if random quests could be implemented, too.  I won't
put this in immediately.

  Standalone operation:

   It'd be cool if the random map generator operated standalone, so that
map designers could use it easily as well as the server could at exits.

  Size:

   Random maps should be sized.  A big, multi-square exit should have a bigger
random map to it, while a small house should have a small interior.

  Inheritance: 
 
   The type and location of the exit should imply something about its random
interior.  A shop exit should have a shop interior, a house should have a
home interior, etc, a difficult map should have difficult sub-maps.

  Directedness:

   Buildings should have random maps with stairs up to the next random map,
dungeons with stairs down, etc.

 What does everyone think?  Anyone willing to help?  Has anyone already
 made so much progress on this that I should just help them instead of
 starting one myself?


 Algorithms:

  Maze algorithm:  start from a wall point, move forward left or right
or start from a new wall point, at random, recursively.  If blocked,
pop the stack until you can walk again.  If you return all the way,
a maze is generated.


  Specs for a room algorithm:
  Can you write for a function:

  char **room_gen_corridored(int xsize, int ysize, int option);

  which allocates and returns a char[xsize][ysize], with # being a wall
  and a char value of 0 indicating nothing.
  like::

   ######################
   #       #   #        #
   #       #   #        #
   #                    #
   #       #   #        #
   #########   ##########
   #       #   #        #
   #                    #
   #       #   #        #
   #       #   #        #
   #########   ##########
   #       #   #        #
   #                    #
   #       #   #        #
   ######################

   Some suggested options:
   option:
   0   random choice of one of the other options below *
   1   vertical centered corridor *
   2   horizontal centered corridor *
   4   vertical corridor on the right-hand wall *
   8   vertical corridor on the left-hand wall
   16  horizontal corridor on the bottom wall *
   32  horizontal corridor on the top wall

   The *'d ones are the important ones.

   Options 4 and 16 are important so I can easily create reasonable
  bilaterally and 4-way symmetric maps, as in a castle.

  If you're really ambitious, you could make it so you could ADD the
  options to get something like 10:  centered vertical corridor and right-hand
  corridor.

  One restriction you must satisfy, however, is that every place on the map
  be accessible from everywhere else.

  Feel free to contact me with any questons.

  peterm@langmuir.eecs.berkeley.edu