public static void amen(Tile tile, List <Tile> comp, List <List <Tile> > board) { Bros colorbros = createColorGroup(tile, comp, board); if (colorbros != null) { board = new List <List <Tile> >(colorbros.board); comp = new List <Tile>(colorbros.hand); } else { Bros straightbros = createStraightGroup(tile, comp, board); if (straightbros != null) { board = new List <List <Tile> >(straightbros.board); comp = new List <Tile>(straightbros.hand); } } /* if (!boolRemainder(board)) * { * * return; * * }*/ }
public static Bros disorder(List <Tile> outcomp, List <List <Tile> > outboard) { outboard.Capacity = 15; outcomp.Capacity = 15; inputboard = new List <List <Tile> >(outboard); inputcomp = new List <Tile>(outcomp); inputboard.Capacity = 15; inputcomp.Capacity = 15; List <List <Tile> > board = new List <List <Tile> >(inputboard); List <Tile> comp = new List <Tile>(inputcomp); notspecial = false; foreach (List <Tile> group in inputboard) { board = new List <List <Tile> >(inputboard); comp = new List <Tile>(inputcomp); board.Capacity = 15; comp.Capacity = 15; List <Tile> modifiedGroup = new List <Tile>(group); int length = group.Count; int count = 0; //foreach(Tile tile in group) for (int i = 0; i < group.Count; i++) { Bros colorbros = createColorGroup(modifiedGroup[i], comp, board); if (colorbros == null) { Bros straightbros = createStraightGroup(modifiedGroup[i], comp, board); if (straightbros == null) { break; } else { board = (straightbros.board); comp = (straightbros.hand); count++; } } else { board = (colorbros.board); comp = (colorbros.hand); count++; } } if (count == length && !boolRemainder(board)) { notspecial = true; return(new Bros(board, comp, null)); } } notspecial = true; return(null); }
/// <summary> /// suggestion button for the player. plays the move for him. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void suggestBtn_Click(object sender, EventArgs e) { reserveBoard = new List <List <Tile> >(boardLst); reserveComp = new List <Tile>(compLst); reserveHand = new List <Tile>(handLst); File.AppendAllText(path, Environment.NewLine + "---------------------PLAYER TURN---------------------" + Environment.NewLine + Environment.NewLine); File.AppendAllText(path, "------------------------BEFORE------------------------" + Environment.NewLine); UpdateBoard(); File.AppendAllText(path, "------------------------AFTER------------------------" + Environment.NewLine); AddMouseEventHandlerToHand(); boardTable.Visible = false; //Algorithm.Easy(boardLst, handLst); for (int j = 1; j <= 1; j++) { for (int i = 0; i < handLst.Count; i++) { Algorithm.amen(handLst[i], handLst, boardLst); } } //Algorithm.Easy(boardLst, handLst); List <List <Tile> > inputboard = new List <List <Tile> >(boardLst); List <Tile> inputcomp = new List <Tile>(handLst); Bros order = Algorithm.disorder(handLst, boardLst); if (order != null) { compLst = order.hand; boardLst = order.board; } boardTB(boardLst, 0); UpdateBoard(); WinOrLose(); boardTable.Visible = true; }