private PencilColumn getNextStep() { foreach (PencilColumn p in getPencilColumns()) { p.blueReset.Set(); p.redReset.WaitOne(); //if (currentPlayer == Player.BLUE) //{ // p.redReset.WaitOne(); // p.blueReset.Set(); //} //else //{ // p.blueReset.WaitOne(); // p.redReset.Set(); //} } Thread.Sleep(250); PencilColumn preferred = getPreferredColumn(); if (preferred == null) { preferred = getRandomColumn(); } return(preferred); }
private void doNextStep(PencilColumn nextColumn) { int pencilsToPaint = nextColumn.getXorResult(); if (pencilsToPaint == -1) { pencilsToPaint = random.Next(nextColumn.getAvailablePencils()); } nextColumn.paintPencils(pencilsToPaint, currentPlayer); }
private void gameLoop() { while (!didWin()) { PencilColumn nextColumn = getNextStep(); doNextStep(nextColumn); } finishGame(); }
private void resetBoard() { flowLayoutPanel1.Controls.OfType <Control>().ToList().ForEach((item) => { if (item is PencilColumn) { item.Dispose(); flowLayoutPanel1.Controls.Remove(item); } }); for (int i = 0; i < columns; i++) { int value = random.Next(11) + 1; PencilColumn pencil = new PencilColumn(value); flowLayoutPanel1.Controls.Add(pencil); } }