19 using System.Collections.Generic;
33 public delegate
void ViewMsgDlg(
string title ,
string msg);
34 public delegate
void DrawSingle(
int y,
int x,
int sts,
int bk,
string text);
35 public delegate
void CurColMsg(
string text);
36 public delegate
void CurStsMsg(
string text);
60 set { _mReversi = value; }
65 set { _mSetting = value; }
70 set { _mCurColor = value; }
75 set { _mCpu = value; }
80 set { _mEdge = value; }
85 set { _mPassEnaB = value; }
90 set { _mPassEnaW = value; }
92 public int mGameEndSts
95 set { _mGameEndSts = value; }
100 set { _mPlayLock = value; }
102 public ViewMsgDlg viewMsgDlg
105 set { _viewMsgDlg = value; }
107 public DrawSingle drawSingle
110 set { _drawSingle = value; }
112 public CurColMsg curColMsg
115 set { _curColMsg = value; }
117 public CurStsMsg curStsMsg
120 set { _curStsMsg = value; }
171 int tmpCol = this.mCurColor;
174 if(this.mPlayLock == 1)
return;
176 if (this.mReversi.
getColorEna(
this.mCurColor) == 0) {
177 if (this.mReversi.
setMasuSts(
this.mCurColor, y, x) == 0) {
192 this.mCurColor = tmpCol;
218 this.mCurColor = tmpCol;
241 waitTime = this.mSetting.mPlayCpuInterVal;
243 System.Threading.Thread.Sleep(waitTime);
269 if (this.mReversi.
getColorEna(
this.mCurColor) != 0) {
279 if (cpuEna == 0)
break;
293 if (this.mGameEndSts == 0) {
294 this.mGameEndSts = 1;
297 System.Threading.Thread.Sleep(waitTime);
299 string tmpMsg1, tmpMsg2, msgStr;
303 tmpMsg1 =
"プレイヤー1 = " + blk.ToString() +
" プレイヤー2 = " + whi.ToString();
305 if (whi == blk) tmpMsg2 =
"引き分けです。";
306 else if (whi < blk) {
308 else tmpMsg2 =
"あなたの負けです。";
311 else tmpMsg2 =
"あなたの負けです。";
314 if (whi == blk) tmpMsg2 =
"引き分けです。";
315 else if (whi < blk) tmpMsg2 =
"プレイヤー1の勝ちです。";
316 else tmpMsg2 =
"プレイヤー2の勝ちです。";
318 msgStr = tmpMsg1 + tmpMsg2;
377 int cpuflg0, cpuflg1, cpuflg2, cpuflg3, mem, mem2, mem3, mem4, rcnt1, rcnt2, kadocnt, loop, pcnt, passCnt, othColor, othBet, ownBet, endZone;
389 loop = this.mSetting.mMasuCnt * this.mSetting.mMasuCnt;
394 othBet = this.mReversi.
getBetCnt(othColor);
397 if ((loop - (othBet + ownBet)) <= 16) endZone = 1;
398 for (var i = 0; i < loop; i++) {
405 for (var i = 0; i < this.mSetting.mMasuCnt; i++) {
406 for (var j = 0; j < this.mSetting.mMasuCnt; j++) {
410 this.mEdge[kadocnt].x = j;
411 this.mEdge[kadocnt].y = i;
414 this.mCpu[rcnt1].x = j;
415 this.mCpu[rcnt1].y = i;
432 if (cpuflg1 == 0 && cpuflg2 == 0) {
447 if (this.mReversi.
getPassEna(color, i, j) != 0) {
457 if (pcnt == 0 && passCnt == 0) {
461 var ownPointCnt = -1;
464 for (var i = 0; i < rcnt1; i++) {
466 tmpAnz = this.mReversi.
getPointAnz(color, this.mCpu[i].y, this.mCpu[i].x);
467 if (tmpAnz != null) {
468 if (badPoint == -1) {
469 badPoint = tmpAnz.badPoint;
470 goodPoint = tmpAnz.goodPoint;
471 pointCnt = tmpAnz.pointCnt;
472 ownPointCnt = tmpAnz.ownPointCnt;
477 if (tmpAnz.badPoint < badPoint) {
478 badPoint = tmpAnz.badPoint;
481 if (goodPoint < tmpAnz.goodPoint) {
482 goodPoint = tmpAnz.goodPoint;
485 if (tmpAnz.pointCnt < pointCnt) {
486 pointCnt = tmpAnz.pointCnt;
487 ownPointCnt = tmpAnz.ownPointCnt;
489 }
else if (tmpAnz.pointCnt == pointCnt) {
490 if (ownPointCnt < tmpAnz.ownPointCnt) {
491 ownPointCnt = tmpAnz.ownPointCnt;
498 if (this.mReversi.
getMasuStsEna(color,
this.mCpu[i].y,
this.mCpu[i].x) == 2) {
514 if (mem == -1) mem =
r.Next(rcnt1);
515 }
else if (kadocnt != 0) {
516 for (var i = 0; i < kadocnt; i++) {
518 tmpAnz = this.mReversi.
getPointAnz(color, this.mEdge[i].y, this.mEdge[i].x);
519 if (tmpAnz != null) {
520 if (badPoint == -1) {
521 badPoint = tmpAnz.badPoint;
522 goodPoint = tmpAnz.goodPoint;
523 pointCnt = tmpAnz.pointCnt;
524 ownPointCnt = tmpAnz.ownPointCnt;
529 if (tmpAnz.badPoint < badPoint) {
530 badPoint = tmpAnz.badPoint;
533 if (goodPoint < tmpAnz.goodPoint) {
534 goodPoint = tmpAnz.goodPoint;
537 if (tmpAnz.pointCnt < pointCnt) {
538 pointCnt = tmpAnz.pointCnt;
539 ownPointCnt = tmpAnz.ownPointCnt;
541 }
else if (tmpAnz.pointCnt == pointCnt) {
542 if (ownPointCnt < tmpAnz.ownPointCnt) {
543 ownPointCnt = tmpAnz.ownPointCnt;
550 if (this.mReversi.
getMasuStsEna(color,
this.mEdge[i].y,
this.mEdge[i].x) == 2) {
566 if (mem == -1) mem =
r.Next(kadocnt);
568 for (var i = 0; i < kadocnt; i++) {
569 if (this.mReversi.
checkEdge(color,
this.mEdge[i].y,
this.mEdge[i].x) != 0) {
570 if ((cpuflg0 == 0) && (cpuflg1 == 0) && (cpuflg2 == 0)) {
577 if ((cpuflg1 == 0) && (cpuflg2 == 0) && (cpuflg0 == 0) && (cpuflg3 == 0)) {
581 setY = this.mCpu[rcnt2].y;
582 setX = this.mCpu[rcnt2].x;
583 }
else if (kadocnt != 0) {
584 setY = this.mEdge[rcnt2].y;
585 setX = this.mEdge[rcnt2].x;
590 if (this.mReversi.
setMasuSts(color, setY, setX) == 0) {
623 for (var i = 0; i < this.mSetting.mMasuCnt; i++) {
624 for (var j = 0; j < this.mSetting.mMasuCnt; j++) {
629 var waitTime = this.mSetting.mPlayDrawInterVal;
630 for (var i = 0; i < this.mSetting.mMasuCnt; i++) {
631 for (var j = 0; j < this.mSetting.mMasuCnt; j++) {
633 System.Threading.Thread.Sleep(waitTime);
693 this.mCurColor = this.mSetting.mPlayer;
696 this.mReversi.
setMasuCnt(this.mSetting.mMasuCnt);
698 this.mReversi.
reset();
711 this.mGameEndSts = 0;
743 System.Threading.Thread.Sleep(this.mSetting.mEndInterVal);
745 for (var i = 0; i < this.mSetting.mMasuCnt; i++) {
746 for (var j = 0; j < this.mSetting.mMasuCnt; j++) {
754 int bCnt2, wCnt2, bEnd, wEnd;
759 for (var i = 0; i < this.mSetting.mMasuCnt; i++) {
760 for (var j = 0; j < this.mSetting.mMasuCnt; j++) {
771 this.
sendDrawMsg((this.mSetting.mMasuCnt - 1) - i, (
this.mSetting.mMasuCnt - 1) - j);
775 if (bEnd == 1 && wEnd == 1) {
778 System.Threading.Thread.Sleep(this.mSetting.mEndDrawInterVal);
837 int dMode, dBack, dCnt;
841 dMode = this.mReversi.
getMasuSts(msgPoint.y, msgPoint.x);
842 dBack = this.mReversi.
getMasuStsEna(this.mCurColor, msgPoint.y, msgPoint.x);
843 dCnt = this.mReversi.
getMasuStsCnt(this.mCurColor, msgPoint.y, msgPoint.x);
844 this.
DrawSingleLocal(msgPoint.y, msgPoint.x, dMode, dBack, dCnt.ToString());
852 dMode = this.mReversi.
getMasuSts(msgPoint.y, msgPoint.x);
853 dBack = this.mReversi.
getMasuStsEna(this.mCurColor, msgPoint.y, msgPoint.x);
854 dCnt = this.mReversi.
getMasuStsCnt(this.mCurColor, msgPoint.y, msgPoint.x);
855 this.
DrawSingleLocal(msgPoint.y, msgPoint.x, dMode, dBack, dCnt.ToString());
859 dMode = this.mReversi.
getMasuSts(msgPoint.y, msgPoint.x);
863 for (var i = 0; i < this.mSetting.mMasuCnt; i++) {
864 for (var j = 0; j < this.mSetting.mMasuCnt; j++) {
873 for (var i = 0; i < this.mSetting.mMasuCnt; i++) {
874 for (var j = 0; j < this.mSetting.mMasuCnt; j++) {
880 for (var i = 0; i < this.mSetting.mMasuCnt; i++) {
881 for (var j = 0; j < this.mSetting.mMasuCnt; j++) {
890 for (var i = 0; i < this.mSetting.mMasuCnt; i++) {
891 for (var j = 0; j < this.mSetting.mMasuCnt; j++) {
902 else tmpStr =
"あなたはプレイヤー2です ";
905 else tmpStr =
"プレイヤー2の番です ";
932 if(this.viewMsgDlg != null) this.viewMsgDlg(title, msg);
950 if(this.drawSingle != null) this.drawSingle(y, x, sts, bk, text);
964 if(this.curColMsg != null) this.curColMsg(text);
978 if(this.curStsMsg != null) this.curStsMsg(text);