/// <summary> /// Default constructor of the class,which will define the correct configration of rule factory and neighbourrule factory. /// </summary> /// <param name="grid">collectiion of cells</param> /// <param name="ruleFactory"> Factory to create rule. </param> /// <param name="neighbourRule">Factory to create neighbour rule.</param> public GameOfLife(ICellCollection grid, IRuleFactory ruleFactory, INeighbourRuleFactory neighbouruleFactory) { this.generationNumber = 1; this.grid = grid; this.ruleFactory = ruleFactory; this.neighbouruleFactory = neighbouruleFactory; }
public bool CalcCellCollection(ICellCollection cellCollection) { var changed = false; for (var i = 0; i < Size - 1; i++) { var cc = cellCollection.Cells[i]; if (cc.Value.HasValue) { continue; } var gList = new List <Cell> { cc }; for (var k = i + 1; k < Size; k++) { var ck = cellCollection.Cells[k]; if (ck.Value.HasValue) { continue; } if (cc.Possibilities.SequenceEqual(ck.Possibilities)) { gList.Add(ck); } } if (gList.Count != cc.Possibilities.Count) { break; } for (var k = i + 1; k < Size; k++) { var ck = cellCollection.Cells[k]; if (ck.Value.HasValue || gList.Contains(ck)) { continue; } cc.Possibilities.ForEach(p => { var ch = ck.Possibilities.Remove(p); if (!changed && ch) { changed = true; } if (ck.Possibilities.Count == 1) { ck.SetValue(ck.Possibilities[0]); ck.Possibilities.Clear(); } }); } } if (!Changed) { Changed = changed; } return(changed); }
public Board(ICellCollection cellCollection, IGameState gameState, IPrinter printer) { _cellCollection = cellCollection; _gameState = gameState; _printer = printer; }
public PossibleWins(ICellCollection cells) : this( new TopRightSlashWin(cells), new TopLeftSlashWin(cells), new RightColumnWin(cells), new CenterColumnWin(cells), new LeftColumnWin(cells), new BottomRowWin(cells), new CenterRowWin(cells), new TopRowWin(cells)) { }
public static bool TryGetCellCollection(this IControl control, out ICellCollection cellCollection) { var selectRange = (SelectionRange)control.FindControl(c => c is SelectionRange); if (selectRange != null) { return(control.MyAskMeAnything.TryGetCellCollection((selectRange).CurrentSelection, out cellCollection)); } cellCollection = null; return(false); }
public void CalculateCell(ICellCollection cellCollection) { cellCollection.Cells.ForEach(c => { if (c == this) { return; } if (c.Value != null) { Possibilities.Remove(c.Value.Value); } }); }
public void Clone_ShouldClone() { //Arrange ICell expected = Cell0; ICell[] cells = { expected }; CellCollection subject = new CellCollection(cells); //Act ICellCollection actual = subject.Clone(); //Assert ReferenceEquals(subject, actual).Should().BeFalse(); ReferenceEquals(subject.At(new IntOf(0)), actual.At(new IntOf(0))).Should().BeTrue(); }
public void AvailableSpaces_ShouldHaveOnlyAvailableCells() { //Arrange FakePrinter fakePrinter = new FakePrinter.Builder().Build(); FakeGameState fakeGameState = new FakeGameState.Builder().Build(); FakeCell fakeCell = new FakeCell.Builder().IsSelected(Bool.False).Build(); FakeCell fakeCellSelected = new FakeCell.Builder().IsSelected(Bool.True).Build(); Board subject = new Board(new CellCollection(new ICell[] { fakeCell, fakeCellSelected }), fakeGameState, fakePrinter); //Act ICellCollection actual = subject.AvailableSpaces(); //Assert ((int)actual.Count()).Should().Be(1); }
public RightColumnWin(ICellCollection cells) : base(cells, TopRight, MiddleRight, BottomRight) { }
public CenterColumnWin(ICellCollection cells) : base(cells, TopCenter, MiddleCenter, BottomCenter) { }
public LeftColumnWin(ICellCollection cells) : base(cells, TopLeft, MiddleLeft, BottomLeft) { }
public BottomRowWin(ICellCollection cells) : base(cells, BottomLeft, BottomCenter, BottomRight) { }
public CenterRowWin(ICellCollection cells) : base(cells, MiddleLeft, MiddleCenter, MiddleRight) { }
public TopRowWin(ICellCollection cells) : base(cells, TopLeft, TopCenter, TopRight) { }
public IndexedCellEquality(ICellCollection cells, Int firstIndex, Int secondIndex) { _cells = cells; _firstIndex = firstIndex; _secondIndex = secondIndex; }
public Cell(ICellCollection neighbours) { _neighbours = neighbours; }
public BoardPrinter(ICellCollection cellBoard) : this(cellBoard, new ConsoleWriterBookEnd()) { }
public void LoadSheet(ICellCollection c) { m.Cells = (CellCollection)c; //change view! }
public TopLeftSlashWin(ICellCollection cells) : base(cells, TopLeft, MiddleCenter, BottomRight) { }
/// <summary> /// Right now it is creating predefine object of matrix class, here we can define configurable instance for /// given dimension type. /// </summary> /// <param name="cellCollection"></param> /// <returns></returns> public INeighbourRule Create(ICellCollection cellCollection) { return new MatrixNeighbourCellRule((Game)cellCollection); }
public BoardPrinter(ICellCollection cellBoard, IWriter writer) { _cellBoard = cellBoard; _writer = writer; }
private Board(ICellCollection cellCollection) : this( cellCollection, new GameState(cellCollection), new BoardPrinter(cellCollection)) { }
public AllCellsSelected(ICellCollection cellCollection) => _cellCollection = cellCollection;
public GameState(ICellCollection cellCollection) : this( new PossibleWins(cellCollection), new Tie(cellCollection)) { }
public bool TryGetCellCollection(string name, out ICellCollection cellCollection) { cellCollection = AskRadiant.GetCellCollections().Where(c => c.Name == name).SingleOrDefault(); return(cellCollection != null); }
public void LoadSheet(ICellCollection c) { foreach (System.Windows.Forms.Control ctr in mainForm.WorksheetsTabControl.SelectedTab.Controls) { if (ctr is SpreadsheetUserControl) { SpreadsheetUserControl ActiveWS = (SpreadsheetUserControl)ctr; ActiveWS.Spreadsheet.SpreadsheetModel.Cells = (CellCollection)c; //change view! } } }
public Tie(ICellCollection cellCollection) => _cellCollection = cellCollection;
protected Win(ICellCollection cells, Int firstIndex, Int secondIndex, Int thirdIndex) : this(new IndexedCellEquality(cells, firstIndex, secondIndex), new IndexedCellEquality(cells, firstIndex, thirdIndex)) { }
public TestWin(ICellCollection cells, int firstIndex, int secondIndex, int thirdIndex) : base(cells, new IntOf(firstIndex), new IntOf(secondIndex), new IntOf(thirdIndex)) { }
public Builder Clone(ICellCollection expected) { _cloneItem.UpdateInvocation(expected); return(this); }