Dungeon Crawler
Input
- A binary matrix $M$ representing the walls of a dungeon.
- The position $(x,y)$ of the player within the dungeon.
- The direction $d$ that the player is currently facing (0 = North, 1 = East, 2 = South, 3 = West)
Output
A pseudo-3D representation of the walls that are in the field of view of the player, as an ASCII art of $30times 10$ characters.
Below are several possible output frames, along with the corresponding map and compass to help getting the hang of it (but drawing the map and the compass is not part of the challenge).
Specification
Field of view
The player has $13$ walls in his field of view, labeled from $A$ to $M$. Below are the positions of the walls relative to the player (in yellow), in all possible directions.
Drawing the walls
The walls are supposed to be drawn from $A$ to $M$ in this exact order, given that any part drawn previously may be overwritten by closer walls. You may of course implement it differently as long as the final result is the same.
The entire output is drawn with 7 distinct characters: " "
, "'"
, "."
, "|"
, "-"
, "_"
and ":"
.
Because detailing the shapes of the walls in the body of this challenge would make it too lengthy, they are instead provided in the following TIO link:
Try it online!
The characters that are not part of a given wall are marked with a "?"
in these diagrams. They must be treated as 'transparent' characters that are not drawn at all. On the other hand, all spaces within a wall are 'solid' and must overwrite any other characters that may have been previously drawn there.
Rules
About the input
- You may take $M$, $x$, $y$ and $d$ in any reasonable format.
- You may use either 0-indexed or 1-indexed coordinates.
- You may use 4 distinct values of your choice for the directions.
- The matrix is guaranteed to be at least $3times 3$
- You may assume that there will always be surrounding walls on the edges.
- The player is guaranteed to be located on an empty square.
- The input is guaranteed to be valid.
About the output
- The walls must be drawn exactly as described.
- However, the output format is also flexible: single string, array of strings, matrix of characters, etc.
- Leading and trailing whitespace is acceptable as long as it's consistent.
This is code-golf.
Test cases
All test cases are using the following matrix:
[ [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ],
[ 1, 0, 1, 1, 1, 0, 0, 0, 0, 1 ],
[ 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 ],
[ 1, 0, 0, 0, 0, 0, 1, 1, 0, 1 ],
[ 1, 0, 0, 1, 0, 0, 0, 1, 0, 1 ],
[ 1, 0, 0, 1, 1, 0, 1, 1, 0, 1 ],
[ 1, 1, 1, 1, 0, 0, 0, 0, 0, 1 ],
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 ],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ]
The following inputs are using 0-indexed coordinates:
x=3, y=3, d=0
x=6, y=4, d=3
x=4, y=4, d=1
x=1, y=5, d=2
x=7, y=7, d=3
x=6, y=6, d=1
x=8, y=1, d=2
x=7, y=6, d=1
Expected outputs:
------------------------------ ------------------------------
x=3, y=3, d=0: x=6, y=4, d=3:
------------------------------ ------------------------------
__ __ '. .'
|'. .'| | |
| '.--------------.' | |----. |
| | | | | | '.--------. |
| | | | | | | | |
| | | | | | | | |
| | | | | | .'--------' |
| .'--------------'. | |----' |
__|.' '.|__ | |
.' '.
------------------------------ ------------------------------
x=4, y=4, d=1: x=1, y=5, d=2:
------------------------------ ------------------------------
.' __ ________________________ .'
| | |
-------. .----| | |
| '.--------.' | | | |
| | | | | | |
| | | | | | |
| .'--------'. | | | |
-------' '----| | |
| __|________________________|
'. '.
------------------------------ ------------------------------
x=7, y=7, d=3: x=6, y=6, d=1:
------------------------------ ------------------------------
'. '.
|'. |'.
| '. | '.
| | '. .- | |--.--------.--------.-
| | |: :| | | | | |
| | |: :| | | | | |
| | .' '- | |--'--------'--------'-
| .' | .'
|.' |.'
.' .'
------------------------------ ------------------------------
x=8, y=1, d=2: x=7, y=6, d=1:
------------------------------ ------------------------------
'. __ '.
|'. .'| |
| '. .' | |----.--------------.-------
| | '. .' | | | | |
| | |: :| | | | | |
| | |: :| | | | | |
| | .' '. | | | | |
| .' '. | |----'--------------'-------
|.' '.|__ |
.' .'
Related challenge:
This challenge from 2013 is closely related. But it has a different winning criterion (code-challenge), a much looser specification of the output, and requires interactive I/O.
code-golf ascii-art game binary-matrix
add a comment |
Input
- A binary matrix $M$ representing the walls of a dungeon.
- The position $(x,y)$ of the player within the dungeon.
- The direction $d$ that the player is currently facing (0 = North, 1 = East, 2 = South, 3 = West)
Output
A pseudo-3D representation of the walls that are in the field of view of the player, as an ASCII art of $30times 10$ characters.
Below are several possible output frames, along with the corresponding map and compass to help getting the hang of it (but drawing the map and the compass is not part of the challenge).
Specification
Field of view
The player has $13$ walls in his field of view, labeled from $A$ to $M$. Below are the positions of the walls relative to the player (in yellow), in all possible directions.
Drawing the walls
The walls are supposed to be drawn from $A$ to $M$ in this exact order, given that any part drawn previously may be overwritten by closer walls. You may of course implement it differently as long as the final result is the same.
The entire output is drawn with 7 distinct characters: " "
, "'"
, "."
, "|"
, "-"
, "_"
and ":"
.
Because detailing the shapes of the walls in the body of this challenge would make it too lengthy, they are instead provided in the following TIO link:
Try it online!
The characters that are not part of a given wall are marked with a "?"
in these diagrams. They must be treated as 'transparent' characters that are not drawn at all. On the other hand, all spaces within a wall are 'solid' and must overwrite any other characters that may have been previously drawn there.
Rules
About the input
- You may take $M$, $x$, $y$ and $d$ in any reasonable format.
- You may use either 0-indexed or 1-indexed coordinates.
- You may use 4 distinct values of your choice for the directions.
- The matrix is guaranteed to be at least $3times 3$
- You may assume that there will always be surrounding walls on the edges.
- The player is guaranteed to be located on an empty square.
- The input is guaranteed to be valid.
About the output
- The walls must be drawn exactly as described.
- However, the output format is also flexible: single string, array of strings, matrix of characters, etc.
- Leading and trailing whitespace is acceptable as long as it's consistent.
This is code-golf.
Test cases
All test cases are using the following matrix:
[ [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ],
[ 1, 0, 1, 1, 1, 0, 0, 0, 0, 1 ],
[ 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 ],
[ 1, 0, 0, 0, 0, 0, 1, 1, 0, 1 ],
[ 1, 0, 0, 1, 0, 0, 0, 1, 0, 1 ],
[ 1, 0, 0, 1, 1, 0, 1, 1, 0, 1 ],
[ 1, 1, 1, 1, 0, 0, 0, 0, 0, 1 ],
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 ],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ]
The following inputs are using 0-indexed coordinates:
x=3, y=3, d=0
x=6, y=4, d=3
x=4, y=4, d=1
x=1, y=5, d=2
x=7, y=7, d=3
x=6, y=6, d=1
x=8, y=1, d=2
x=7, y=6, d=1
Expected outputs:
------------------------------ ------------------------------
x=3, y=3, d=0: x=6, y=4, d=3:
------------------------------ ------------------------------
__ __ '. .'
|'. .'| | |
| '.--------------.' | |----. |
| | | | | | '.--------. |
| | | | | | | | |
| | | | | | | | |
| | | | | | .'--------' |
| .'--------------'. | |----' |
__|.' '.|__ | |
.' '.
------------------------------ ------------------------------
x=4, y=4, d=1: x=1, y=5, d=2:
------------------------------ ------------------------------
.' __ ________________________ .'
| | |
-------. .----| | |
| '.--------.' | | | |
| | | | | | |
| | | | | | |
| .'--------'. | | | |
-------' '----| | |
| __|________________________|
'. '.
------------------------------ ------------------------------
x=7, y=7, d=3: x=6, y=6, d=1:
------------------------------ ------------------------------
'. '.
|'. |'.
| '. | '.
| | '. .- | |--.--------.--------.-
| | |: :| | | | | |
| | |: :| | | | | |
| | .' '- | |--'--------'--------'-
| .' | .'
|.' |.'
.' .'
------------------------------ ------------------------------
x=8, y=1, d=2: x=7, y=6, d=1:
------------------------------ ------------------------------
'. __ '.
|'. .'| |
| '. .' | |----.--------------.-------
| | '. .' | | | | |
| | |: :| | | | | |
| | |: :| | | | | |
| | .' '. | | | | |
| .' '. | |----'--------------'-------
|.' '.|__ |
.' .'
Related challenge:
This challenge from 2013 is closely related. But it has a different winning criterion (code-challenge), a much looser specification of the output, and requires interactive I/O.
code-golf ascii-art game binary-matrix
This instantly reminded me of 3D Monster Maze, although that uses block graphics of course.
– Neil
4 hours ago
1
Your challenges are so fun and well-written!
– Oliver
3 hours ago
@Oliver Hey thanks! I've to say that I've spent an unusual (and unreasonable) amount of time on that one. It was fun to write, though. So I hope it will be fun to answer as well.
– Arnauld
3 hours ago
add a comment |
Input
- A binary matrix $M$ representing the walls of a dungeon.
- The position $(x,y)$ of the player within the dungeon.
- The direction $d$ that the player is currently facing (0 = North, 1 = East, 2 = South, 3 = West)
Output
A pseudo-3D representation of the walls that are in the field of view of the player, as an ASCII art of $30times 10$ characters.
Below are several possible output frames, along with the corresponding map and compass to help getting the hang of it (but drawing the map and the compass is not part of the challenge).
Specification
Field of view
The player has $13$ walls in his field of view, labeled from $A$ to $M$. Below are the positions of the walls relative to the player (in yellow), in all possible directions.
Drawing the walls
The walls are supposed to be drawn from $A$ to $M$ in this exact order, given that any part drawn previously may be overwritten by closer walls. You may of course implement it differently as long as the final result is the same.
The entire output is drawn with 7 distinct characters: " "
, "'"
, "."
, "|"
, "-"
, "_"
and ":"
.
Because detailing the shapes of the walls in the body of this challenge would make it too lengthy, they are instead provided in the following TIO link:
Try it online!
The characters that are not part of a given wall are marked with a "?"
in these diagrams. They must be treated as 'transparent' characters that are not drawn at all. On the other hand, all spaces within a wall are 'solid' and must overwrite any other characters that may have been previously drawn there.
Rules
About the input
- You may take $M$, $x$, $y$ and $d$ in any reasonable format.
- You may use either 0-indexed or 1-indexed coordinates.
- You may use 4 distinct values of your choice for the directions.
- The matrix is guaranteed to be at least $3times 3$
- You may assume that there will always be surrounding walls on the edges.
- The player is guaranteed to be located on an empty square.
- The input is guaranteed to be valid.
About the output
- The walls must be drawn exactly as described.
- However, the output format is also flexible: single string, array of strings, matrix of characters, etc.
- Leading and trailing whitespace is acceptable as long as it's consistent.
This is code-golf.
Test cases
All test cases are using the following matrix:
[ [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ],
[ 1, 0, 1, 1, 1, 0, 0, 0, 0, 1 ],
[ 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 ],
[ 1, 0, 0, 0, 0, 0, 1, 1, 0, 1 ],
[ 1, 0, 0, 1, 0, 0, 0, 1, 0, 1 ],
[ 1, 0, 0, 1, 1, 0, 1, 1, 0, 1 ],
[ 1, 1, 1, 1, 0, 0, 0, 0, 0, 1 ],
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 ],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ]
The following inputs are using 0-indexed coordinates:
x=3, y=3, d=0
x=6, y=4, d=3
x=4, y=4, d=1
x=1, y=5, d=2
x=7, y=7, d=3
x=6, y=6, d=1
x=8, y=1, d=2
x=7, y=6, d=1
Expected outputs:
------------------------------ ------------------------------
x=3, y=3, d=0: x=6, y=4, d=3:
------------------------------ ------------------------------
__ __ '. .'
|'. .'| | |
| '.--------------.' | |----. |
| | | | | | '.--------. |
| | | | | | | | |
| | | | | | | | |
| | | | | | .'--------' |
| .'--------------'. | |----' |
__|.' '.|__ | |
.' '.
------------------------------ ------------------------------
x=4, y=4, d=1: x=1, y=5, d=2:
------------------------------ ------------------------------
.' __ ________________________ .'
| | |
-------. .----| | |
| '.--------.' | | | |
| | | | | | |
| | | | | | |
| .'--------'. | | | |
-------' '----| | |
| __|________________________|
'. '.
------------------------------ ------------------------------
x=7, y=7, d=3: x=6, y=6, d=1:
------------------------------ ------------------------------
'. '.
|'. |'.
| '. | '.
| | '. .- | |--.--------.--------.-
| | |: :| | | | | |
| | |: :| | | | | |
| | .' '- | |--'--------'--------'-
| .' | .'
|.' |.'
.' .'
------------------------------ ------------------------------
x=8, y=1, d=2: x=7, y=6, d=1:
------------------------------ ------------------------------
'. __ '.
|'. .'| |
| '. .' | |----.--------------.-------
| | '. .' | | | | |
| | |: :| | | | | |
| | |: :| | | | | |
| | .' '. | | | | |
| .' '. | |----'--------------'-------
|.' '.|__ |
.' .'
Related challenge:
This challenge from 2013 is closely related. But it has a different winning criterion (code-challenge), a much looser specification of the output, and requires interactive I/O.
code-golf ascii-art game binary-matrix
Input
- A binary matrix $M$ representing the walls of a dungeon.
- The position $(x,y)$ of the player within the dungeon.
- The direction $d$ that the player is currently facing (0 = North, 1 = East, 2 = South, 3 = West)
Output
A pseudo-3D representation of the walls that are in the field of view of the player, as an ASCII art of $30times 10$ characters.
Below are several possible output frames, along with the corresponding map and compass to help getting the hang of it (but drawing the map and the compass is not part of the challenge).
Specification
Field of view
The player has $13$ walls in his field of view, labeled from $A$ to $M$. Below are the positions of the walls relative to the player (in yellow), in all possible directions.
Drawing the walls
The walls are supposed to be drawn from $A$ to $M$ in this exact order, given that any part drawn previously may be overwritten by closer walls. You may of course implement it differently as long as the final result is the same.
The entire output is drawn with 7 distinct characters: " "
, "'"
, "."
, "|"
, "-"
, "_"
and ":"
.
Because detailing the shapes of the walls in the body of this challenge would make it too lengthy, they are instead provided in the following TIO link:
Try it online!
The characters that are not part of a given wall are marked with a "?"
in these diagrams. They must be treated as 'transparent' characters that are not drawn at all. On the other hand, all spaces within a wall are 'solid' and must overwrite any other characters that may have been previously drawn there.
Rules
About the input
- You may take $M$, $x$, $y$ and $d$ in any reasonable format.
- You may use either 0-indexed or 1-indexed coordinates.
- You may use 4 distinct values of your choice for the directions.
- The matrix is guaranteed to be at least $3times 3$
- You may assume that there will always be surrounding walls on the edges.
- The player is guaranteed to be located on an empty square.
- The input is guaranteed to be valid.
About the output
- The walls must be drawn exactly as described.
- However, the output format is also flexible: single string, array of strings, matrix of characters, etc.
- Leading and trailing whitespace is acceptable as long as it's consistent.
This is code-golf.
Test cases
All test cases are using the following matrix:
[ [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ],
[ 1, 0, 1, 1, 1, 0, 0, 0, 0, 1 ],
[ 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 ],
[ 1, 0, 0, 0, 0, 0, 1, 1, 0, 1 ],
[ 1, 0, 0, 1, 0, 0, 0, 1, 0, 1 ],
[ 1, 0, 0, 1, 1, 0, 1, 1, 0, 1 ],
[ 1, 1, 1, 1, 0, 0, 0, 0, 0, 1 ],
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 ],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ]
The following inputs are using 0-indexed coordinates:
x=3, y=3, d=0
x=6, y=4, d=3
x=4, y=4, d=1
x=1, y=5, d=2
x=7, y=7, d=3
x=6, y=6, d=1
x=8, y=1, d=2
x=7, y=6, d=1
Expected outputs:
------------------------------ ------------------------------
x=3, y=3, d=0: x=6, y=4, d=3:
------------------------------ ------------------------------
__ __ '. .'
|'. .'| | |
| '.--------------.' | |----. |
| | | | | | '.--------. |
| | | | | | | | |
| | | | | | | | |
| | | | | | .'--------' |
| .'--------------'. | |----' |
__|.' '.|__ | |
.' '.
------------------------------ ------------------------------
x=4, y=4, d=1: x=1, y=5, d=2:
------------------------------ ------------------------------
.' __ ________________________ .'
| | |
-------. .----| | |
| '.--------.' | | | |
| | | | | | |
| | | | | | |
| .'--------'. | | | |
-------' '----| | |
| __|________________________|
'. '.
------------------------------ ------------------------------
x=7, y=7, d=3: x=6, y=6, d=1:
------------------------------ ------------------------------
'. '.
|'. |'.
| '. | '.
| | '. .- | |--.--------.--------.-
| | |: :| | | | | |
| | |: :| | | | | |
| | .' '- | |--'--------'--------'-
| .' | .'
|.' |.'
.' .'
------------------------------ ------------------------------
x=8, y=1, d=2: x=7, y=6, d=1:
------------------------------ ------------------------------
'. __ '.
|'. .'| |
| '. .' | |----.--------------.-------
| | '. .' | | | | |
| | |: :| | | | | |
| | |: :| | | | | |
| | .' '. | | | | |
| .' '. | |----'--------------'-------
|.' '.|__ |
.' .'
Related challenge:
This challenge from 2013 is closely related. But it has a different winning criterion (code-challenge), a much looser specification of the output, and requires interactive I/O.
code-golf ascii-art game binary-matrix
code-golf ascii-art game binary-matrix
asked 4 hours ago
Arnauld
72.1k688302
72.1k688302
This instantly reminded me of 3D Monster Maze, although that uses block graphics of course.
– Neil
4 hours ago
1
Your challenges are so fun and well-written!
– Oliver
3 hours ago
@Oliver Hey thanks! I've to say that I've spent an unusual (and unreasonable) amount of time on that one. It was fun to write, though. So I hope it will be fun to answer as well.
– Arnauld
3 hours ago
add a comment |
This instantly reminded me of 3D Monster Maze, although that uses block graphics of course.
– Neil
4 hours ago
1
Your challenges are so fun and well-written!
– Oliver
3 hours ago
@Oliver Hey thanks! I've to say that I've spent an unusual (and unreasonable) amount of time on that one. It was fun to write, though. So I hope it will be fun to answer as well.
– Arnauld
3 hours ago
This instantly reminded me of 3D Monster Maze, although that uses block graphics of course.
– Neil
4 hours ago
This instantly reminded me of 3D Monster Maze, although that uses block graphics of course.
– Neil
4 hours ago
1
1
Your challenges are so fun and well-written!
– Oliver
3 hours ago
Your challenges are so fun and well-written!
– Oliver
3 hours ago
@Oliver Hey thanks! I've to say that I've spent an unusual (and unreasonable) amount of time on that one. It was fun to write, though. So I hope it will be fun to answer as well.
– Arnauld
3 hours ago
@Oliver Hey thanks! I've to say that I've spent an unusual (and unreasonable) amount of time on that one. It was fun to write, though. So I hope it will be fun to answer as well.
– Arnauld
3 hours ago
add a comment |
1 Answer
1
active
oldest
votes
Clean (with Snappy), 800 785 670 644 bytes
460 402 bytes of code + 360 242-byte string literal
(escaped here and on TIO because it isn't valid UTF-8)
You can verify the length of the literal here.
import StdEnv,Data.List,Data.Maybe,Codec.Compression.Snappy,Text
@a b|b<'~'=b=a
$m x y d=map(@' ')(foldl(a b=[@u v\u<-a&v<-b])['~~'..][join['
']k\Just(Just 1)<-[mapMaybe(e=e!?(x+[u,v,~u,~v]!!d))(m!?(y+[~v,u,v,~u]!!d))\u<-[-2,2,-1,1,0,-1,1,0,-1,1,0,-1,1]&v<-[3,3,3,3,3,2,2,2,1,1,1,0,0]]&k<-nub[q\w<-split"#"(snappy_uncompress"2116444141415556404140174725460554740414141434141411765655r12456404117617440r141747272r47r4635722513110341252435113176253113311224r1522056404040412121710404756311444017412614456472174471741340r22025242111252502536011125253376302130253331112447414143137137111542041404017447r3441157534111153361721134564741137137174564713472043176176401371321440417521176113565150116137635376351263513234720137174414347101337517441133122410564740"),q<-let l=[[c\c<-:rpad s 30'~']\s<-split"!"w]in[l,map reverse l]]])
Try it online!
Snappy compression actually does pretty well in this case, despite being speed-focused, because there are so many single-character runs in the string being compressed.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "200"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f177893%2fdungeon-crawler%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Clean (with Snappy), 800 785 670 644 bytes
460 402 bytes of code + 360 242-byte string literal
(escaped here and on TIO because it isn't valid UTF-8)
You can verify the length of the literal here.
import StdEnv,Data.List,Data.Maybe,Codec.Compression.Snappy,Text
@a b|b<'~'=b=a
$m x y d=map(@' ')(foldl(a b=[@u v\u<-a&v<-b])['~~'..][join['
']k\Just(Just 1)<-[mapMaybe(e=e!?(x+[u,v,~u,~v]!!d))(m!?(y+[~v,u,v,~u]!!d))\u<-[-2,2,-1,1,0,-1,1,0,-1,1,0,-1,1]&v<-[3,3,3,3,3,2,2,2,1,1,1,0,0]]&k<-nub[q\w<-split"#"(snappy_uncompress"2116444141415556404140174725460554740414141434141411765655r12456404117617440r141747272r47r4635722513110341252435113176253113311224r1522056404040412121710404756311444017412614456472174471741340r22025242111252502536011125253376302130253331112447414143137137111542041404017447r3441157534111153361721134564741137137174564713472043176176401371321440417521176113565150116137635376351263513234720137174414347101337517441133122410564740"),q<-let l=[[c\c<-:rpad s 30'~']\s<-split"!"w]in[l,map reverse l]]])
Try it online!
Snappy compression actually does pretty well in this case, despite being speed-focused, because there are so many single-character runs in the string being compressed.
add a comment |
Clean (with Snappy), 800 785 670 644 bytes
460 402 bytes of code + 360 242-byte string literal
(escaped here and on TIO because it isn't valid UTF-8)
You can verify the length of the literal here.
import StdEnv,Data.List,Data.Maybe,Codec.Compression.Snappy,Text
@a b|b<'~'=b=a
$m x y d=map(@' ')(foldl(a b=[@u v\u<-a&v<-b])['~~'..][join['
']k\Just(Just 1)<-[mapMaybe(e=e!?(x+[u,v,~u,~v]!!d))(m!?(y+[~v,u,v,~u]!!d))\u<-[-2,2,-1,1,0,-1,1,0,-1,1,0,-1,1]&v<-[3,3,3,3,3,2,2,2,1,1,1,0,0]]&k<-nub[q\w<-split"#"(snappy_uncompress"2116444141415556404140174725460554740414141434141411765655r12456404117617440r141747272r47r4635722513110341252435113176253113311224r1522056404040412121710404756311444017412614456472174471741340r22025242111252502536011125253376302130253331112447414143137137111542041404017447r3441157534111153361721134564741137137174564713472043176176401371321440417521176113565150116137635376351263513234720137174414347101337517441133122410564740"),q<-let l=[[c\c<-:rpad s 30'~']\s<-split"!"w]in[l,map reverse l]]])
Try it online!
Snappy compression actually does pretty well in this case, despite being speed-focused, because there are so many single-character runs in the string being compressed.
add a comment |
Clean (with Snappy), 800 785 670 644 bytes
460 402 bytes of code + 360 242-byte string literal
(escaped here and on TIO because it isn't valid UTF-8)
You can verify the length of the literal here.
import StdEnv,Data.List,Data.Maybe,Codec.Compression.Snappy,Text
@a b|b<'~'=b=a
$m x y d=map(@' ')(foldl(a b=[@u v\u<-a&v<-b])['~~'..][join['
']k\Just(Just 1)<-[mapMaybe(e=e!?(x+[u,v,~u,~v]!!d))(m!?(y+[~v,u,v,~u]!!d))\u<-[-2,2,-1,1,0,-1,1,0,-1,1,0,-1,1]&v<-[3,3,3,3,3,2,2,2,1,1,1,0,0]]&k<-nub[q\w<-split"#"(snappy_uncompress"2116444141415556404140174725460554740414141434141411765655r12456404117617440r141747272r47r4635722513110341252435113176253113311224r1522056404040412121710404756311444017412614456472174471741340r22025242111252502536011125253376302130253331112447414143137137111542041404017447r3441157534111153361721134564741137137174564713472043176176401371321440417521176113565150116137635376351263513234720137174414347101337517441133122410564740"),q<-let l=[[c\c<-:rpad s 30'~']\s<-split"!"w]in[l,map reverse l]]])
Try it online!
Snappy compression actually does pretty well in this case, despite being speed-focused, because there are so many single-character runs in the string being compressed.
Clean (with Snappy), 800 785 670 644 bytes
460 402 bytes of code + 360 242-byte string literal
(escaped here and on TIO because it isn't valid UTF-8)
You can verify the length of the literal here.
import StdEnv,Data.List,Data.Maybe,Codec.Compression.Snappy,Text
@a b|b<'~'=b=a
$m x y d=map(@' ')(foldl(a b=[@u v\u<-a&v<-b])['~~'..][join['
']k\Just(Just 1)<-[mapMaybe(e=e!?(x+[u,v,~u,~v]!!d))(m!?(y+[~v,u,v,~u]!!d))\u<-[-2,2,-1,1,0,-1,1,0,-1,1,0,-1,1]&v<-[3,3,3,3,3,2,2,2,1,1,1,0,0]]&k<-nub[q\w<-split"#"(snappy_uncompress"2116444141415556404140174725460554740414141434141411765655r12456404117617440r141747272r47r4635722513110341252435113176253113311224r1522056404040412121710404756311444017412614456472174471741340r22025242111252502536011125253376302130253331112447414143137137111542041404017447r3441157534111153361721134564741137137174564713472043176176401371321440417521176113565150116137635376351263513234720137174414347101337517441133122410564740"),q<-let l=[[c\c<-:rpad s 30'~']\s<-split"!"w]in[l,map reverse l]]])
Try it online!
Snappy compression actually does pretty well in this case, despite being speed-focused, because there are so many single-character runs in the string being compressed.
edited 21 mins ago
answered 2 hours ago
Οurous
6,34811032
6,34811032
add a comment |
add a comment |
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f177893%2fdungeon-crawler%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
This instantly reminded me of 3D Monster Maze, although that uses block graphics of course.
– Neil
4 hours ago
1
Your challenges are so fun and well-written!
– Oliver
3 hours ago
@Oliver Hey thanks! I've to say that I've spent an unusual (and unreasonable) amount of time on that one. It was fun to write, though. So I hope it will be fun to answer as well.
– Arnauld
3 hours ago