private void Print(int id, int length, Matrix matrix) { for (int i = 0; i < length; i++) { for (int j = 0; j < length; j++) { var isThereAreFood = matrix.EatMatrix.HasOneBite(new System.Drawing.Point(i, j)); var isThereAreCreature = matrix.Creatures[i, j] != null; var strokeColor = new Color(); var fillColor = new Color(); if (isThereAreCreature) { fillColor = Colors.Black; strokeColor = isThereAreFood ? Colors.YellowGreen : Colors.OrangeRed; } else { if (isThereAreFood) { fillColor = Color.FromArgb(50, 154, 205, 50); strokeColor = fillColor; } else { fillColor = Colors.White; strokeColor = fillColor; } } PaintSquareStroke(i, j, strokeColor, _squares); PaintSquareFill(i, j, fillColor, _squares); } } }
private void Start(object sender, RoutedEventArgs e) { var matrixSize = LogConstants.MatrixSize; var commandsForGetDirection = new GetDirectionAlgorithm().Algorithm; var commandsForGetAction = new GetActionAlgorithm().Algorithm; var creator = new CreatorOfCreature(commandsForGetAction, commandsForGetDirection); _matrix = new Matrix(matrixSize, matrixSize, creator, new FillingFromCornersByWavesStrategy()); _matrix.FillStartMatrixRandomly(); Print(_step, matrixSize, _matrix); }