Skip to main content
6 of 8
deleted 86 characters in body
Pavel
  • 9.4k
  • 1
  • 52
  • 95

Generate a map for a rogue-like

#Today, we'll be generating a map for a rogue-like RPG! ##Example Map:

##########
####    F#
####    ##
##    C#C#
#     ## #
# C   #E #
####  #  #
#        #
#P       #
##########

# are walls, P is the player's starting location, F is the finish that must be reached, C are coins that can be collected, and E are enemies that can be fought.

##Map specifications:

  • Height and Width should both be between 10 and 39, inclusive. Height does not have to equal width.
  • The maps borders should be filled in with walls.
  • P should be placed in the bottom left corner.
  • F should be placed in the top right corner.
  • There should be between 1 and 3 enemies.
  • There should be between 2 and 4 coins.
  • There should be some amount of walls in the middle. There should be a path to get from P to Every C, E, and F, keeping in mind that the player cannot move diagonally.
  • Every possible combination should have some chance of occurring.

##Rules

  • Fewest byte program wins.
  • Your program should not take any input.
  • Your program may not exit with an error (non-fatal output is STDERR is ok, but we can't have our rogue-like crash after map generation!)
  • A single trailing newline is allowed and trailing space is allowed.
  • No other output is allowed.
Pavel
  • 9.4k
  • 1
  • 52
  • 95