Exemple #1
0
        private void DuyetDong(OCo.CellValues player, ref BangDiem eBoard)
        {
            int rw, cl, ePC, eHuman;

            // Duyệt theo dòng
            for (rw = 0; rw < BoardSize; rw++)
            {
                for (cl = 0; cl < BoardSize - 4; cl++)
                {
                    ePC = 0; eHuman = 0;
                    // Duyệt 5 ô liên tiếp nhau
                    for (int i = 0; i < 5; i++)
                    {
                        if (BanCo.Cells[rw, cl + i] == OCo.CellValues.Player1)
                        {
                            eHuman++;
                        }
                        if (BanCo.Cells[rw, cl + i] == OCo.CellValues.Player2)
                        {
                            ePC++;
                        }
                    }

                    if (eHuman * ePC == 0 && eHuman != ePC)
                    {
                        for (int i = 0; i < 5; i++)
                        {
                            if (BanCo.Cells[rw, cl + i] == OCo.CellValues.None) // Nếu ô chưa được đánh
                            {
                                if (eHuman == 0)
                                {
                                    if (player == OCo.CellValues.Player1)
                                    {
                                        BangDiem.Diem[rw, cl + i] += MangDiemPhongNgu[ePC];
                                    }
                                    else
                                    {
                                        BangDiem.Diem[rw, cl + i] += MangDiemTanCong[ePC];
                                    }
                                }
                                if (ePC == 0)
                                {
                                    if (player == OCo.CellValues.Player2)
                                    {
                                        BangDiem.Diem[rw, cl + i] += MangDiemPhongNgu[eHuman];
                                    }
                                    else
                                    {
                                        BangDiem.Diem[rw, cl + i] += MangDiemTanCong[eHuman];
                                    }
                                }
                                if (eHuman == 4 || ePC == 4)
                                {
                                    BangDiem.Diem[rw, cl + i] *= 2;
                                }
                            }
                        }
                    }
                }
            }
        }