Update: There are 6 mazes. They are included in the controller. There is a tar.gz of the mazes and their .bmp files here (dropbox). There is also a utility for making more mazes at that link (the maze_4.txt file is incorrect in archive). At this point, please feel free to run your own entry and update your score. Details on how to do so are included at the bottom. If you have questions or trouble, please ping me in chat.
You're a mouse. You're in a maze. Find the cheese.
Concept
You are in a maze that exists on a rectangular grid. Each space of the grid contains one of several things:
!
- An impassable wallO
- You, the mouse+
- The cheese, your goal
Please use the same characters so that I do not have to modify the controller.
On each turn, you will be given the tiles that are North, South, East, and West of your current position. You must then output the direction that you wish to travel. You win when you get to the cheese. Fewer steps is better.
Input
You will be given input through stdin in the following fashion: nesw
, where each letter represents the tile at that compass point. For example, if the current state looks like
! <--- Wall
!O <--- You
+ <--- Cheese
then you will be given the string ! +!
.
At the end of the game, the controller will send you a string of four zeroes: 0000
. Upon receiving this string, your program should terminate. No other input given will contain the 0
character.
Please ignore all other inputs.
Output
You are to output one letter n
, s
, e
, or w
, to indicate which direction you want to travel, followed by a new line character.
Scoring
Your score on each test is the number of steps it takes you to find the cheese.
Your overall score will be the sum of your average score per maze across a battery of mazes of variable sizes, all of which will fit inside a square of length 50.
For example, if it takes your bot 100 moves to complete each of the 6 mazes, then your score is 600.
If your bot is not deterministic, please try each maze 10 times and use average as the score for that maze. Your final score will be the sum of all the averages.
Rules
- Each maze will fit inside a 50x50 square.
- Each maze will have at least one valid path from start to cheese.
- Each maze will be entirely walled in, except that the cheese will always be on the outer wall so that it essentially serves as an exit to the maze.
- If you run into a wall, your submission is disqualified.
- If your submission takes too long (as determined by me, as I start testing), it will be disqualified. This is in large part to prevent infinite loops. The soft limit will be one minute per maze, although I reserve the right to change this at any time in either direction.
- Entries need not be deterministic, but if you are too random, you will likely be disqualified by the above point.
- At some point, the battery of mazes will be released, future answers may not optimize toward them, and they are subject to change.
Submissions:
Your submission is a full program that takes input via stdin and output via stdout. This is important because the submission will be interacting with the maze controller. I'm not going to ban languages that are not freely available, but know that someone else will have to offer their time to run the tests if I do not have access to the language.
Please include instructions on how to run your submission.
Please state whether your submission is deterministic or not, so that I know whether I need to run it multiple times.
Test Mazes
In the test mazes, .
characters outline the shortest route to the cheese. They are the same as the (space) character. They are not visible to your submission. The controller replaces them with spaces.
!!!!!!!!+!
!O..!....!
! !.!.! !!
! !.!.! !
! !.!.!! !
!!!.!.!! !
! .!.! !!
!!!... !
!!!!!!!!!!
31x31 test maze. Shamelessly stolen.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! O...!.......! ! .....!.....! ! ! !
!!!!!.!.! !!!.! !!! !.!!!.!.!!!.!!!!!!! !!! !!!!!!!!! !!! ! ! !
! !...! !.! !.! !.!.! !.! ! ! ! ! ! !
! !!!!! !!! !.!!!!!!!.! !.!.! !.! !!!!!!! !!! ! !!!!!!! !!! ! !
! ! !.........! !...!...! ! ! ! ! ! ! ! !
! !!! !!!!!!!!!!!!!!!!! !!!!!.!!! !!! !!! ! ! !!! !!! !!! !!! !
! ! ! ! !.....! ! ! ! ! ! ! ! ! !
!!!!!!!!!!! ! ! !!! !!! !.!!!!!!!!!!!!! ! !!! ! !!!!!!! !!! ! !
! ! ! !.! ! ! ! ! !
! !!!!!!! !!!!!!! !!!!!!!.! !!!!!!!!!!!!!!! !!!!!!! !!!!!!!!!!!
! ! ! ! ! !...!.! ! ! ! ! !
! !!! ! ! ! ! !!!!!!!.!.!.! !!!!!!!!! ! ! !!!!!!! ! ! !!!!!!! !
! ! ! ! ! !.!...! ! ! ! ! ! ! ! ! !
!!! ! !!!!! !!!!!!! !.!!!!!!! !!!!!!!!! !!! !!!!! ! !!! ! !!! !
! ! ! ! ! !...! ! ! ! ! ! ! ! !
! !!!!! ! ! ! !!!!!!!!!.! !!!!! !!! !!!!! !!!!!!!!!!! ! ! ! ! !
! ! ! ! ! !...! ! ! ! ! ! ! ! ! ! !
! !!!!!!!!! !!! ! ! !.!!! !!!!!!! ! !!!!!!! ! ! !!!!!!! !!! ! !
! ! ! !...! ! ! ! ! ! ! !
!!!!!!!!!!!!!!!!!!! !!!.!!!!!!! ! !!!!! ! !!! !!!!!!!!!!!!!!! !
! ! !...! ! ! ! ! ! !
! !!!!!!!!!!!!! ! ! !.!!! !!!!!!! !!!!!!!!! !!! !!! !!! ! !!! !
! ! ! ! ! !.! ! ! ! ! ! ! ! ! ! ! !
! ! ! !!!!! !!!!!!! !.! ! !!! ! ! ! ! !!! !!!!!!! !!! !!!!! !!!
! ! ! ! ! !.! ! ! ! ! ! ! ! ! !
!!!!! ! ! !!! !!! ! !.!!!!!!! !!!!!!! ! ! !!! ! !!!!!!!!! !!! !
! ! ! ! ! !.......! ! ! ! ! ! ! ! !
! !!!!! !!! !!! !!!!!!!!!!!.!!!!!!! ! ! ! !!!!!!! ! !!!!!!! ! !
! ! ! !...! ! ! ! ! ! ! ! !
!!!!!!!!!!! !!!!!!!!!!! !.!!! !!!!!!! ! !!!!! ! !!! !!!!!!!!! !
! ! ! ! !.! ! ! ! ! ! !
! !!!!!!! !!!!! ! !!! !!!.!!!!!!! ! !!!!! ! ! !!!!! ! !!!!!!!!!
! ! ! ! ! ! !.......! ! ! ! ! !
! ! !!! !!!!! ! !!! !!! !!!!!!!.! !!!!!!!!! !!!!!!!!!!!!!!!!! !
! ! ! ! ! ! ! !.! ! ! ! ! !
!!!!!!!!!!! ! !!! !!! ! ! ! !!!.! ! !!!!! !!! ! !!! ! !!!!!!! !
! ! ! ! ! !...! ! ! ! ! ! ! ! !
! !!!!!!!!!!! !!!!!!!!!!!!! !.!!! !!!!!!!!!!! ! ! ! ! !!! ! !!!
! ! ! ! !.! ! ! ! ! ! ! ! ! !
!!!!!!! !!! !!!!!!!!!!!!! ! !.! !!! ! !!!!!!! ! !!! !!!!! ! ! !
! ! ! ! ! !.! ! ! ! ! ! ! !
! !!!!!!! !!!!!!! ! !!!!! ! !.!!! !!!!!!! ! ! !!! !!!!!!!!!!!!!
! ! ! ! ! !.! ! ! ! !
! ! ! !!!!!!! ! ! !!! !!!!!!!.! !!!!!!!!!!! ! !!!!!!!!!!!!!!! !
! ! ! ! ! ! ! ! !.....! ! ! ! !...............!
! ! !!! !!! ! !!!!! !!! !.!!!!! ! ! ! !!!!!!! !.!!!!!!!!!!!!!.!
! ! ! ! ! ! !...! ! ! !.! !...!
!!!!! !!! ! !!! ! !!!!!!!!!.!!!!!!! !!!!!!!!!!!.!!!!! !!!!!.!!!
! ! ! ! ! !.......! !...!.....! .! !
! !!!!! !!!!! !!!!! !!!!! !!!!!!!.!!!!!!!!!.!.!!!!!.!!!!!!!.! !
! ! ! ! ! ! !...........!...!...!.....!...!
! !!!!!!!!! !!!!! ! !!! ! !!! ! !!!!!!!!!!!!!!!.!.!!!.!!!.!!!.!
! ! ! ! ! ! ! ! !.!..... !...!.!
!!! !!! !!!!!!!!! !!!!! !!!!!!!!! ! !!!!!!! !!!.! !!!!!!!!!.!.!
! ! ! ! ! ! ! ! ! !...! !.........!.!
! !!!!!!! ! ! ! ! !!! ! !!!!!!! ! !!!!!!!!! !.!!!!!.!!!!!!!!!.!
! ! ! ! ! ! ! ! ! ! !.!.....! !.!
! !!!!! !!!!!!!!! ! !!!!!!!!!!! !!! ! ! ! ! !.!.!!!!! !!!!! !.!
! ! ! ! ! ! ! ! ! !.!...! ! !.!
! ! !!!!!!!!!!!!!!!!! !!! !!!!! ! ! !!!!!!!!!.!!!.! !!!!!!!!!.!
! ! ! ! .....! .!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!+!
Controller
The controller is in Rust (1.11 Nightly)
type Maze = Vec<Vec<char>>;
fn str_to_maze(input: &str) -> Result<Maze,i32> {
let mut maze: Vec<Vec<char>> = vec![ vec![] ];
let mut row: Vec<char> = vec![];
for c in input.chars() {
if c == '!' || c == '+' || c == 'O' || c == ' ' {
row.push(c);
}
else if c =='.' {
row.push(' ');
}
else if c == '#' {
maze.push(row);
row = vec![];
}
else if c =='\0' {
break;
}
else {
println!("Bad character in maze: {}, exiting.", c);
return Err(1);
}
}
return Ok(maze);
}
fn display_maze(maze: &Maze, position: [usize;2]) {
for y in 0..maze.len() {
for x in 0..maze[y].len() {
if [x,y] == position {
print!("O");
}
else if maze[y][x] == '#' {
println!("\n");
}
else {
print!("{}",maze[y][x]);
}
}
println!("");
}
println!("\n");
}
fn get_starting_position(maze: &mut Maze) -> Result<[usize;2],&str> {
for y in 0..maze.len() {
for x in 0..maze[y].len() {
if maze[y][x] == 'O' {
maze[y][x] = ' ';
return Ok([x,y]);
}
}
}
return Err("No mouse found");
}
enum State {
Continue([char;4]),
Win,
Disqualify,
}
fn output(maze: &Maze, position: [usize;2]) -> State {
let x = position[0];
let y = position[1];
if maze[y][x] == '+' {
return State::Win;
}
else if maze[y][x] == '!' {
return State::Disqualify;
}
let n = maze[y-1][x];
assert!(y+1<maze.len());
let s = maze[y+1][x];
let w = maze[y][x-1];
assert!(x+1<maze[y].len());
let e = maze[y][x+1];
return State::Continue([n,e,s,w]);
}
fn get_input() -> char {
use std::io;
use std::io::Read;
let mut buffer: [u8;2] = [0;2];
io::stdin().read_exact(&mut buffer).unwrap();
//println!("{:?}", buffer); // to see exactly what the input is
return buffer[0] as char;
}
fn next_position(current_position: [usize;2], direction: char) -> Result<[usize;2],char> {
let mut x = current_position[0];
let mut y = current_position[1];
if direction == 'n' {
y -= 1;
}
else if direction == 'e' {
x += 1;
}
else if direction == 's' {
y += 1;
}
else if direction == 'w' {
x -= 1;
}
else {
return Err(direction);
}
return Ok([x,y]);
}
fn play(maze: &mut Maze) -> (State, usize) {
let mut position: [usize;2];
match get_starting_position(maze) {
Ok(pos) => position = pos,
Err(s) => {
println!("{}",s);
std::process::exit(2);
}
}
let mut moves = 0;
loop {
let state = output(maze, position);
/* uncomment below to view the maze at each step */
//display_maze(&maze, position);
/* ----------------------------------------------*/
match state {
State::Win => {
//println!("You found the cheese");
return(State::Win, moves);
}
State::Disqualify => {
//println!("You were disqualified");
return(State::Disqualify, moves);
}
State::Continue(out) => {
println!("{}{}{}{}",out[0],out[1],out[2],out[3]);
}
}
// only get here with Continue
let input = get_input();
moves += 1;
match next_position(position, input) {
Err(c) => {
println!("Invalid input: {}", c as u8);
return (State::Disqualify, moves);
}
Ok(next_pos) => position = next_pos,
}
}
}
fn main() {
let mut arg_counter = 0;
for argument in std::env::args() {
if arg_counter != 0 {
let mut maze = match argument.as_str(){
"1" => maze_1(),
"2" => maze_2(),
"3" => maze_3(),
"4" => maze_4(),
"5" => maze_5(),
"6" => maze_6(),
_ => {
println!("invalid input: {}, breaking", argument);
break;
}
};
let game_result = play(&mut maze);
println!("0000");
match game_result.0 {
State::Win => println!("WIN"),
State::Disqualify => println!("DISQUALIFY"),
_ => println!("Error"),
}
println!("moves: {}", game_result.1 );
}
arg_counter += 1;
}
}
fn maze_1() -> Maze {
let maze_str = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#\
!O ! ! !#\
!. ! !!!!!!!!!!!!!!!!!! ! !!!!!!#\
!. ! ! ! !#\
!. ! !!!!!!!!!!!!!!!!!!!! ! !! !#\
!. !........... ! !!.+#\
!. !.!!!!!!!!!.!!!!!!!!!!!!!!!.!#\
!.!..! ...............!.!#\
!.!.!! !!!!!!!!!!!!!!!!!!!!!.!.!#\
!.!.!! !!! ! .!.!#\
!.!.!! !!! !!!!!!!!!!!!!!!!.!.!#\
!...!! !!! .!.!#\
! ! !! !!! .!.!#\
! ! !! !!! !!!!!!!!! !!!!!!.!.!#\
! ! !! !!! ! !! ! .!.!#\
! ! !! !!! ! !!!!!!! ! .!.!#\
! ! !! !!! ! !! ! .!.!#\
! ! !! !!! ! !! ! .!.!#\
! ! !! ! ! !! ! .!.!#\
! ! !! ! ! !!!!!! !! ! .!.!#\
! ! !! ! ! ! !! ! ...!#\
! ! !! ! ! ! !! ! !#\
! ! !! ! ! ! !! ! ! !#\
! ! !! ! ! ! !!!!!! ! ! !#\
! ! !! ! ! ! !! ! ! !#\
! ! ! ! !! ! ! !#\
! !!!!!! !!!!!!!! !! ! ! !#\
! ! !! ! ! !#\
! !!!!!!!!!!! !!!! !! ! ! !#\
! ! ! !#\
! !!!!!!!! !!!! ! !#\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#\
";
match str_to_maze(&maze_str) {
Ok(x) => return x,
Err(i) => std::process::exit(i),
}
}
fn maze_2() -> Maze {
let maze_str = "!!!!!!!!!!!!!!!#\
! .......!#\
! !!! !.!!!! .!#\
! ! !.!!O!!.!#\
!!! !....! .!#\
! !!!!!!!!!.!#\
! !! ..!#\
! !!!!!!!!!.!!#\
! ..+#\
!!!!!!!!!!!!!!!#\
";
match str_to_maze(&maze_str) {
Ok(x) => return x,
Err(i) => std::process::exit(i),
}
}
fn maze_3() -> Maze {
let maze_str = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#\
! !!!#\
! ! !!! !!!!!!!!!!!!!!!!!! !#\
! ! ! !!! !!! ! !#\
! ! ! !!!!!!!!!!!!!!!! !! !#\
! ! ! !!!! !#\
! !! !!!!!!!!!! !! ! !#\
! ! ! !!!! !!!!! !!! !#\
!! ! ! !!!! ! ! !#\
!! ! ! !!!! !!!!!!!!!!!!!! ! !#\
!! ! ! !!!! ! ! ! !#\
!! ! ! !!!! ! ! !!!! ! ! !#\
!! ! ! !!!! ! ! ! !!! ! ! !#\
! ! ! !!!! ! ! ! !!! ! ! !#\
! ! ! !!!! ! ! !!!!! ! !#\
! ! ! !!!! !!! ! !! ! !!!#\
! ! ! !!! !! ! !!! ! !!!#\
! ! ! ! !! !!!! !! ! !!!#\
! ! !! ! !! ! !! ! !!!#\
! ! ! !! !! !!! ! !!!#\
! !! !!!! !!! !! ! !#\
!! ! !! ! !!! !! !!! !#\
!! ! ! ! ! !#\
!! !!!!!! !! !!!!!!!!!!! !#\
! !!!! !!!!!!!!!!! !#\
! ..........O!!!! !!!!!!!!!!!.+#\
!! .!!!!!! !! !!!!!!!!!!!.!#\
!! .! ! ! ! .!#\
!!..! !! ! !!! !! !!!.!#\
! .!! !!!! !!! !! !...!#\
! .! ! !! !! !!! !.!!!#\
! .! !! ! !! ! !! !.!!!#\
! .! ! ! !! !!!! !! !.!!!#\
! .! ! !!! !! ! !!! !.!!!#\
! .! ! !!!! !!! ! !! !.!!!#\
! .! ! !!!! ! ! !!!!! !...!#\
! .! ! !!!! ! ! ! !!! ! !.!#\
!!.! ! !!!! ! ! ! !!! ! !.!#\
!!.! ! !!!! ! ! !!!! ! !.!#\
!!.! ! !!!! ! ! !.!#\
!!.! ! !!!! !!!!!!!!!!!!!! !.!#\
!!.! ! !!!! ! ! .!#\
!..! ! !!!! !!!!! !!!.!#\
!.!! !!!!!!!!!! !! !.!#\
!.! ! !!!! .!#\
!.! ! !!!!!!!!!!!!!!!! !!.!#\
!.! ! !!! !!! !.!#\
!.! !!! !!!!!!!!!!!!!!!!!!...!#\
!............................!!!#\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#\
";
match str_to_maze(&maze_str) {
Ok(x) => return x,
Err(i) => std::process::exit(i),
}
}
fn maze_4() -> Maze {
let maze_str = "!!!!!!!!!!!!!!!!!+!!!!!!!!!!!!!!#\
!................. !!!#\
!.! !!! !!!!!!!!!!!!!!!!!! !#\
!.! ! !!! !!! ! !#\
!.! ! !!!!!!!!!!!!!!!! !! !#\
!.! ! !!!! !#\
!.!! !!!!!!!!!! !! ! !#\
!..! ! !!!! !!!!! !!! !#\
!!.! ! !!!! ! ! !#\
!!.! ! !!!! !!!!!!!!!!!!!! ! !#\
!!.! ! !!!! ! ! ! !#\
!!.! ! !!!! ! ! !!!! ! ! !#\
!!.! ! !!!! ! ! ! !!! ! ! !#\
! .! ! !!!! ! ! ! !!! ! ! !#\
! .! ! !!!! ! ! !!!!! ! !#\
! .! ! !!!! !!! ! !! ! !!!#\
! .! ! !!! !! ! !!! ! !!!#\
! .! ! ! !! !!!! !! ! !!!#\
! .! !! ! !! ! !! ! !!!#\
! .! ! !! !! !!! ! !!!#\
! .!! !!!! !!! !! ! !#\
!!. ! !! ! !!! !! !!! !#\
!!. ! ! ! ! !#\
!!. !!!!!! !! !!!!!!!!!!! !#\
! ........... !!!! !!!!!!!!!!! !#\
! . !!!! !!!!!!!!!!! !#\
!! !!!!!! . !! !!!!!!!!!!! !#\
!! ! ! . ! ! !#\
!! ! !! ! . !!! !! !!! !#\
! !! !!!! . !!! !! ! !#\
! ! ! !!.!! !!! ! !!!#\
! ! !! !.!! ! !! ! !!!#\
! ! ! !.!! !!!! !! ! !!!#\
! ! ! !!!..!! ! !!! ! !!!#\
! ! ! !!!!.!!! ! !! ! !!!#\
! ! ! !!!!.! ! !!!!! ! !#\
! ! ! !!!!.! ! ! !!! ! ! !#\
!! ! ! !!!!.! ! ! !!! ! ! !#\
!! ! ! !!!!.! ! !!!! ! ! !#\
!! ! ! !!!!.! ! ! !#\
!! ! ! !!!!. !!!!!!!!!!!!!! ! !#\
!! ! ! !!!!.....O! ! !#\
! ! ! !!!! !!!!! !!! !#\
! !! !!!!!!!!!! !! ! !#\
! ! ! !!!! !#\
! ! ! !!!!!!!!!!!!!!!! !! !#\
! ! ! !!! !!! ! !#\
! ! !!! !!!!!!!!!!!!!!!!!! !#\
! !!!#\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#\
";
match str_to_maze(&maze_str) {
Ok(x) => return x,
Err(i) => std::process::exit(i),
}
}
fn maze_5() -> Maze {
let maze_str = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#\
+......!!!! !!! !!! !!!! !!#\
! .! !! !!!!!#\
! !!!.! !! !!! !!!! !!!!!!!!! !!! !#\
! !!...! !!!!! !! ! !! !! !#\
!!!..!! ! !! ! ! ! !!#\
!! .!!........ !! !!! ! ! ! ! !!#\
!!!. !. ! !. ! !!!!! !! ! ! !! !!!#\
!!!. !. ! !. ! !!!!! ! !! ! !!!#\
!!.. !. ! !.. ! ! ! !! ! ! !!#\
!!.! !.! ! ! .. ! !!!!!! ! ! ! ! !!#\
!!.! !.! ! !! . ! ! ! ! ! ! !!#\
!!.! !.! ! ! . ! !! !! !!!! ! ! ! !!#\
!!.! !.!! ! ! . ! !!! !!!! ! ! !! !!#\
!!.! !. ! ! ! . ! !! ! ! ! ! !!#\
! .!!!. ! ! !!. ! ! ! ! ! ! !#\
! .!!!. ! ! !. ! ! ! ! ! ! !#\
! .! !. ! ! !. ! ! ! ! ! ! !#\
! .! !. ! !! !....!!! ! !! ! ! ! !#\
! .! ..! ! ! ...!!!! ! ! ! ! ! !#\
! .! .! ! !!!!!!.... !!!!!!! ! ! !#\
! .! !!.! !! ! !!!! .! !#\
! .!!!!.! !!!! !!! .! !!!!! !!!!!!!!!!! !#\
! .. !!.! !!! !! !.!! !#\
!!!.. !. ! !!! !..! !!! ! ! !#\
!!! .... ! !!!! ! .! ! !!#\
!!!!!!!!!!!!!!!!!!!!!!! .! !!!!!!!!!!!!!!!!!!!! !!#\
!!! ! .! !!!#\
!! ! !!! !! .! !!#\
!! ! ! !! !!!!!!.! !!!!!! !!#\
!! ! ! !! !!!!!!.! !!!!!!!! ! !!#\
!! ! ! !! !!!!!!!.! !!!!!! !! ! ! !!#\
!! ! ! ! !!!!!!!!.! !!! ! ! ! !!#\
!! ! ! ! !!!!!!!!!.! !!!! ! ! ! ! ! !!#\
!! ! ! ! .! !! ! ! ! ! !!#\
!! !!! ! ! !!!!!! .! ! !! !!#\
!! ! ! ! ! ! !!. ! !!! ! ! !!#\
!! ! ! ! ! ! ! . ! ! !! ! ! !!#\
!! ! ! ! ! ! !! !!. !!! !! ! ! ! !!#\
!! ! ! ! !! ! !!! ! ..... !! ! ! !!#\
!! ! ! ! ! ! !!!!!!! . ! ! !!#\
! ! ! ! ! ! !!! ! .!!!! ! ! !#\
! ! ! ! !! ! ! .! !!.......... !#\
! !! ! ! ! !!!!!!!!! .! !! .! !!!!. !#\
! ! ! ! !! !!! .!!!!! .. ! . !#\
! ! ! !! !!! !!! .......... !!!! . !#\
! ! ! !! !!!! !!!!!!!!!!!! !. !#\
! ! ! !!!!!! O. !#\
! ! !#\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#\
";
match str_to_maze(&maze_str) {
Ok(x) => return x,
Err(i) => std::process::exit(i),
}
}
fn maze_6() -> Maze {
let maze_str = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#\
! !!!! ....!!! !!! !!!! !!#\
! ! .!!.......... !!!!!#\
! !!! ! !! ...!!! !!!!. !!!!!!!!! !!! !#\
! !! ! !!!!!.. !! !. !! !! !#\
!!! !! !. !! !..... ! ! !!#\
!! !! .. !! !!! . ! ! ! ! !!#\
!!! ! ! ! .! !!!!! . !! ! ! !! !!!#\
!!! ! ! ! .! !!!!!. ! !! ! !!!#\
!! ! ! ! .! ! !. !! ! ! !!#\
!! ! ! ! ! ! . ! !!!!!! ! .. ! ! ! !!#\
!! ! ! ! ! !! . ! ! ! .....! ! ! !!#\
!! ! ! ! ! ! . ! !! !! !!!!.! ! ! !!#\
!! ! ! !! ! ! ..! !!! !!!! .! ! !! !!#\
!! ! ! ! ! ! .! !! ! .! ! ! !!#\
! !!! ! ! !! . ! ! ! .! ! ! !#\
! !!! ! ! ! ..! ! ! . ! ! ! !#\
! ! ! ! ! ! .! ! ! . ! ! ! !#\
! ! ! ! !! ! .!!! ! !! . ! ! ! !#\
! ! ! ! ! ...!!!! ! . ! ! ! ! !#\
! ! ! ! !!!!!!.... !!!!!!! . ! ! !#\
! ! !! ! !! ! !!!! .! . !#\
! !!!! ! !!!! !!! .! !!!!! .!!!!!!!!!!! !#\
! !! ! !!! !! !.!!.......... !#\
!!! ! ! !!! !. !. !!! ! ! !#\
!!! ! !!!! !. !. ! !!#\
!!!!!!!!!!!!!!!!!!!!!!!. !.!!!!!!!!!!!!!!!!!!!! !!#\
!!! ! . !.....................!!!#\
!! ! !!! !! O..... ! ..!!#\
!! ! ! !! !!!!!! ! !!!!!! .!!#\
!! ! ! !! !!!!!! ! !!!!!!!! ! .!!#\
!! ! ! !! !!!!!!! ! !!!!!! !! ! ! .!!#\
!! ! ! ! !!!!!!!! ! !!! ! ! ! .!!#\
!! ! ! ! !!!!!!!!! ! !!!! ! ! ! ! ! .!!#\
!! ! ! ! ! !! ! ! ! ! .!!#\
!! !!! ! ! !!!!!! ! ! !! .!!#\
!! ! ! ! ! ! !! ! !!! ! ! .!!#\
!! ! ! ! ! ! ! ! ! !! ! ! .!!#\
!! ! ! ! ! ! !! !! !!! !! ! ! ! .!!#\
!! ! ! ! !! ! !!! ! !! ! !.!!#\
!! ! ! ! ! ! !!!!!!! ! ! .!!#\
! ! ! ! ! ! !!! ! !!!! ! ! . !#\
! ! ! ! !! ! ! ! !! . !#\
! !! ! ! ! !!!!!!!!! ! !! ! !!!!. !#\
! ! ! ! !! !!! !!!!! ! . !#\
! ! ! !! !!! !!! ! !!!! . !#\
! ! ! !! !!!! !!!!!!!!!!!! !..+#\
! ! ! !!!!!! !#\
! ! ! !#\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#\
";
match str_to_maze(&maze_str) {
Ok(x) => return x,
Err(i) => std::process::exit(i),
}
}
To test the larger maze, simply replace the maze string in the maze_1
function. Make sure to append the correct #\
characters to each line.
Testing your entry
This script can be used to test entries
#!/bin/bash
mkfifo /tmp/pipe1
mkfifo /tmp/pipe2
for arg in "$@"; do
<path to controller> $arg < /tmp/pipe1 | tee /tmp/pipe2 trascript.txt &
( <path to entry> < /tmp/pipe2 | tee /tmp/pipe1 ) > /dev/null
done
rm /tmp/pipe1
rm /tmp/pipe2
For example, my script looks like:
#!/bin/bash
mkfifo /tmp/pipe1
mkfifo /tmp/pipe2
for arg in "$@"; do
./maze/target/release/maze $arg < /tmp/pipe1 | tee /tmp/pipe2 trascript.txt &
( ./maze_test/main < /tmp/pipe2 | tee /tmp/pipe1 ) > /dev/null
done
rm /tmp/pipe1
rm /tmp/pipe2
It is used in the following way:
./script <mazes to test>
For example
./script 1 2 3 4 5 6
It will print everything to the console as well as writing everything to a file called transcript.txt
For the purpose of developing your entry, you can uncomment the
display_maze(&maze, position)
line in the play
function. This will cause the controller to display the maze at each step.