Skip to content

Instantly share code, notes, and snippets.

@jbubriski
Created March 24, 2017 20:06
Show Gist options
  • Save jbubriski/e9b542ea5b6e2f42ddc231a34b738a2b to your computer and use it in GitHub Desktop.
Save jbubriski/e9b542ea5b6e2f42ddc231a34b738a2b to your computer and use it in GitHub Desktop.
Dijkstra's Algorithm Setup.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CallStackExample
{
class Program
{
public class Cell
{
public int X { get; set; }
public int Y { get; set; }
}
static void Main(string[] args)
{
var grid = GetGrid();
var startCell = new Cell { X = 1, Y = 1 };
var endCell = new Cell { X = 8, Y = 8 };
var path = GetShortestPath(startCell, endCell);
// TODO: Verify that the path is what we expect
// TODO: Or at least that the length is what we expect
}
private static CellType[,] GetGrid()
{
var grid = new CellType[10, 10];
// Wall moving across
grid[3, 6] = CellType.Closed;
grid[4, 6] = CellType.Closed;
grid[5, 6] = CellType.Closed;
grid[6, 6] = CellType.Closed;
grid[7, 6] = CellType.Closed;
// Wall moving down
grid[7, 5] = CellType.Closed;
grid[7, 4] = CellType.Closed;
return grid;
}
private static List<Cell> GetShortestPath(Cell start, Cell end)
{
var path = new List<Cell>();
// TODO: Do it
return path;
}
public enum CellType
{
Open = 0,
Closed = 1,
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment