Light Mode
Dark Mode
mission idea "Vector Labyrinth"

I like labyrinth missions.

I would like to add one.

You are given your own coordinate and direction. You should draw a view with some (0-5) quadrangles.

I would like to get a feedback about a mission

specification

vector_labyrinth(your_x, your_y, your_dir) == [quadrangle_1, quadrangle_2..]
quadrangle == [[x1, y1], [x2, y2], [x3, y3], [x4, y4]]

examples

0 1 2 3 4 5
         /|
1-+-+-+-+ +  -----      vector_labyrinth(6, 2, "N") ==  [[[0,1],[1,1],[1,4],[0,4]],
| |     | |  -XXX-                                       [[5,0],[4,1],[4,4],[5,5]],
2 +     + +  -.@X-                                       [[1,1],[4,1],[4,4],[1,4]]]
| |     | |
3 +     + +  @: you
| |     | |  .: path
4-+-+-+-+-+  X: wall
         \|  -: anything
5         

0 1 2 3 4 5
|\
1 +     +-+  --X--      vector_labyrinth(10, 2, "E") == [[[0,0],[1,1],[1,4],[0,5]],
| |\   /| |  -X.X-                                       [[4,1],[5,1],[5,4],[4,4]],
2 + +-+ + +  -X@.-                                       [[1,1],[2,2],[2,3],[1,4]],
| | | | | |                                              [[2,2],[3,2],[2,3],[3,3]],
3 + +-+ + +  @: you                                      [[4,1],[3,2],[3,3],[4,4]]]
| |/   \| |  .: path
4 +     +-+  X: wall
|/           -: anything
5

0 1 2 3 4 5

1         +  X..X-      vector_labyrinth(6, 11, "S") == [[[0,2],[1,2],[0,3],[1,3]],
         /|  ....X                                       [[5,1],[4,2],[4,3],[5,4]],
2-+   +-+ +  -.@.-                                       [[3,2],[4,2],[3,3],[4,3]]]
| |   | | |
3-+   +-+ +  @: you
         \|  .: path
4         +  X: wall
             -: anything
5

initial code

LABYRINTH = [
'XXXXXXXXXXXXXXX',
'XXXXXXXXXXXXXXX',
'XX.....XXX..XXX',
'XX.....XXX.XXXX',
'XX...........XX',
'XXXX.XXXXXXX.XX',
'XXX..XXXXXXX.XX',
'XX....XXXXX..XX',
'XX....XXXXX..XX',
'XXXX.XXX.XX..XX',
'XXXX..XX.XXX.XX',
'XXXX.........XX',
'XXXXX....XXXXXX',
'XXXXXX..XXXXXXX',
'XXXXXXXXXXXXXXX',
'XXXXXXXXXXXXXXX',]

def vector_labyrinth(your_x, your_y, your_dir):
    return []

if __name__ == '__main__':

    to_set = lambda rects: set(map(lambda rect: frozenset(map(tuple, rect)), rects))

    assert to_set(vector_labyrinth(6, 2,"N")) == to_set([[[0,1],[1,1],[1,4],[0,4]],
                                                         [[5,0],[4,1],[4,4],[5,5]],
                                                         [[1,1],[4,1],[4,4],[1,4]]]), '1st'

    assert to_set(vector_labyrinth(10, 2,"E")) == to_set([[[0,0],[1,1],[1,4],[0,5]],
                                                          [[4,1],[5,1],[5,4],[4,4]],
                                                          [[1,1],[2,2],[2,3],[1,4]],
                                                          [[2,2],[3,2],[2,3],[3,3]],
                                                          [[4,1],[3,2],[3,3],[4,4]]]), '2nd'

    assert to_set(vector_labyrinth(6, 11,"S")) == to_set([[[0,2],[1,2],[0,3],[1,3]],
                                                          [[5,1],[4,2],[4,3],[5,4]],
                                                          [[3,2],[4,2],[3,3],[4,3]]]), '3rd'
    print('Check done.')
  • idea
Created: May 6, 2017, 12:41 p.m.
Updated: May 6, 2017, 12:44 p.m.
0
45
User avatar
kurosawa4434