private SnakeAction RouteToAction(WeightedRoute best, BoardPoint start) { if (best != null) { var next = best.Route.Path.Skip(1).First(); Report(start, next, best); if (next.X < start.X) { return(new SnakeAction(false, Direction.Left)); } if (next.X > start.X) { return(new SnakeAction(false, Direction.Right)); } if (next.Y < start.Y) { return(new SnakeAction(false, Direction.Up)); } if (next.Y > start.Y) { return(new SnakeAction(false, Direction.Down)); } } return(new SnakeAction(false, Direction.Stop)); }
private void Report(BoardPoint start, BoardPoint next, WeightedRoute route, string name = "GOTO") => Console.WriteLine( $"{name} {route.Route.GoalElement} at {route.Route.GoalPoint}\t{start} -> {next}. L:{route.Route.Length} I:{route.Route.Income:00.0000} P:{route.LastPotentialIncome:00.0000}");