Last active
September 9, 2015 12:06
-
-
Save netbrain/63ad3c3743d5ca5e9869 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Converts a maze to a string of the format: | |
▛▀▜▛▀▜▛▀▜▛▀▜▛▀▜▛▀▜▛▀▜▛▀▜▛▀▜▛▀▜▛▀▜▛▀▜▛▀▜▛▀▜▛▀▜ | |
▌· · ·▐▌· ·▐▌· · · · ·▐▌· · · ·▐▌·▐ | |
▙ ▟▙▄▟▙ ▟▙ ▟▙ ▟▙ ▟▙ ▟▙▄▟▙▄▟▙ ▟▙▄▟▙ ▟▙▄▟▙ ▟▙ ▟ | |
▛ ▜▛▀▜▛ ▜▛ ▜▛ ▜▛ ▜▛ ▜▛▀▜▛▀▜▛ ▜▛▀▜▛ ▜▛▀▜▛ ▜▛ ▜ | |
▌· ·▐▌· ·▐▌· ·▐▌·▐▌· ·▐▌· ·▐▌· ·▐▌· ·▐ | |
▙▄▟▙ ▟▙▄▟▙▄▟▙▄▟▙ ▟▙▄▟▙ ▟▙ ▟▙▄▟▙ ▟▙▄▟▙ ▟▙▄▟▙ ▟ | |
▛▀▜▛ ▜▛▀▜▛▀▜▛▀▜▛ ▜▛▀▜▛ ▜▛ ▜▛▀▜▛ ▜▛▀▜▛ ▜▛▀▜▛ ▜ | |
▌· ·▐▌· ·▐▌· ·▐▌· ·▐▌· ·▐▌· ·▐▌· ·▐▌·▐ | |
▙ ▟▙▄▟▙▄▟▙ ▟▙ ▟▙▄▟▙ ▟▙▄▟▙▄▟▙ ▟▙▄▟▙ ▟▙ ▟▙ ▟▙▄▟ | |
▛ ▜▛▀▜▛▀▜▛ ▜▛ ▜▛▀▜▛ ▜▛▀▜▛▀▜▛ ▜▛▀▜▛ ▜▛ ▜▛ ▜▛▀▜ | |
▌·▐▌· ·▐▌· · ·▐▌· ·▐▌· ·▐▌· ·▐▌·▐▌· ·▐ | |
▙ ▟▙ ▟▙ ▟▙▄▟▙▄▟▙▄▟▙▄▟▙ ▟▙ ▟▙▄▟▙ ▟▙▄▟▙▄▟▙▄▟▙ ▟ | |
▛ ▜▛ ▜▛ ▜▛▀▜▛▀▜▛▀▜▛▀▜▛ ▜▛ ▜▛▀▜▛ ▜▛▀▜▛▀▜▛▀▜▛ ▜ | |
▌· ·▐▌· ·▐▌· ·▐▌☉ ·▐▌· ·▐▌· ·▐▌· ·▐▌·▐ | |
▙▄▟▙▄▟▙▄▟▙ ▟▙ ▟▙ ▟▙ ▟▙▄▟▙▄▟▙ ▟▙▄▟▙ ▟▙ ▟▙ ▟▙ ▟ | |
▛▀▜▛▀▜▛▀▜▛ ▜▛ ▜▛ ▜▛ ▜▛▀▜▛▀▜▛ ▜▛▀▜▛ ▜▛ ▜▛ ▜▛ ▜ | |
▌· · ·▐▌· ·▐▌· ·▐▌·▐▌· ·▐▌· · ·▐▌· ·▐ | |
▙ ▟▙▄▟▙ ▟▙▄▟▙▄▟▙▄▟▙▄▟▙ ▟▙ ▟▙▄▟▙▄▟▙▄▟▙▄▟▙▄▟▙ ▟ | |
▛ ▜▛▀▜▛ ▜▛▀▜▛▀▜▛▀▜▛▀▜▛ ▜▛ ▜▛▀▜▛▀▜▛▀▜▛▀▜▛▀▜▛ ▜ | |
▌⚿ ·▐▌· · · · · ·▐▌· ·▐▌· ·▐▌·▐▌· ·▐ | |
▙ ▟▙ ▟▙▄▟▙▄▟▙▄▟▙▄▟▙▄▟▙▄▟▙▄▟▙ ▟▙ ▟▙▄▟▙ ▟▙ ▟▙▄▟ | |
▛ ▜▛ ▜▛▀▜▛▀▜▛▀▜▛▀▜▛▀▜▛▀▜▛▀▜▛ ▜▛ ▜▛▀▜▛ ▜▛ ▜▛▀▜ | |
▌·▐▌· ·▐▌· ·▐▌· ·▐▌· ·▐▌· ·▐▌·▐▌· ·▐▌·▐ | |
▙ ▟▙▄▟▙ ▟▙ ▟▙ ▟▙ ▟▙ ▟▙ ▟▙ ▟▙▄▟▙▄▟▙ ▟▙ ▟▙▄▟▙ ▟ | |
▛ ▜▛▀▜▛ ▜▛ ▜▛ ▜▛ ▜▛ ▜▛ ▜▛ ▜▛▀▜▛▀▜▛ ▜▛ ▜▛▀▜▛ ▜ | |
▌· ·▐▌· ·▐▌· ·▐▌· ·▐▌· ·▐▌· ·▐▌· ·▐▌·▐ | |
▙▄▟▙ ▟▙▄▟▙▄▟▙▄▟▙▄▟▙▄▟▙▄▟▙▄▟▙ ▟▙ ▟▙ ▟▙▄▟▙ ▟▙ ▟ | |
▛▀▜▛ ▜▛▀▜▛▀▜▛▀▜▛▀▜▛▀▜▛▀▜▛▀▜▛ ▜▛ ▜▛ ▜▛▀▜▛ ▜▛ ▜ | |
▌· · · · · · · · ·▐▌· ·▐▌· · · ·▐ | |
▙▄▟▙▄▟▙▄▟▙▄▟▙▄▟▙▄▟▙▄▟▙▄▟▙▄▟▙▄▟▙▄▟▙▄▟▙▄▟▙▄▟▙▄▟ | |
*/ | |
func MazeString(m mazelib.MazeI) string { | |
out := "" | |
str := make([][]string, m.Height()*3) | |
for i := 0; i < m.Height(); i++ { | |
str[i*3] = make([]string, m.Width()*3) | |
str[i*3+1] = make([]string, m.Width()*3) | |
str[i*3+2] = make([]string, m.Width()*3) | |
for j := 0; j < m.Width(); j++ { | |
room, _ := m.GetRoom(j, i) | |
str[i*3][j*3] = "▛" | |
str[i*3][j*3+1] = " " | |
str[i*3][j*3+2] = "▜" | |
str[i*3+2][j*3] = "▙" | |
str[i*3+2][j*3+1] = " " | |
str[i*3+2][j*3+2] = "▟" | |
str[i*3+1][j*3] = " " | |
str[i*3+1][j*3+2] = " " | |
str[i*3+1][j*3+1] = " " | |
if room.Walls.Top { | |
str[i*3][j*3+1] = "▀" | |
} | |
if room.Walls.Bottom { | |
str[i*3+2][j*3+1] = "▄" | |
} | |
if room.Walls.Left { | |
str[i*3+1][j*3] = "▌" | |
} | |
if room.Walls.Right { | |
str[i*3+1][j*3+2] = "▐" | |
} | |
if room.Visited { | |
str[i*3+1][j*3+1] = "·" | |
} | |
if room.Treasure { | |
str[i*3+1][j*3+1] = "⚿" | |
} else if room.Start { | |
str[i*3+1][j*3+1] = "⚑" | |
} | |
x, y := m.Icarus() | |
if x == j && y == i { | |
str[i*3+1][j*3+1] = "☉" | |
} | |
} | |
} | |
for x := 0; x < len(str); x++ { | |
for y := 0; y < len(str[x]); y++ { | |
out += str[x][y] | |
} | |
out += "\n" | |
} | |
return out | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment