public static int Check(char[,] arrayMatrix, int currentRow, int currentCol, Helper.Direction direction) { try { Helper.Move(direction, ref currentRow, ref currentCol); if (arrayMatrix[currentRow, currentCol] == '1') { arrayMatrix[currentRow, currentCol] = '0'; return(1); } return(-1); } catch (Exception) { return(-2); } }
static void Main() { char[,] matrix = Helper.FillMatrix(8, 16); Dictionary <char, byte> obstacles = new Dictionary <char, byte>(); obstacles.Add('1', 1); int currentRow = 0; int currentCol = 0; int result = 0; //Helper.PrintMatrix(matrix, string.Empty); for (int col = 7; col >= 0; col--) { for (int i = 0; i < 8; i++) { if (matrix[i, col] == '1') { matrix[i, col] = '0'; int flight = 1; currentCol = col; currentRow = i; int borderCount = 0; Helper.Direction direction = Helper.Direction.NE; while (borderCount != 2) { int check = Helper.Check(obstacles, matrix, currentRow, currentCol, direction); switch (check) { case 1: { Helper.Move(direction, ref currentRow, ref currentCol); matrix[currentRow, currentCol] = '0'; result += flight * Splash(matrix, currentRow, currentCol); borderCount = 2; } break; case -1: { Helper.Move(direction, ref currentRow, ref currentCol); flight++; } break; case -2: { borderCount++; direction = Helper.Direction.SE; } break; } } // Console.WriteLine("-------------------------------------"); //Helper.PrintMatrix(matrix, string.Empty); //Console.WriteLine(result); continue; } } } for (int row = 0; row < matrix.GetLength(0); row++) { for (int col = 0; col < matrix.GetLength(1); col++) { if (matrix[row, col] == '1') { Console.WriteLine("{0} No", result); return; } } } Console.WriteLine("{0} Yes", result); }
public override void NextTurn() { base.NextTurn(); int lastX = X; int lastY = Y; List<int> dir = LibHelper.FlexibleNormalMovement(Game, this, Game.Player, false, false, true, CalculateDistance(Game.Player.X, Game.Player.Y) > 8); LastDirection = Helper.IntToDirection(dir); EntityManager[lastX, lastY, 1] = new EntityZombieTrail(Game); }
public override void NextTurn() { base.NextTurn (); string nextMove = ""; DistanceMax = CalculateDistance(Game.Player.X, Game.Player.Y); if (DistanceMax > 5) { nextMove = "attack"; } else if (DistanceMax <= 5) { if (DistanceMax == 5) { nextMove = "stop"; } if (DistanceMax < 5) { nextMove = "flee"; } List<EntityWraithwing> w = new List<EntityWraithwing> (); for (int iY = 0; iY < Game.EntityManager.SizeY; iY++) { for (int iX = 0; iX < Game.EntityManager.SizeX; iX++) { if (Game.EntityManager[iX, iY, 0] is EntityWraithwing) { w.Add((EntityWraithwing) Game.EntityManager[iX, iY, 0]); } } } foreach (EntityWraithwing ww in w) { int d2 = ww.CalculateDistance(Game.Player.X, Game.Player.Y); int d3 = ww.CalculateDistance(X, Y); if (Math.Abs(DistanceMax - d2) <= 2 && d3 >= 3) { nextMove = "attack"; break; } } } List<int> dir; switch (nextMove) { case "attack": dir = Game.BrainYellow ? LibHelper.FlexibleNormalMovement(Game, this, Game.Player, false, true) : LibHelper.BeelineNormalMovement(Game, this, Game.Player, false, true); LastDirection = Helper.IntToDirection(dir); break; case "flee": dir = Game.BrainYellow ? LibHelper.FlexibleNormalMovement(Game, this, Game.Player, false, true, true, true) : LibHelper.BeelineNormalMovement(Game, this, Game.Player, false, true, true, true); LastDirection = Helper.IntToDirection(dir); break; } }
public override void NextTurn() { base.NextTurn (); List<int> dir = Game.BrainYellow ? LibHelper.FlexibleNormalMovement(Game, this, Game.Player) : LibHelper.BeelineNormalMovement(Game, this, Game.Player); LastDirection = Helper.IntToDirection(dir); }
public override void NextTurn() { base.NextTurn (); if (Awake == false) { CheckForPlayer(Direction); } if (!Awake) return; List<int> dir = Game.BrainYellow ? LibHelper.FlexibleNormalMovement(Game, this, Game.Player) : LibHelper.BeelineNormalMovement(Game, this, Game.Player); Direction = Helper.IntToDirection(dir); }