diff options
Diffstat (limited to 'vroomba-analysis/src/main.rs')
-rw-r--r-- | vroomba-analysis/src/main.rs | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/vroomba-analysis/src/main.rs b/vroomba-analysis/src/main.rs index e1d244b..3abcfc6 100644 --- a/vroomba-analysis/src/main.rs +++ b/vroomba-analysis/src/main.rs @@ -1,4 +1,4 @@ -use pathfinding::directed::astar; +use pathfinding::prelude::*; use std::path::PathBuf; use structopt::StructOpt; use vroomba::command::Command; @@ -18,10 +18,10 @@ fn main() { let initial_node = Node { state: global_json::read_initial_state_from_global_json_file(opt.path.to_str().unwrap()) .unwrap(), - last_command: Command::Nothing, + //last_command: Command::Nothing, }; - let shortest_path = astar::astar( + let shortest_path = astar( &initial_node, |node| { let player_moves = node.state.valid_moves(0); @@ -29,11 +29,11 @@ fn main() { .into_iter() .map(|player_move| { let mut state = node.state.clone(); - state.update([player_move, Command::Accelerate]); + state.update([player_move, Command::Decelerate]); ( Node { state, - last_command: player_move, + //last_command: player_move, }, 1, ) @@ -45,19 +45,20 @@ fn main() { ) .unwrap(); - println!( - "{:?}", - shortest_path - .0 - .into_iter() - .map(|node| node.last_command) - .collect::<Vec<_>>() - ); + // println!( + // "{:?}", + // shortest_path + // .0 + // .into_iter() + // .map(|node| node.last_command) + // .collect::<Vec<_>>() + // ); + println!("{:?}", shortest_path.0); println!("{}", shortest_path.1); } #[derive(Debug, Clone, Hash, PartialEq, Eq)] struct Node { state: GameState, - last_command: Command, + //last_command: Command, } |