using System.Collections.Generic;
public static void Main()
Console.WriteLine("Enter the amount of stepping stones. Enter ? for help:");
String s = Console.ReadLine();
"AGENT STARTS ON THIS ROW, JUMPS TO NEARBY ROCKS\n" +
"(0, 0) (1, 0) (2, 0) (3, 0) (4, 0) (5, 0) (6, 0) (7, 0) (8, 0) (9, 0)\n" +
"(0, 1) (1, 1) (2, 1) (3, 1) (4, 1) (5, 1) (6, 1) (7, 1) (8, 1) (9, 1)\n" +
"(0, 2) (1, 2) (2, 2) (3, 2) (4, 2) (5, 2) (6, 2) (7, 2) (8, 2) (9, 2)\n" +
"(0, 3) (1, 3) (2, 3) (3, 3) (4, 3) (5, 3) (6, 3) (7, 3) (8, 3) (9, 3)\n" +
"(0, 4) (1, 4) (2, 4) (3, 4) (4, 4) (5, 4) (6, 4) (7, 4) (8, 4) (9, 4)\n" +
"(0, 5) (1, 5) (2, 5) (3, 5) (4, 5) (5, 5) (6, 5) (7, 5) (8, 5) (9, 5)\n" +
"(0, 6) (1, 6) (2, 6) (3, 6) (4, 6) (5, 6) (6, 6) (7, 6) (8, 6) (9, 6)\n" +
"(0, 7) (1, 7) (2, 7) (3, 7) (4, 7) (5, 7) (6, 7) (7, 7) (8, 7) (9, 7)\n" +
"(0, 8) (1, 8) (2, 8) (3, 8) (4, 8) (5, 8) (6, 8) (7, 8) (8, 8) (9, 8)\n" +
"(0, 9) (1, 9) (2, 9) (3, 9) (4, 9) (5, 9) (6, 9) (7, 9) (8, 9) (9, 9)\n" +
"L__ AGENT WINS IF THEY GET TO HERE\n" +
int stoneCount = Int32.Parse(s);
bool[,] stones = new bool[10, 10];
List<Cell> stoneCells = new List<Cell>();
for (int i = 0; i < stoneCount; i++) {
Console.WriteLine("Enter stone position in \"x, y\":");
String input = Console.ReadLine();
String[] splits = {", "};
String[] inputs = input.Split(splits, System.StringSplitOptions.None);
int x = Int32.Parse(inputs[0]);
int y = Int32.Parse(inputs[1]);
stoneCells.Add(new Cell(x, y));
for(int x = 0; x < 10; x++) {
for(int y = 0; y < 10; y++) {
stoneCells.Add(new Cell(x, y));
for (int a = 0; a < stoneCells.Count; a++) {
Cell stoneA = stoneCells[a];
for (int b = 0; b < stoneCells.Count; b++) {
Cell stoneB = stoneCells[b];
if (CanJumpToCell(stoneB.x - stoneA.x, stoneB.y - stoneA.y))
stoneA.AddEdge(new Edge(a, b));
List<Cell> stonesCanReach = new List<Cell>();
foreach (Cell stone in stoneCells) {
stonesCanReach.Add(stone);
Console.WriteLine("There isn't even a rock for the Agent to start at!");
for(int i = 0; i < stoneCount + 4 && !youWin; i++) {
List<Cell> stonesCouldReach = new List<Cell>();
foreach(Cell thisStone in stonesCanReach) {
foreach(Cell thatStone in stoneCells) {
if (CanJumpToCell(thatStone.x - thisStone.x, thatStone.y - thisStone.y))
stonesCouldReach.Add(thatStone);
foreach(Cell thatStone in stonesCouldReach) {
if (!stonesCanReach.Exists(x => x == thatStone)) {
stonesCanReach.Add(thatStone);
if (thatStone.y >= 5 && !youWin) {
Console.WriteLine("Congratulations, with your help, the Agent escaped!");
foreach (Cell stone in stonesCanReach) {
Console.WriteLine("("+stone.x+", "+stone.y+")");
Console.WriteLine("The Agent never found a path out of there... YOU LOSE");
public static bool CanJumpToCell(int x, int y) {
bool in4x4 = (x*x <= 16 && y*y <= 16);
bool notCorner = (x*x + y*y < 32);
bool onAxis = (x*x == 25 && y == 0) || (y*y == 25 && x == 0);
return (in4x4 && notCorner) || onAxis;
public static void PrintMat(bool[,] matrix) {
for (int y = 0; y < matrix.GetLength(1); y++) {
for (int x = 0; x < matrix.GetLength(0); x++) {
s += (matrix[x, y] ? "# " : ": ");
public List<Edge> edges = new List<Edge>();
public Cell(int X, int Y) {
public void AddEdge(Edge edge) {
public Edge(int a, int b) {