public OCo Timkiemnuocdi() { OCo _ocoResult = new OCo(); long _Diem_Max = 0; for (int i = 0; i < _Banco.nRow; i++) { for (int j = 0; j < _Banco.nCol; j++) { if (_MangOco[i, j].Own == 0) { long _Diem_TC = DTC_DuyetDoc(i, j) + DTC_DuyetNgang(i, j) + DTC_DuyetCheoXuoi(i, j) + DTC_DuyetCheoNguoc(i, j); long _Diem_PT = DPT_DuyetNgang(i, j) + DPT_DuyetDoc(i, j) + DPT_DuyetCheoXuoi(i, j) + DPT_DuyetCheoNguoc(i, j); long _Diem_Tam_Thoi = _Diem_TC > _Diem_PT? _Diem_TC:_Diem_PT; long _Diem_Tong = (_Diem_PT + _Diem_TC) > _Diem_Tam_Thoi ? (_Diem_PT + _Diem_TC) : _Diem_Tam_Thoi; if (_Diem_Max < _Diem_Tong) { _Diem_Max = _Diem_Tong; _ocoResult = new OCo(_MangOco[i, j].Col, _MangOco[i, j].Row, _MangOco[i, j].Location, _MangOco[i, j].Own); } } } } return(_ocoResult); }
//Tạo ra mảng ô cờ trống, không có ai sở hữu public void InitArrayOco() { for (int i = 0; i < 12; i++) { for (int j = 0; j < 12; j++) { _MangOco[i, j] = new OCo(j, i, new Point(j * _Banco.getWidthOCo(), i * _Banco.getHeightOCo()), 0); } } }
//Tạo ra mảng ô cờ trống, không có ai sở hữu public void InitArrayOco() { for (int i = 0; i < 12; i++) { for (int j = 0; j < 12; j++) { _MangOco[i, j] = new OCo(j, i, new Point(j * _Banco.getWidthOCo(), i * _Banco.getHeightOCo()), 0); } } }
public void StartCom(int turn) { if (_CacNuocDaDi.Count == 0) { _Banco.drawChess(_Banco.nCol / 2, _Banco.nRow / 2, 2); _MangOco[_Banco.nCol / 2, _Banco.nRow / 2].Own = turn; _CacNuocDaDi.Add(_MangOco[_Banco.nCol / 2, _Banco.nRow / 2]); } else { OCo oco = Timkiemnuocdi(); if (_MangOco[oco.Row, oco.Col].Own == 0) { _Banco.drawChess(oco.Col, oco.Row, turn); _MangOco[oco.Row, oco.Col].Own = turn; _CacNuocDaDi.Add(_MangOco[oco.Row, oco.Col]); } } }
public OCo Timkiemnuocdi() { OCo _ocoResult = new OCo(); long _Diem_Max = 0; for (int i = 0; i < _Banco.nRow; i++ ) { for (int j = 0; j < _Banco.nCol; j++) { if (_MangOco[i,j].Own == 0) { long _Diem_TC = DTC_DuyetDoc(i, j) + DTC_DuyetNgang(i, j) + DTC_DuyetCheoXuoi(i, j) + DTC_DuyetCheoNguoc(i, j); long _Diem_PT = DPT_DuyetNgang(i, j) + DPT_DuyetDoc(i, j) + DPT_DuyetCheoXuoi(i, j) + DPT_DuyetCheoNguoc(i, j); long _Diem_Tam_Thoi = _Diem_TC > _Diem_PT? _Diem_TC:_Diem_PT; long _Diem_Tong = (_Diem_PT + _Diem_TC) > _Diem_Tam_Thoi ? (_Diem_PT + _Diem_TC) : _Diem_Tam_Thoi; if (_Diem_Max < _Diem_Tong) { _Diem_Max = _Diem_Tong; _ocoResult = new OCo(_MangOco[i,j].Col,_MangOco[i,j].Row,_MangOco[i,j].Location,_MangOco[i,j].Own); } } } } return _ocoResult; }