public void ExtractColumn() { var RowRules = new List<List<int>>(); var ColumnRules = new List<List<int>>(); var model = new NonogramModel(3, 3, RowRules, ColumnRules); model[2, 0].State = BoardItemState.Marked; model[1, 1].State = BoardItemState.Marked; model[2, 1].State = BoardItemState.Marked; model[0, 2].State = BoardItemState.Marked; model[2, 2].State = BoardItemState.Marked; CollectionAssert.AreEqual(model.ExtractColumn(0), new List<int> { 1 }); CollectionAssert.AreEqual(model.ExtractColumn(1), new List<int> { 1 }); CollectionAssert.AreEqual(model.ExtractColumn(2), new List<int> { 3 }); }
public static NonogramModel GenerateRandom(int width, int height) { var model = new NonogramModel(width, height); Random rnd = new Random(); for (int row = 0; row < height; row += 1) { for (int column = 0; column < width; column += 1) { if (rnd.Next(2) == 0) { model[column, row] = new BoardItem { State = BoardItemState.Marked }; } } } for (int i = 0; i < width; i += 1) { model.ColumnRules.Add(model.ExtractColumn(i)); } for (int i = 0; i < height; i += 1) { model.RowRules.Add(model.ExtractRow(i)); } model.ClearBoard(); return model; }