Skip to main content
1 of 8
LiefdeWen
  • 3.9k
  • 16
  • 38

ASCII 2D game-map

Problem

Given input a where a is a grid of characters in any input format as long as it has only one element for each 'block' of the output.

And input b where b is a grid of numbers the same size as input a.

There are two types of road, a 1 represents a stone road marked by @ and a 2 represents a dirt road maked by #

  • A @ road is centered in the block and is size 6x6, if a road is adjacent, that side is extended to grid cell border
  • A # road is centered in the block is size 4x4, if a road is adjacent, that side is extended to grid cell border

Output a grid offset by linenumber of 8x8 of the ASCII character in input a and overlay a 'road' from input b e.g.

Input a=[[a,b,a],[b,a,b],[a,b,a]] b=[[1,1,1],[2,0,1],[2,0,0]]

Output:

Step 1: the grid (8x8 representation of input a)

aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
bbbbbbbbaaaaaaaabbbbbbbb
bbbbbbbbaaaaaaaabbbbbbbb
bbbbbbbbaaaaaaaabbbbbbbb
bbbbbbbbaaaaaaaabbbbbbbb
bbbbbbbbaaaaaaaabbbbbbbb
bbbbbbbbaaaaaaaabbbbbbbb
bbbbbbbbaaaaaaaabbbbbbbb
bbbbbbbbaaaaaaaabbbbbbbb
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa

Step 2: Overlay with roads represented by b:

aaaaaaaabbbbbbbbaaaaaaaa
a@@@@@@@@@@@@@@@@@@@@@@a
a@@@@@@@@@@@@@@@@@@@@@@a
a@@@@@@@@@@@@@@@@@@@@@@a
a@@@@@@@@@@@@@@@@@@@@@@a
a@@@@@@@@@@@@@@@@@@@@@@a
a@@@@@@@@@@@@@@@@@@@@@@a
a@@@@@@abbbbbbbba@@@@@@a
bb####bbaaaaaaaab@@@@@@b
bb####bbaaaaaaaab@@@@@@b
bb####bbaaaaaaaab@@@@@@b
bb####bbaaaaaaaab@@@@@@b
bb####bbaaaaaaaab@@@@@@b
bb####bbaaaaaaaab@@@@@@b
bbbbbbbbaaaaaaaab@@@@@@b
bbbbbbbbaaaaaaaabbbbbbbb
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa

Step 3: Offset each line with linenumber:

aaaaaaaabbbbbbbbaaaaaaaa
 a@@@@@@@@@@@@@@@@@@@@@@a
  a@@@@@@@@@@@@@@@@@@@@@@a
   a@@@@@@@@@@@@@@@@@@@@@@a
    a@@@@@@@@@@@@@@@@@@@@@@a
     a@@@@@@@@@@@@@@@@@@@@@@a
      a@@@@@@@@@@@@@@@@@@@@@@a
       a@@@@@@abbbbbbbba@@@@@@a
        bb####bbaaaaaaaab@@@@@@b
         bb####bbaaaaaaaab@@@@@@b
          bb####bbaaaaaaaab@@@@@@b
           bb####bbaaaaaaaab@@@@@@b
            bb####bbaaaaaaaab@@@@@@b
             bb####bbaaaaaaaab@@@@@@b
              bbbbbbbbaaaaaaaab@@@@@@b
               bbbbbbbbaaaaaaaabbbbbbbb
                aaaaaaaabbbbbbbbaaaaaaaa
                 aaaaaaaabbbbbbbbaaaaaaaa
                  aaaaaaaabbbbbbbbaaaaaaaa
                   aaaaaaaabbbbbbbbaaaaaaaa
                    aaaaaaaabbbbbbbbaaaaaaaa
                     aaaaaaaabbbbbbbbaaaaaaaa
                      aaaaaaaabbbbbbbbaaaaaaaa
                       aaaaaaaabbbbbbbbaaaaaaaa

Rules

  • No leading whitespace or newlines
  • Trailing whitespace and 1 new line allowed.
  • This is code-golf so shortest code wins

Here is an extra test case with all edge cases in I can think of.

LiefdeWen
  • 3.9k
  • 16
  • 38