ReversiForm  1.0.0
ReversiForm
MyReversi.cs
Go to the documentation of this file.
1 
18 using System;
19 using System.Collections.Generic;
20 using System.Linq;
21 using System.Text;
22 
23 namespace ReversiForm
24 {
30  public class MyReversi
31  {
32  #region メンバ変数
33  private int[,] _mMasuSts;
34  private int[,] _mMasuStsOld;
35  private int[,] _mMasuStsEnaB;
36  private int[,] _mMasuStsCntB;
37  private int[,] _mMasuStsPassB;
40  private int _mMasuPointCntB;
41  private int _mMasuBetCntB;
42  private int[,] _mMasuStsEnaW;
43  private int[,] _mMasuStsCntW;
44  private int[,] _mMasuStsPassW;
47  private int _mMasuPointCntW;
48  private int _mMasuBetCntW;
49  private int _mMasuCnt;
50  private int _mMasuCntMax;
51  private int _mMasuHistCur;
53  #endregion
54 
55  #region プロパティ
56  public int[,] mMasuSts
57  {
58  get { return _mMasuSts; }
59  set { _mMasuSts = value; }
60  }
61  public int[,] mMasuStsOld
62  {
63  get { return _mMasuStsOld; }
64  set { _mMasuStsOld = value; }
65  }
66  public int[,] mMasuStsEnaB
67  {
68  get { return _mMasuStsEnaB; }
69  set { _mMasuStsEnaB = value; }
70  }
71  public int[,] mMasuStsCntB
72  {
73  get { return _mMasuStsCntB; }
74  set { _mMasuStsCntB = value; }
75  }
76  public int[,] mMasuStsPassB
77  {
78  get { return _mMasuStsPassB; }
79  set { _mMasuStsPassB = value; }
80  }
81  public ReversiAnz[,] mMasuStsAnzB
82  {
83  get { return _mMasuStsAnzB; }
84  set { _mMasuStsAnzB = value; }
85  }
86  public ReversiPoint[] mMasuPointB
87  {
88  get { return _mMasuPointB; }
89  set { _mMasuPointB = value; }
90  }
91  public int mMasuPointCntB
92  {
93  get { return _mMasuPointCntB; }
94  set { _mMasuPointCntB = value; }
95  }
96  public int mMasuBetCntB
97  {
98  get { return _mMasuBetCntB; }
99  set { _mMasuBetCntB = value; }
100  }
101  public int[,] mMasuStsEnaW
102  {
103  get { return _mMasuStsEnaW; }
104  set { _mMasuStsEnaW = value; }
105  }
106  public int[,] mMasuStsCntW
107  {
108  get { return _mMasuStsCntW; }
109  set { _mMasuStsCntW = value; }
110  }
111  public int[,] mMasuStsPassW
112  {
113  get { return _mMasuStsPassW; }
114  set { _mMasuStsPassW = value; }
115  }
116  public ReversiAnz[,] mMasuStsAnzW
117  {
118  get { return _mMasuStsAnzW; }
119  set { _mMasuStsAnzW = value; }
120  }
121  public ReversiPoint[] mMasuPointW
122  {
123  get { return _mMasuPointW; }
124  set { _mMasuPointW = value; }
125  }
126  public int mMasuPointCntW
127  {
128  get { return _mMasuPointCntW; }
129  set { _mMasuPointCntW = value; }
130  }
131  public int mMasuBetCntW
132  {
133  get { return _mMasuBetCntW; }
134  set { _mMasuBetCntW = value; }
135  }
136  public int mMasuCnt
137  {
138  get { return _mMasuCnt; }
139  set { _mMasuCnt = value; }
140  }
141  public int mMasuCntMax
142  {
143  get { return _mMasuCntMax; }
144  set { _mMasuCntMax = value; }
145  }
146  public int mMasuHistCur
147  {
148  get { return _mMasuHistCur; }
149  set { _mMasuHistCur = value; }
150  }
151  public ReversiHistory[] mMasuHist
152  {
153  get { return _mMasuHist; }
154  set { _mMasuHist = value; }
155  }
156  #endregion
157 
168  public MyReversi(int masuCnt, int masuMax)
169  {
170  this.mMasuCnt = masuCnt;
171  this.mMasuCntMax = masuMax;
172 
175 
180 
185 
186  for (var i = 0; i < this.mMasuCntMax; i++) {
187  for (var j = 0; j < this.mMasuCntMax; j++) {
188  this.mMasuSts[i,j] = ReversiConst.REVERSI_STS_NONE;
189 
190  this.mMasuStsEnaB[i,j] = ReversiConst.REVERSI_STS_NONE;
191  this.mMasuStsCntB[i,j] = ReversiConst.REVERSI_STS_NONE;
192  this.mMasuStsPassB[i,j] = ReversiConst.REVERSI_STS_NONE;
193  this.mMasuStsAnzB[i,j] = new ReversiAnz();
194 
195  this.mMasuStsEnaW[i,j] = ReversiConst.REVERSI_STS_NONE;
196  this.mMasuStsCntW[i,j] = ReversiConst.REVERSI_STS_NONE;
197  this.mMasuStsPassW[i,j] = ReversiConst.REVERSI_STS_NONE;
198  this.mMasuStsAnzW[i,j] = new ReversiAnz();
199  }
200  }
203  for (var i = 0; i < (this.mMasuCntMax * this.mMasuCntMax); i++) {
204  this.mMasuPointB[i] = new ReversiPoint();
205  this.mMasuPointW[i] = new ReversiPoint();
206  }
207  this.mMasuPointCntB = 0;
208  this.mMasuPointCntW = 0;
209 
210  this.mMasuBetCntB = 0;
211  this.mMasuBetCntW = 0;
212 
214  for (var i = 0; i < (this.mMasuCntMax * this.mMasuCntMax); i++) {
215  this.mMasuHist[i] = new ReversiHistory();
216  }
217  this.mMasuHistCur = 0;
218  Array.Copy(this.mMasuSts, this.mMasuStsOld, this.mMasuSts.Length);
219  this.reset();
220  }
221 
230  public MyReversi Clone()
231  {
232  return (MyReversi)MemberwiseClone();
233  }
234 
243  public void reset()
244  {
245  for (var i = 0; i < this.mMasuCnt; i++) {
246  for (var j = 0; j < this.mMasuCnt; j++) {
247  this.mMasuSts[i,j] = ReversiConst.REVERSI_STS_NONE;
248  this.mMasuStsPassB[i,j] = 0;
249  this.mMasuStsAnzB[i,j].reset();
250  this.mMasuStsPassW[i,j] = 0;
251  this.mMasuStsAnzW[i,j].reset();
252  }
253  }
254  this.mMasuSts[(this.mMasuCnt >> 1) - 1,(this.mMasuCnt >> 1) - 1] = ReversiConst.REVERSI_STS_BLACK;
255  this.mMasuSts[(this.mMasuCnt >> 1) - 1,(this.mMasuCnt >> 1)] = ReversiConst.REVERSI_STS_WHITE;
256  this.mMasuSts[(this.mMasuCnt >> 1),(this.mMasuCnt >> 1) - 1] = ReversiConst.REVERSI_STS_WHITE;
257  this.mMasuSts[(this.mMasuCnt >> 1),(this.mMasuCnt >> 1)] = ReversiConst.REVERSI_STS_BLACK;
260  this.mMasuHistCur = 0;
261  Array.Copy(this.mMasuSts, this.mMasuStsOld, this.mMasuSts.Length);
262  }
263 
273  private int makeMasuSts(int color)
274  {
275  int flg;
276  int okflg = 0;
277  int cnt1;
278  int cnt2;
279  int count1;
280  int count2 = 0;
281  int ret = -1;
282  int countMax = 0;
283  int loop;
284 
285  for (var i = 0; i < this.mMasuCnt; i++) { // 初期化
286  for (var j = 0; j < this.mMasuCnt; j++) {
287  if (color == ReversiConst.REVERSI_STS_BLACK) {
288  this.mMasuStsEnaB[i,j] = 0;
289  this.mMasuStsCntB[i,j] = 0;
290  } else {
291  this.mMasuStsEnaW[i,j] = 0;
292  this.mMasuStsCntW[i,j] = 0;
293  }
294  }
295  }
296 
297  loop = this.mMasuCnt * this.mMasuCnt;
298  for (var i = 0; i < loop; i++) { // 初期化
299  if (color == ReversiConst.REVERSI_STS_BLACK) {
300  this.mMasuPointB[i].x = 0;
301  this.mMasuPointB[i].y = 0;
302  } else {
303  this.mMasuPointW[i].x = 0;
304  this.mMasuPointW[i].y = 0;
305  }
306  }
307  if (color == ReversiConst.REVERSI_STS_BLACK) {
308  this.mMasuPointCntB = 0;
309  } else {
310  this.mMasuPointCntW = 0;
311  }
312  this.mMasuBetCntB = 0;
313  this.mMasuBetCntW = 0;
314 
315  for (var i = 0; i < this.mMasuCnt; i++) {
316  for (var j = 0; j < this.mMasuCnt; j++) {
317  okflg = 0;
318  count2 = 0;
319  if (this.mMasuSts[i,j] == ReversiConst.REVERSI_STS_NONE) { // 何も置かれていないマスなら
320  cnt1 = i;
321  count1 = flg = 0;
322  // *** 上方向を調べる *** //
323  while ((cnt1 > 0) && (this.mMasuSts[cnt1 - 1,j] != ReversiConst.REVERSI_STS_NONE && this.mMasuSts[cnt1 - 1,j] != color)) {
324  flg = 1;
325  cnt1--;
326  count1++;
327  }
328  if ((cnt1 > 0) && (flg == 1) && (this.mMasuSts[cnt1 - 1,j] == color)) {
329  okflg = 1;
330  count2 += count1;
331  }
332  cnt1 = i;
333  count1 = flg = 0;
334  // *** 下方向を調べる *** //
335  while ((cnt1 < (this.mMasuCnt - 1)) && (this.mMasuSts[cnt1 + 1,j] != ReversiConst.REVERSI_STS_NONE && this.mMasuSts[cnt1 + 1,j] != color)) {
336  flg = 1;
337  cnt1++;
338  count1++;
339  }
340  if ((cnt1 < (this.mMasuCnt - 1)) && (flg == 1) && (this.mMasuSts[cnt1 + 1,j] == color)) {
341  okflg = 1;
342  count2 += count1;
343  }
344  cnt2 = j;
345  count1 = flg = 0;
346  // *** 右方向を調べる *** //
347  while ((cnt2 < (this.mMasuCnt - 1)) && (this.mMasuSts[i,cnt2 + 1] != ReversiConst.REVERSI_STS_NONE && this.mMasuSts[i,cnt2 + 1] != color)) {
348  flg = 1;
349  cnt2++;
350  count1++;
351  }
352  if ((cnt2 < (this.mMasuCnt - 1)) && (flg == 1) && (this.mMasuSts[i,cnt2 + 1] == color)) {
353  okflg = 1;
354  count2 += count1;
355  }
356  cnt2 = j;
357  count1 = flg = 0;
358  // *** 左方向を調べる *** //
359  while ((cnt2 > 0) && (this.mMasuSts[i,cnt2 - 1] != ReversiConst.REVERSI_STS_NONE && this.mMasuSts[i,cnt2 - 1] != color)) {
360  flg = 1;
361  cnt2--;
362  count1++;
363  }
364  if ((cnt2 > 0) && (flg == 1) && (this.mMasuSts[i,cnt2 - 1] == color)) {
365  okflg = 1;
366  count2 += count1;
367  }
368  cnt2 = j;
369  cnt1 = i;
370  count1 = flg = 0;
371  // *** 右上方向を調べる *** //
372  while (((cnt2 < (this.mMasuCnt - 1)) && (cnt1 > 0)) && (this.mMasuSts[cnt1 - 1,cnt2 + 1] != ReversiConst.REVERSI_STS_NONE && this.mMasuSts[cnt1 - 1,cnt2 + 1] != color)) {
373  flg = 1;
374  cnt1--;
375  cnt2++;
376  count1++;
377  }
378  if (((cnt2 < (this.mMasuCnt - 1)) && (cnt1 > 0)) && (flg == 1) && (this.mMasuSts[cnt1 - 1,cnt2 + 1] == color)) {
379  okflg = 1;
380  count2 += count1;
381  }
382  cnt2 = j;
383  cnt1 = i;
384  count1 = flg = 0;
385  // *** 左上方向を調べる *** //
386  while (((cnt2 > 0) && (cnt1 > 0)) && (this.mMasuSts[cnt1 - 1,cnt2 - 1] != ReversiConst.REVERSI_STS_NONE && this.mMasuSts[cnt1 - 1,cnt2 - 1] != color)) {
387  flg = 1;
388  cnt1--;
389  cnt2--;
390  count1++;
391  }
392  if (((cnt2 > 0) && (cnt1 > 0)) && (flg == 1) && (this.mMasuSts[cnt1 - 1,cnt2 - 1] == color)) {
393  okflg = 1;
394  count2 += count1;
395  }
396  cnt2 = j;
397  cnt1 = i;
398  count1 = flg = 0;
399  // *** 右下方向を調べる *** //
400  while (((cnt2 < (this.mMasuCnt - 1)) && (cnt1 < (this.mMasuCnt - 1))) && (this.mMasuSts[cnt1 + 1,cnt2 + 1] != ReversiConst.REVERSI_STS_NONE && this.mMasuSts[cnt1 + 1,cnt2 + 1] != color)) {
401  flg = 1;
402  cnt1++;
403  cnt2++;
404  count1++;
405  }
406  if (((cnt2 < (this.mMasuCnt - 1)) && (cnt1 < (this.mMasuCnt - 1))) && (flg == 1) && (this.mMasuSts[cnt1 + 1,cnt2 + 1] == color)) {
407  okflg = 1;
408  count2 += count1;
409  }
410  cnt2 = j;
411  cnt1 = i;
412  count1 = flg = 0;
413  // *** 左下方向を調べる *** //
414  while (((cnt2 > 0) && (cnt1 < (this.mMasuCnt - 1))) && (this.mMasuSts[cnt1 + 1,cnt2 - 1] != ReversiConst.REVERSI_STS_NONE && this.mMasuSts[cnt1 + 1,cnt2 - 1] != color)) {
415  flg = 1;
416  cnt1++;
417  cnt2--;
418  count1++;
419  }
420  if (((cnt2 > 0) && (cnt1 < (this.mMasuCnt - 1))) && (flg == 1) && (this.mMasuSts[cnt1 + 1,cnt2 - 1] == color)) {
421  okflg = 1;
422  count2 += count1;
423  }
424  if (okflg == 1) {
425  if (color == ReversiConst.REVERSI_STS_BLACK) {
426  this.mMasuStsEnaB[i,j] = 1;
427  this.mMasuStsCntB[i,j] = count2;
428  // *** 置ける場所をリニアに保存、置けるポイント数も保存 *** //
429  this.mMasuPointB[this.mMasuPointCntB].y = i;
430  this.mMasuPointB[this.mMasuPointCntB].x = j;
431  this.mMasuPointCntB++;
432  } else {
433  this.mMasuStsEnaW[i,j] = 1;
434  this.mMasuStsCntW[i,j] = count2;
435  // *** 置ける場所をリニアに保存、置けるポイント数も保存 *** //
436  this.mMasuPointW[this.mMasuPointCntW].y = i;
437  this.mMasuPointW[this.mMasuPointCntW].x = j;
438  this.mMasuPointCntW++;
439  }
440  ret = 0;
441  if (countMax < count2) countMax = count2;
442  }
443  } else if (this.mMasuSts[i,j] == ReversiConst.REVERSI_STS_BLACK) {
444  this.mMasuBetCntB++;
445  } else if (this.mMasuSts[i,j] == ReversiConst.REVERSI_STS_WHITE) {
446  this.mMasuBetCntW++;
447  }
448  }
449  }
450 
451  // *** 一番枚数を獲得できるマスを設定 *** //
452  for (var i = 0; i < this.mMasuCnt; i++) {
453  for (var j = 0; j < this.mMasuCnt; j++) {
454  if (color == ReversiConst.REVERSI_STS_BLACK) {
455  if (this.mMasuStsEnaB[i,j] != 0 && this.mMasuStsCntB[i,j] == countMax) {
456  this.mMasuStsEnaB[i,j] = 2;
457  }
458  } else {
459  if (this.mMasuStsEnaW[i,j] != 0 && this.mMasuStsCntW[i,j] == countMax) {
460  this.mMasuStsEnaW[i,j] = 2;
461  }
462  }
463  }
464  }
465  return ret;
466  }
467 
479  private void revMasuSts(int color, int y, int x)
480  {
481  int cnt1;
482  int cnt2;
483  int rcnt1;
484  int rcnt2;
485  int flg = 0;
486 
487  // *** 左方向にある駒を調べる *** //
488  for (flg = 0, cnt1 = x, cnt2 = y; cnt1 > 0;) {
489  if (this.mMasuSts[cnt2,cnt1 - 1] != ReversiConst.REVERSI_STS_NONE && this.mMasuSts[cnt2,cnt1 - 1] != color) {
490  // *** プレイヤー以外の色の駒があるなら *** //
491  cnt1--;
492  } else if (this.mMasuSts[cnt2,cnt1 - 1] == color) {
493  flg = 1;
494  break;
495  } else if (this.mMasuSts[cnt2,cnt1 - 1] == ReversiConst.REVERSI_STS_NONE) {
496  break;
497  }
498  }
499  if (flg == 1) {
500  // *** 駒をひっくり返す *** //
501  for (rcnt1 = cnt1; rcnt1 < x; rcnt1++) {
502  this.mMasuSts[cnt2,rcnt1] = color;
503  }
504  }
505 
506  // *** 右方向にある駒を調べる *** //
507  for (flg = 0, cnt1 = x, cnt2 = y; cnt1 < (this.mMasuCnt - 1);) {
508  if (this.mMasuSts[cnt2,cnt1 + 1] != ReversiConst.REVERSI_STS_NONE && this.mMasuSts[cnt2,cnt1 + 1] != color) {
509  // *** プレイヤー以外の色の駒があるなら *** //
510  cnt1++;
511  } else if (this.mMasuSts[cnt2,cnt1 + 1] == color) {
512  flg = 1;
513  break;
514  } else if (this.mMasuSts[cnt2,cnt1 + 1] == ReversiConst.REVERSI_STS_NONE) {
515  break;
516  }
517  }
518  if (flg == 1) {
519  // *** 駒をひっくり返す *** //
520  for (rcnt1 = cnt1; rcnt1 > x; rcnt1--) {
521  this.mMasuSts[cnt2,rcnt1] = color;
522  }
523  }
524 
525  // *** 上方向にある駒を調べる *** //
526  for (flg = 0, cnt1 = x, cnt2 = y; cnt2 > 0;) {
527  if (this.mMasuSts[cnt2 - 1,cnt1] != ReversiConst.REVERSI_STS_NONE && this.mMasuSts[cnt2 - 1,cnt1] != color) {
528  // *** プレイヤー以外の色の駒があるなら *** //
529  cnt2--;
530  } else if (this.mMasuSts[cnt2 - 1,cnt1] == color) {
531  flg = 1;
532  break;
533  } else if (this.mMasuSts[cnt2 - 1,cnt1] == ReversiConst.REVERSI_STS_NONE) {
534  break;
535  }
536  }
537  if (flg == 1) {
538  // *** 駒をひっくり返す *** //
539  for (rcnt1 = cnt2; rcnt1 < y; rcnt1++) {
540  this.mMasuSts[rcnt1,cnt1] = color;
541  }
542  }
543 
544  // *** 下方向にある駒を調べる *** //
545  for (flg = 0, cnt1 = x, cnt2 = y; cnt2 < (this.mMasuCnt - 1);) {
546  if (this.mMasuSts[cnt2 + 1,cnt1] != ReversiConst.REVERSI_STS_NONE && this.mMasuSts[cnt2 + 1,cnt1] != color) {
547  // *** プレイヤー以外の色の駒があるなら *** //
548  cnt2++;
549  } else if (this.mMasuSts[cnt2 + 1,cnt1] == color) {
550  flg = 1;
551  break;
552  } else if (this.mMasuSts[cnt2 + 1,cnt1] == ReversiConst.REVERSI_STS_NONE) {
553  break;
554  }
555  }
556  if (flg == 1) {
557  // *** 駒をひっくり返す *** //
558  for (rcnt1 = cnt2; rcnt1 > y; rcnt1--) {
559  this.mMasuSts[rcnt1,cnt1] = color;
560  }
561  }
562 
563  // *** 左上方向にある駒を調べる *** //
564  for (flg = 0, cnt1 = x, cnt2 = y; cnt2 > 0 && cnt1 > 0;) {
565  if (this.mMasuSts[cnt2 - 1,cnt1 - 1] != ReversiConst.REVERSI_STS_NONE && this.mMasuSts[cnt2 - 1,cnt1 - 1] != color) {
566  // *** プレイヤー以外の色の駒があるなら *** //
567  cnt2--;
568  cnt1--;
569  } else if (this.mMasuSts[cnt2 - 1,cnt1 - 1] == color) {
570  flg = 1;
571  break;
572  } else if (this.mMasuSts[cnt2 - 1,cnt1 - 1] == ReversiConst.REVERSI_STS_NONE) {
573  break;
574  }
575  }
576  if (flg == 1) {
577  // *** 駒をひっくり返す *** //
578  for (rcnt1 = cnt2, rcnt2 = cnt1; (rcnt1 < y) && (rcnt2 < x); rcnt1++ , rcnt2++) {
579  this.mMasuSts[rcnt1,rcnt2] = color;
580  }
581  }
582 
583  // *** 左下方向にある駒を調べる *** //
584  for (flg = 0, cnt1 = x, cnt2 = y; cnt2 < (this.mMasuCnt - 1) && cnt1 > 0;) {
585  if (this.mMasuSts[cnt2 + 1,cnt1 - 1] != ReversiConst.REVERSI_STS_NONE && this.mMasuSts[cnt2 + 1,cnt1 - 1] != color) {
586  // *** プレイヤー以外の色の駒があるなら *** //
587  cnt2++;
588  cnt1--;
589  } else if (this.mMasuSts[cnt2 + 1,cnt1 - 1] == color) {
590  flg = 1;
591  break;
592  } else if (this.mMasuSts[cnt2 + 1,cnt1 - 1] == ReversiConst.REVERSI_STS_NONE) {
593  break;
594  }
595  }
596  if (flg == 1) {
597  // *** 駒をひっくり返す *** //
598  for (rcnt1 = cnt2, rcnt2 = cnt1; (rcnt1 > y) && (rcnt2 < x); rcnt1-- , rcnt2++) {
599  this.mMasuSts[rcnt1,rcnt2] = color;
600  }
601  }
602 
603  // *** 右上方向にある駒を調べる *** //
604  for (flg = 0, cnt1 = x, cnt2 = y; cnt2 > 0 && cnt1 < (this.mMasuCnt - 1);) {
605  if (this.mMasuSts[cnt2 - 1,cnt1 + 1] != ReversiConst.REVERSI_STS_NONE && this.mMasuSts[cnt2 - 1,cnt1 + 1] != color) {
606  // *** プレイヤー以外の色の駒があるなら *** //
607  cnt2--;
608  cnt1++;
609  } else if (this.mMasuSts[cnt2 - 1,cnt1 + 1] == color) {
610  flg = 1;
611  break;
612  } else if (this.mMasuSts[cnt2 - 1,cnt1 + 1] == ReversiConst.REVERSI_STS_NONE) {
613  break;
614  }
615  }
616  if (flg == 1) {
617  // *** 駒をひっくり返す *** //
618  for (rcnt1 = cnt2, rcnt2 = cnt1; (rcnt1 < y) && (rcnt2 > x); rcnt1++ , rcnt2--) {
619  this.mMasuSts[rcnt1,rcnt2] = color;
620  }
621  }
622 
623  // *** 右下方向にある駒を調べる *** //
624  for (flg = 0, cnt1 = x, cnt2 = y; cnt2 < (this.mMasuCnt - 1) && cnt1 < (this.mMasuCnt - 1);) {
625  if (this.mMasuSts[cnt2 + 1,cnt1 + 1] != ReversiConst.REVERSI_STS_NONE && this.mMasuSts[cnt2 + 1,cnt1 + 1] != color) {
626  // *** プレイヤー以外の色の駒があるなら *** //
627  cnt2++;
628  cnt1++;
629  } else if (this.mMasuSts[cnt2 + 1,cnt1 + 1] == color) {
630  flg = 1;
631  break;
632  } else if (this.mMasuSts[cnt2 + 1,cnt1 + 1] == ReversiConst.REVERSI_STS_NONE) {
633  break;
634  }
635  }
636  if (flg == 1) {
637  // *** 駒をひっくり返す *** //
638  for (rcnt1 = cnt2, rcnt2 = cnt1; (rcnt1 > y) && (rcnt2 > x); rcnt1-- , rcnt2--) {
639  this.mMasuSts[rcnt1,rcnt2] = color;
640  }
641  }
642  }
643 
655  private int checkPara(int para, int min, int max)
656  {
657  int ret = -1;
658  if (min <= para && para <= max) ret = 0;
659  return ret;
660  }
661 
670  private void AnalysisReversiBlack()
671  {
672  int tmpX;
673  int tmpY;
674  int sum;
675  int sumOwn;
676  int tmpGoodPoint;
677  int tmpBadPoint;
678  int tmpD1;
679  int tmpD2;
680  for (var cnt = 0; cnt < this.mMasuPointCntB; cnt++) {
681  // *** 現在ステータスを一旦コピー *** //
685  Array.Copy(this.mMasuSts, tmpMasu, this.mMasuSts.Length);
686  Array.Copy(this.mMasuStsEnaB, tmpMasuEnaB, this.mMasuStsEnaB.Length);
687  Array.Copy(this.mMasuStsEnaW, tmpMasuEnaW, this.mMasuStsEnaW.Length);
688 
689  tmpY = this.mMasuPointB[cnt].y;
690  tmpX = this.mMasuPointB[cnt].x;
691  this.mMasuSts[tmpY,tmpX] = ReversiConst.REVERSI_STS_BLACK; // 仮に置く
692  this.revMasuSts(ReversiConst.REVERSI_STS_BLACK, tmpY, tmpX); // 仮にひっくり返す
695  // *** このマスに置いた場合の解析を行う *** //
696  if (this.getColorEna(ReversiConst.REVERSI_STS_WHITE) != 0) { // 相手がパス
697  this.mMasuStsPassB[tmpY,tmpX] = 1;
698  }
699  if (this.getEdgeSideZero(tmpY, tmpX) == 0) { // 置いた場所が角
700  this.mMasuStsAnzB[tmpY,tmpX].ownEdgeCnt++;
701  this.mMasuStsAnzB[tmpY,tmpX].goodPoint += 10000 * this.mMasuStsCntB[tmpY,tmpX];
702  } else if (this.getEdgeSideOne(tmpY, tmpX) == 0) { // 置いた場所が角の一つ手前
703  this.mMasuStsAnzB[tmpY,tmpX].ownEdgeSideOneCnt++;
704  if (this.checkEdge(ReversiConst.REVERSI_STS_BLACK, tmpY, tmpX) != 0) { // 角を取られない
705  this.mMasuStsAnzB[tmpY,tmpX].goodPoint += 10 * this.mMasuStsCntB[tmpY,tmpX];
706  } else { // 角を取られる
707  this.mMasuStsAnzB[tmpY,tmpX].badPoint += 100000;
708  }
709  } else if (this.getEdgeSideTwo(tmpY, tmpX) == 0) { // 置いた場所が角の二つ手前
710  this.mMasuStsAnzB[tmpY,tmpX].ownEdgeSideTwoCnt++;
711  this.mMasuStsAnzB[tmpY,tmpX].goodPoint += 1000 * this.mMasuStsCntB[tmpY,tmpX];
712  } else if (this.getEdgeSideThree(tmpY, tmpX) == 0) { // 置いた場所が角の三つ手前
713  this.mMasuStsAnzB[tmpY,tmpX].ownEdgeSideThreeCnt++;
714  this.mMasuStsAnzB[tmpY,tmpX].goodPoint += 100 * this.mMasuStsCntB[tmpY,tmpX];
715  } else { // 置いた場所がその他
716  this.mMasuStsAnzB[tmpY,tmpX].ownEdgeSideOtherCnt++;
717  this.mMasuStsAnzB[tmpY,tmpX].goodPoint += 10 * this.mMasuStsCntB[tmpY,tmpX];
718  }
719  sum = 0;
720  sumOwn = 0;
721  for (var i = 0; i < this.mMasuCnt; i++) {
722  for (var j = 0; j < this.mMasuCnt; j++) {
723  tmpBadPoint = 0;
724  tmpGoodPoint = 0;
725  if (this.getMasuStsEna(ReversiConst.REVERSI_STS_WHITE, i, j) != 0) {
726  sum += this.mMasuStsCntW[i,j]; // 相手の獲得予定枚数
727  // *** 相手の獲得予定の最大数保持 *** //
728  if (this.mMasuStsAnzB[tmpY,tmpX].max < this.mMasuStsCntW[i,j]) this.mMasuStsAnzB[tmpY,tmpX].max = this.mMasuStsCntW[i,j];
729  // *** 相手の獲得予定の最小数保持 *** //
730  if (this.mMasuStsCntW[i,j] < this.mMasuStsAnzB[tmpY,tmpX].min) this.mMasuStsAnzB[tmpY,tmpX].min = this.mMasuStsCntW[i,j];
731  this.mMasuStsAnzB[tmpY,tmpX].pointCnt++; // 相手の置ける場所の数
732  if (this.getEdgeSideZero(i, j) == 0) { // 置く場所が角
733  this.mMasuStsAnzB[tmpY,tmpX].edgeCnt++;
734  tmpBadPoint = 100000 * this.mMasuStsCntW[i,j];
735  } else if (this.getEdgeSideOne(i, j) == 0) { // 置く場所が角の一つ手前
736  this.mMasuStsAnzB[tmpY,tmpX].edgeSideOneCnt++;
737  tmpBadPoint = 0;
738  } else if (this.getEdgeSideTwo(i, j) == 0) { // 置く場所が角の二つ手前
739  this.mMasuStsAnzB[tmpY,tmpX].edgeSideTwoCnt++;
740  tmpBadPoint = 1 * this.mMasuStsCntW[i,j];
741  } else if (this.getEdgeSideThree(i, j) == 0) { // 置く場所が角の三つ手前
742  this.mMasuStsAnzB[tmpY,tmpX].edgeSideThreeCnt++;
743  tmpBadPoint = 1 * this.mMasuStsCntW[i,j];
744  } else { // 置く場所がその他
745  this.mMasuStsAnzB[tmpY,tmpX].edgeSideOtherCnt++;
746  tmpBadPoint = 1 * this.mMasuStsCntW[i,j];
747  }
748  if (tmpMasuEnaW[i,j] != 0) tmpBadPoint = 0; // ステータス変化していないなら
749  }
750  if (this.getMasuStsEna(ReversiConst.REVERSI_STS_BLACK, i, j) != 0) {
751  sumOwn += this.mMasuStsCntB[i,j]; // 自分の獲得予定枚数
752  // *** 自分の獲得予定の最大数保持 *** //
753  if (this.mMasuStsAnzB[tmpY,tmpX].ownMax < this.mMasuStsCntB[i,j]) this.mMasuStsAnzB[tmpY,tmpX].ownMax = this.mMasuStsCntB[i,j];
754  // *** 自分の獲得予定の最小数保持 *** //
755  if (this.mMasuStsCntB[i,j] < this.mMasuStsAnzB[tmpY,tmpX].ownMin) this.mMasuStsAnzB[tmpY,tmpX].ownMin = this.mMasuStsCntB[i,j];
756  this.mMasuStsAnzB[tmpY,tmpX].ownPointCnt++; // 自分の置ける場所の数
757  if (this.getEdgeSideZero(i, j) == 0) { // 置く場所が角
758  this.mMasuStsAnzB[tmpY,tmpX].ownEdgeCnt++;
759  tmpGoodPoint = 100 * this.mMasuStsCntB[i,j];
760  } else if (this.getEdgeSideOne(i, j) == 0) { // 置く場所が角の一つ手前
761  this.mMasuStsAnzB[tmpY,tmpX].ownEdgeSideOneCnt++;
762  tmpGoodPoint = 0;
763  } else if (this.getEdgeSideTwo(i, j) == 0) { // 置く場所が角の二つ手前
764  this.mMasuStsAnzB[tmpY,tmpX].ownEdgeSideTwoCnt++;
765  tmpGoodPoint = 3 * this.mMasuStsCntB[i,j];
766  } else if (this.getEdgeSideThree(i, j) == 0) { // 置く場所が角の三つ手前
767  this.mMasuStsAnzB[tmpY,tmpX].ownEdgeSideThreeCnt++;
768  tmpGoodPoint = 2 * this.mMasuStsCntB[i,j];
769  } else { // 置く場所がその他
770  this.mMasuStsAnzB[tmpY,tmpX].ownEdgeSideOtherCnt++;
771  tmpGoodPoint = 1 * this.mMasuStsCntB[i,j];
772  }
773  if (tmpMasuEnaB[i,j] != 0) tmpGoodPoint = 0; // ステータス変化していないなら
774  }
775  if (tmpBadPoint != 0) this.mMasuStsAnzB[tmpY,tmpX].badPoint += tmpBadPoint;
776  if (tmpGoodPoint != 0) this.mMasuStsAnzB[tmpY,tmpX].goodPoint += tmpGoodPoint;
777  }
778  }
779  // *** 相手に取られる平均コマ数 *** //
780  if (this.getPointCnt(ReversiConst.REVERSI_STS_WHITE) != 0) {
781  tmpD1 = sum;
783  this.mMasuStsAnzB[tmpY,tmpX].avg = tmpD1 / tmpD2;
784  }
785 
786  // *** 自分が取れる平均コマ数 *** //
787  if (this.getPointCnt(ReversiConst.REVERSI_STS_BLACK) != 0) {
788  tmpD1 = sumOwn;
790  this.mMasuStsAnzB[tmpY,tmpX].ownAvg = tmpD1 / tmpD2;
791  }
792 
793  // *** 元に戻す *** //
794  Array.Copy(tmpMasu, this.mMasuSts, tmpMasu.Length);
797  }
798  }
799 
808  private void AnalysisReversiWhite()
809  {
810  int tmpX;
811  int tmpY;
812  int sum;
813  int sumOwn;
814  int tmpGoodPoint;
815  int tmpBadPoint;
816  int tmpD1;
817  int tmpD2;
818  for (var cnt = 0; cnt < this.mMasuPointCntW; cnt++) {
819  // *** 現在ステータスを一旦コピー *** //
823  Array.Copy(this.mMasuSts, tmpMasu, this.mMasuSts.Length);
824  Array.Copy(this.mMasuStsEnaB, tmpMasuEnaB, this.mMasuStsEnaB.Length);
825  Array.Copy(this.mMasuStsEnaW, tmpMasuEnaW, this.mMasuStsEnaW.Length);
826 
827  tmpY = this.mMasuPointW[cnt].y;
828  tmpX = this.mMasuPointW[cnt].x;
829  this.mMasuSts[tmpY,tmpX] = ReversiConst.REVERSI_STS_WHITE; // 仮に置く
830  this.revMasuSts(ReversiConst.REVERSI_STS_WHITE, tmpY, tmpX); // 仮にひっくり返す
833  // *** このマスに置いた場合の解析を行う *** //
834  if (this.getColorEna(ReversiConst.REVERSI_STS_BLACK) != 0) { // 相手がパス
835  this.mMasuStsPassW[tmpY,tmpX] = 1;
836  }
837  if (this.getEdgeSideZero(tmpY, tmpX) == 0) { // 置いた場所が角
838  this.mMasuStsAnzW[tmpY,tmpX].ownEdgeCnt++;
839  this.mMasuStsAnzW[tmpY,tmpX].goodPoint += 10000 * this.mMasuStsCntW[tmpY,tmpX];
840  } else if (this.getEdgeSideOne(tmpY, tmpX) == 0) { // 置いた場所が角の一つ手前
841  this.mMasuStsAnzW[tmpY,tmpX].ownEdgeSideOneCnt++;
842  if (this.checkEdge(ReversiConst.REVERSI_STS_WHITE, tmpY, tmpX) != 0) { // 角を取られない
843  this.mMasuStsAnzW[tmpY,tmpX].goodPoint += 10 * this.mMasuStsCntW[tmpY,tmpX];
844  } else { // 角を取られる
845  this.mMasuStsAnzW[tmpY,tmpX].badPoint += 100000;
846  }
847  } else if (this.getEdgeSideTwo(tmpY, tmpX) == 0) { // 置いた場所が角の二つ手前
848  this.mMasuStsAnzW[tmpY,tmpX].ownEdgeSideTwoCnt++;
849  this.mMasuStsAnzW[tmpY,tmpX].goodPoint += 1000 * this.mMasuStsCntW[tmpY,tmpX];
850  } else if (this.getEdgeSideThree(tmpY, tmpX) == 0) { // 置いた場所が角の三つ手前
851  this.mMasuStsAnzW[tmpY,tmpX].ownEdgeSideThreeCnt++;
852  this.mMasuStsAnzW[tmpY,tmpX].goodPoint += 100 * this.mMasuStsCntW[tmpY,tmpX];
853  } else { // 置いた場所がその他
854  this.mMasuStsAnzW[tmpY,tmpX].ownEdgeSideOtherCnt++;
855  this.mMasuStsAnzW[tmpY,tmpX].goodPoint += 10 * this.mMasuStsCntW[tmpY,tmpX];
856  }
857  sum = 0;
858  sumOwn = 0;
859  for (var i = 0; i < this.mMasuCnt; i++) {
860  for (var j = 0; j < this.mMasuCnt; j++) {
861  tmpBadPoint = 0;
862  tmpGoodPoint = 0;
863  if (this.getMasuStsEna(ReversiConst.REVERSI_STS_BLACK, i, j) != 0) {
864  sum += this.mMasuStsCntB[i,j]; // 相手の獲得予定枚数
865  // *** 相手の獲得予定の最大数保持 *** //
866  if (this.mMasuStsAnzW[tmpY,tmpX].max < this.mMasuStsCntB[i,j]) this.mMasuStsAnzW[tmpY,tmpX].max = this.mMasuStsCntB[i,j];
867  // *** 相手の獲得予定の最小数保持 *** //
868  if (this.mMasuStsCntB[i,j] < this.mMasuStsAnzW[tmpY,tmpX].min) this.mMasuStsAnzW[tmpY,tmpX].min = this.mMasuStsCntB[i,j];
869  this.mMasuStsAnzW[tmpY,tmpX].pointCnt++; // 相手の置ける場所の数
870  if (this.getEdgeSideZero(i, j) == 0) { // 置く場所が角
871  this.mMasuStsAnzW[tmpY,tmpX].edgeCnt++;
872  tmpBadPoint = 100000 * this.mMasuStsCntB[i,j];
873  } else if (this.getEdgeSideOne(i, j) == 0) { // 置く場所が角の一つ手前
874  this.mMasuStsAnzW[tmpY,tmpX].edgeSideOneCnt++;
875  tmpBadPoint = 0;
876  } else if (this.getEdgeSideTwo(i, j) == 0) { // 置く場所が角の二つ手前
877  this.mMasuStsAnzW[tmpY,tmpX].edgeSideTwoCnt++;
878  tmpBadPoint = 1 * this.mMasuStsCntB[i,j];
879  } else if (this.getEdgeSideThree(i, j) == 0) { // 置く場所が角の三つ手前
880  this.mMasuStsAnzW[tmpY,tmpX].edgeSideThreeCnt++;
881  tmpBadPoint = 1 * this.mMasuStsCntB[i,j];
882  } else { // 置く場所がその他
883  this.mMasuStsAnzW[tmpY,tmpX].edgeSideOtherCnt++;
884  tmpBadPoint = 1 * this.mMasuStsCntB[i,j];
885  }
886  if (tmpMasuEnaB[i,j] != 0) tmpBadPoint = 0; // ステータス変化していないなら
887  }
888  if (this.getMasuStsEna(ReversiConst.REVERSI_STS_WHITE, i, j) != 0) {
889  sumOwn += this.mMasuStsCntW[i,j]; // 自分の獲得予定枚数
890  // *** 自分の獲得予定の最大数保持 *** //
891  if (this.mMasuStsAnzW[tmpY,tmpX].ownMax < this.mMasuStsCntW[i,j]) this.mMasuStsAnzW[tmpY,tmpX].ownMax = this.mMasuStsCntW[i,j];
892  // *** 自分の獲得予定の最小数保持 *** //
893  if (this.mMasuStsCntW[i,j] < this.mMasuStsAnzW[tmpY,tmpX].ownMin) this.mMasuStsAnzW[tmpY,tmpX].ownMin = this.mMasuStsCntW[i,j];
894  this.mMasuStsAnzW[tmpY,tmpX].ownPointCnt++; // 自分の置ける場所の数
895  if (this.getEdgeSideZero(i, j) == 0) { // 置く場所が角
896  this.mMasuStsAnzW[tmpY,tmpX].ownEdgeCnt++;
897  tmpGoodPoint = 100 * this.mMasuStsCntW[i,j];
898  } else if (this.getEdgeSideOne(i, j) == 0) { // 置く場所が角の一つ手前
899  this.mMasuStsAnzW[tmpY,tmpX].ownEdgeSideOneCnt++;
900  tmpGoodPoint = 0;
901  } else if (this.getEdgeSideTwo(i, j) == 0) { // 置く場所が角の二つ手前
902  this.mMasuStsAnzW[tmpY,tmpX].ownEdgeSideTwoCnt++;
903  tmpGoodPoint = 3 * this.mMasuStsCntW[i,j];
904  } else if (this.getEdgeSideThree(i, j) == 0) { // 置く場所が角の三つ手前
905  this.mMasuStsAnzW[tmpY,tmpX].ownEdgeSideThreeCnt++;
906  tmpGoodPoint = 2 * this.mMasuStsCntW[i,j];
907  } else { // 置く場所がその他
908  this.mMasuStsAnzW[tmpY,tmpX].ownEdgeSideOtherCnt++;
909  tmpGoodPoint = 1 * this.mMasuStsCntW[i,j];
910  }
911  if (tmpMasuEnaW[i,j] != 0) tmpGoodPoint = 0; // ステータス変化していないなら
912  }
913  if (tmpBadPoint != 0) this.mMasuStsAnzW[tmpY,tmpX].badPoint += tmpBadPoint;
914  if (tmpGoodPoint != 0) this.mMasuStsAnzW[tmpY,tmpX].goodPoint += tmpGoodPoint;
915  }
916  }
917  // *** 相手に取られる平均コマ数 *** //
918  if (this.getPointCnt(ReversiConst.REVERSI_STS_BLACK) != 0) {
919  tmpD1 = sum;
921  this.mMasuStsAnzW[tmpY,tmpX].avg = tmpD1 / tmpD2;
922  }
923 
924  // *** 自分が取れる平均コマ数 *** //
925  if (this.getPointCnt(ReversiConst.REVERSI_STS_WHITE) != 0) {
926  tmpD1 = sumOwn;
928  this.mMasuStsAnzW[tmpY,tmpX].ownAvg = tmpD1 / tmpD2;
929  }
930 
931  // *** 元に戻す *** //
932  Array.Copy(tmpMasu, this.mMasuSts, tmpMasu.Length);
935  }
936  }
937 
948  public void AnalysisReversi(int bPassEna, int wPassEna)
949  {
950  // *** 相手をパスさせることができるマス検索 *** //
951  for (var i = 0; i < this.mMasuCnt; i++) { // 初期化
952  for (var j = 0; j < this.mMasuCnt; j++) {
953  this.mMasuStsPassB[i,j] = 0;
954  this.mMasuStsAnzB[i,j].reset();
955  this.mMasuStsPassW[i,j] = 0;
956  this.mMasuStsAnzW[i,j].reset();
957  }
958  }
959  this.AnalysisReversiBlack(); // 黒解析
960  this.AnalysisReversiWhite(); // 白解析
961 
964 
965  // *** パスマスを取得 *** //
966  for (var i = 0; i < this.mMasuCnt; i++) {
967  for (var j = 0; j < this.mMasuCnt; j++) {
968  if (this.mMasuStsPassB[i,j] != 0) {
969  if (bPassEna != 0) this.mMasuStsEnaB[i,j] = 3;
970  }
971  if (this.mMasuStsPassW[i,j] != 0) {
972  if (wPassEna != 0) this.mMasuStsEnaW[i,j] = 3;
973  }
974  }
975  }
976  }
977 
988  public int getMasuSts(int y, int x)
989  {
990  int ret = -1;
991  if (this.checkPara(y, 0, this.mMasuCnt) == 0 && this.checkPara(x, 0, this.mMasuCnt) == 0) ret = this.mMasuSts[y,x];
992  return ret;
993  }
994 
1005  public int getMasuStsOld(int y, int x)
1006  {
1007  int ret = -1;
1008  if (this.checkPara(y, 0, this.mMasuCnt) == 0 && this.checkPara(x, 0, this.mMasuCnt) == 0) ret = this.mMasuStsOld[y,x];
1009  return ret;
1010  }
1011 
1023  public int getMasuStsEna(int color, int y, int x)
1024  {
1025  int ret = 0;
1026  if (this.checkPara(y, 0, this.mMasuCnt) == 0 && this.checkPara(x, 0, this.mMasuCnt) == 0) {
1027  if (color == ReversiConst.REVERSI_STS_BLACK) ret = this.mMasuStsEnaB[y,x];
1028  else ret = this.mMasuStsEnaW[y,x];
1029  }
1030  return ret;
1031  }
1032 
1044  public int getMasuStsCnt(int color, int y, int x)
1045  {
1046  int ret = -1;
1047  if (this.checkPara(y, 0, this.mMasuCnt) == 0 && this.checkPara(x, 0, this.mMasuCnt) == 0) {
1048  if (color == ReversiConst.REVERSI_STS_BLACK) ret = this.mMasuStsCntB[y,x];
1049  else ret = this.mMasuStsCntW[y,x];
1050  }
1051  return ret;
1052  }
1053 
1063  public int getColorEna(int color)
1064  {
1065  int ret = -1;
1066  for (var i = 0; i < this.mMasuCnt; i++) {
1067  for (var j = 0; j < this.mMasuCnt; j++) {
1068  if (this.getMasuStsEna(color, i, j) != 0) {
1069  ret = 0;
1070  break;
1071  }
1072  }
1073  }
1074  return ret;
1075  }
1076 
1085  public int getGameEndSts()
1086  {
1087  int ret = 1;
1088  if (this.getColorEna(ReversiConst.REVERSI_STS_BLACK) == 0) ret = 0;
1089  if (this.getColorEna(ReversiConst.REVERSI_STS_WHITE) == 0) ret = 0;
1090  return ret;
1091  }
1092 
1104  public int setMasuSts(int color, int y, int x)
1105  {
1106  int ret = -1;
1107  if (this.getMasuStsEna(color, y, x) != 0) {
1108  ret = 0;
1109  Array.Copy(this.mMasuSts, this.mMasuStsOld, this.mMasuSts.Length);
1110  this.mMasuSts[y,x] = color;
1111  this.revMasuSts(color, y, x);
1114  // *** 履歴保存 *** //
1115  if (this.mMasuHistCur < (this.mMasuCntMax * this.mMasuCntMax)) {
1116  this.mMasuHist[this.mMasuHistCur].color = color;
1117  this.mMasuHist[this.mMasuHistCur].point.y = y;
1118  this.mMasuHist[this.mMasuHistCur].point.x = x;
1119  this.mMasuHistCur++;
1120  }
1121  }
1122  return ret;
1123  }
1124 
1136  public int setMasuStsForcibly(int color, int y, int x)
1137  {
1138  int ret = -1;
1139  ret = 0;
1140  Array.Copy(this.mMasuSts, this.mMasuStsOld, this.mMasuSts.Length);
1141  this.mMasuSts[y,x] = color;
1142  return ret;
1143  }
1144 
1154  public int setMasuCnt(int cnt)
1155  {
1156  int ret = -1;
1157  int chg = 0;
1158 
1159  if (this.checkPara(cnt, 0, this.mMasuCntMax) == 0) {
1160  if (this.mMasuCnt != cnt) chg = 1;
1161  this.mMasuCnt = cnt;
1162  ret = 0;
1163  if (chg == 1) this.reset();
1164  }
1165 
1166  return ret;
1167  }
1168 
1179  public ReversiPoint getPoint(int color, int num)
1180  {
1181  ReversiPoint ret = null;
1182  if (this.checkPara(num, 0, (this.mMasuCnt * this.mMasuCnt)) == 0) {
1183  if (color == ReversiConst.REVERSI_STS_BLACK) ret = this.mMasuPointB[num];
1184  else ret = this.mMasuPointW[num];
1185  }
1186  return ret;
1187  }
1188 
1198  public int getPointCnt(int color)
1199  {
1200  int ret = 0;
1201  if (color == ReversiConst.REVERSI_STS_BLACK) ret = this.mMasuPointCntB;
1202  else ret = this.mMasuPointCntW;
1203  return ret;
1204  }
1205 
1215  public int getBetCnt(int color)
1216  {
1217  int ret = 0;
1218  if (color == ReversiConst.REVERSI_STS_BLACK) ret = this.mMasuBetCntB;
1219  else ret = this.mMasuBetCntW;
1220  return ret;
1221  }
1222 
1237  public int getPassEna(int color, int y, int x)
1238  {
1239  int ret = 0;
1240  if (this.checkPara(y, 0, this.mMasuCnt) == 0 && this.checkPara(x, 0, this.mMasuCnt) == 0) {
1241  if (color == ReversiConst.REVERSI_STS_BLACK) ret = this.mMasuStsPassB[y,x];
1242  else ret = this.mMasuStsPassW[y,x];
1243  }
1244  return ret;
1245  }
1246 
1256  public ReversiHistory getHistory(int num)
1257  {
1258  ReversiHistory ret = null;
1259  if (this.checkPara(num, 0, (this.mMasuCnt * this.mMasuCnt)) == 0) {
1260  ret = this.mMasuHist[num];
1261  }
1262  return ret;
1263  }
1264 
1273  public int getHistoryCnt()
1274  {
1275  int ret = 0;
1276  ret = this.mMasuHistCur;
1277  return ret;
1278  }
1279 
1291  public ReversiAnz getPointAnz(int color, int y, int x)
1292  {
1293  ReversiAnz ret = null;
1294  if (this.checkPara(y, 0, this.mMasuCnt) == 0 && this.checkPara(x, 0, this.mMasuCnt) == 0) {
1295  if (color == ReversiConst.REVERSI_STS_BLACK) ret = this.mMasuStsAnzB[y,x];
1296  else ret = this.mMasuStsAnzW[y,x];
1297  }
1298  return ret;
1299  }
1300 
1312  public int checkEdge(int color, int y, int x)
1313  {
1314  int style = 0;
1315  int flg1 = 0;
1316  int flg2 = 0;
1317  int loop;
1318  int loop2;
1319 
1320  if (y == 0 && x == 1) {
1321  for (loop = x, flg1 = 0, flg2 = 0; loop < this.mMasuCnt; loop++) {
1322  if (this.getMasuSts(y, loop) == color) flg1 = 1;
1323  if (flg1 == 1 && this.getMasuSts(y, loop) == ReversiConst.REVERSI_STS_NONE) break;
1324  if ((flg1 == 1) && (this.getMasuSts(y, loop) != color) && (this.getMasuSts(y, loop) != ReversiConst.REVERSI_STS_NONE)) flg2 = 1;
1325  }
1326  if ((flg1 == 1) && (flg2 == 0)) style = 1;
1327  }
1328  if (y == 1 && x == 0) {
1329  for (loop = y, flg1 = 0, flg2 = 0; loop < this.mMasuCnt; loop++) {
1330  if (this.getMasuSts(loop, x) == color) flg1 = 1;
1331  if (flg1 == 1 && this.getMasuSts(loop, x) == ReversiConst.REVERSI_STS_NONE) break;
1332  if ((flg1 == 1) && (this.getMasuSts(loop, x) != color) && (this.getMasuSts(loop, x) != ReversiConst.REVERSI_STS_NONE)) flg2 = 1;
1333  }
1334  if ((flg1 == 1) && (flg2 == 0)) style = 1;
1335  }
1336  if (y == 1 && x == 1) {
1337  for (loop = y, flg1 = 0, flg2 = 0; loop < this.mMasuCnt; loop++) {
1338  if (this.getMasuSts(loop, loop) == color) flg1 = 1;
1339  if (flg1 == 1 && this.getMasuSts(loop, loop) == ReversiConst.REVERSI_STS_NONE) break;
1340  if ((flg1 == 1) && (this.getMasuSts(loop, loop) != color) && (this.getMasuSts(loop, loop) != ReversiConst.REVERSI_STS_NONE)) flg2 = 1;
1341  }
1342  if ((flg1 == 1) && (flg2 == 0)) style = 1;
1343  }
1344  if (y == 0 && x == (this.mMasuCnt - 2)) {
1345  for (loop = x, flg1 = 0, flg2 = 0; loop > 0; loop--) {
1346  if (this.getMasuSts(y, loop) == color) flg1 = 1;
1347  if (flg1 == 1 && this.getMasuSts(y, loop) == ReversiConst.REVERSI_STS_NONE) break;
1348  if ((flg1 == 1) && (this.getMasuSts(y, loop) != color) && (this.getMasuSts(y, loop) != ReversiConst.REVERSI_STS_NONE)) flg2 = 1;
1349  }
1350  if ((flg1 == 1) && (flg2 == 0)) style = 1;
1351  }
1352  if (y == 1 && x == (this.mMasuCnt - 1)) {
1353  for (loop = y, flg1 = 0, flg2 = 0; loop < this.mMasuCnt; loop++) {
1354  if (this.getMasuSts(loop, x) == color) flg1 = 1;
1355  if (flg1 == 1 && this.getMasuSts(loop, x) == ReversiConst.REVERSI_STS_NONE) break;
1356  if ((flg1 == 1) && (this.getMasuSts(loop, x) != color) && (this.getMasuSts(loop, x) != ReversiConst.REVERSI_STS_NONE)) flg2 = 1;
1357  }
1358  if ((flg1 == 1) && (flg2 == 0)) style = 1;
1359  }
1360  if (y == 1 && x == (this.mMasuCnt - 2)) {
1361  for (loop = y, loop2 = x, flg1 = 0, flg2 = 0; loop < this.mMasuCnt; loop++ , loop2--) {
1362  if (this.getMasuSts(loop, loop2) == color) flg1 = 1;
1363  if (flg1 == 1 && this.getMasuSts(loop, loop2) == ReversiConst.REVERSI_STS_NONE) break;
1364  if ((flg1 == 1) && (this.getMasuSts(loop, loop2) != color) && (this.getMasuSts(loop, loop2) != ReversiConst.REVERSI_STS_NONE)) flg2 = 1;
1365  }
1366  if ((flg1 == 1) && (flg2 == 0)) style = 1;
1367  }
1368  if (y == (this.mMasuCnt - 2) && x == 0) {
1369  for (loop = y, flg1 = 0, flg2 = 0; loop > 0; loop--) {
1370  if (this.getMasuSts(loop, x) == color) flg1 = 1;
1371  if (flg1 == 1 && this.getMasuSts(loop, x) == ReversiConst.REVERSI_STS_NONE) break;
1372  if ((flg1 == 1) && (this.getMasuSts(loop, x) != color) && (this.getMasuSts(loop, x) != ReversiConst.REVERSI_STS_NONE)) flg2 = 1;
1373  }
1374  if ((flg1 == 1) && (flg2 == 0)) style = 1;
1375  }
1376  if (y == (this.mMasuCnt - 1) && x == 1) {
1377  for (loop = x, flg1 = 0, flg2 = 0; loop < this.mMasuCnt; loop++) {
1378  if (this.getMasuSts(y, loop) == color) flg1 = 1;
1379  if (flg1 == 1 && this.getMasuSts(y, loop) == ReversiConst.REVERSI_STS_NONE) break;
1380  if ((flg1 == 1) && (this.getMasuSts(y, loop) != color) && (this.getMasuSts(y, loop) != ReversiConst.REVERSI_STS_NONE)) flg2 = 1;
1381  }
1382  if ((flg1 == 1) && (flg2 == 0)) style = 1;
1383  }
1384  if (y == (this.mMasuCnt - 2) && x == 1) {
1385  for (loop = y, loop2 = x, flg1 = 0, flg2 = 0; loop > 0; loop-- , loop2++) {
1386  if (this.getMasuSts(loop, loop2) == color) flg1 = 1;
1387  if (flg1 == 1 && this.getMasuSts(loop, loop2) == ReversiConst.REVERSI_STS_NONE) break;
1388  if ((flg1 == 1) && (this.getMasuSts(loop, loop2) != color) && (this.getMasuSts(loop, loop2) != ReversiConst.REVERSI_STS_NONE)) flg2 = 1;
1389  }
1390  if ((flg1 == 1) && (flg2 == 0)) style = 1;
1391  }
1392  if (y == (this.mMasuCnt - 2) && x == (this.mMasuCnt - 1)) {
1393  for (loop = y, flg1 = 0, flg2 = 0; loop > 0; loop--) {
1394  if (this.getMasuSts(loop, x) == color) flg1 = 1;
1395  if (flg1 == 1 && this.getMasuSts(loop, x) == ReversiConst.REVERSI_STS_NONE) break;
1396  if ((flg1 == 1) && (this.getMasuSts(loop, x) != color) && (this.getMasuSts(loop, x) != ReversiConst.REVERSI_STS_NONE)) flg2 = 1;
1397  }
1398  if ((flg1 == 1) && (flg2 == 0)) style = 1;
1399  }
1400  if (y == (this.mMasuCnt - 1) && x == (this.mMasuCnt - 2)) {
1401  for (loop = x, flg1 = 0, flg2 = 0; loop > 0; loop--) {
1402  if (this.getMasuSts(y, loop) == color) flg1 = 1;
1403  if (flg1 == 1 && this.getMasuSts(y, loop) == ReversiConst.REVERSI_STS_NONE) break;
1404  if ((flg1 == 1) && (this.getMasuSts(y, loop) != color) && (this.getMasuSts(y, loop) != ReversiConst.REVERSI_STS_NONE)) flg2 = 1;
1405  }
1406  if ((flg1 == 1) && (flg2 == 0)) style = 1;
1407  }
1408  if (y == (this.mMasuCnt - 2) && x == (this.mMasuCnt - 2)) {
1409  for (loop = y, loop2 = x, flg1 = 0, flg2 = 0; loop > 0; loop-- , loop2--) {
1410  if (this.getMasuSts(loop, loop2) == color) flg1 = 1;
1411  if (flg1 == 1 && this.getMasuSts(loop, loop2) == ReversiConst.REVERSI_STS_NONE) break;
1412  if ((flg1 == 1) && (this.getMasuSts(loop, loop2) != color) && (this.getMasuSts(loop, loop2) != ReversiConst.REVERSI_STS_NONE)) flg2 = 1;
1413  }
1414  if ((flg1 == 1) && (flg2 == 0)) style = 1;
1415  }
1416 
1417  return style;
1418  }
1419 
1430  public int getEdgeSideZero(int y, int x)
1431  {
1432  int ret = -1;
1433  if (
1434  (y == 0 && x == 0)
1435  || (y == 0 && x == (this.mMasuCnt - 1))
1436  || (y == (this.mMasuCnt - 1) && x == 0)
1437  || (y == (this.mMasuCnt - 1) && x == (this.mMasuCnt - 1))
1438  ) {
1439  ret = 0;
1440  }
1441  return ret;
1442  }
1443 
1454  public int getEdgeSideOne(int y, int x)
1455  {
1456  int ret = -1;
1457  if (
1458  (y == 0 && x == 1)
1459  || (y == 0 && x == (this.mMasuCnt - 2))
1460  || (y == 1 && x == 0)
1461  || (y == 1 && x == 1)
1462  || (y == 1 && x == (this.mMasuCnt - 2))
1463  || (y == 1 && x == (this.mMasuCnt - 1))
1464  || (y == (this.mMasuCnt - 2) && x == 0)
1465  || (y == (this.mMasuCnt - 2) && x == 1)
1466  || (y == (this.mMasuCnt - 2) && x == (this.mMasuCnt - 2))
1467  || (y == (this.mMasuCnt - 2) && x == (this.mMasuCnt - 1))
1468  || (y == (this.mMasuCnt - 1) && x == 1)
1469  || (y == (this.mMasuCnt - 1) && x == (this.mMasuCnt - 2))
1470  ) {
1471  ret = 0;
1472  }
1473  return ret;
1474  }
1475 
1486  public int getEdgeSideTwo(int y, int x)
1487  {
1488  int ret = -1;
1489  if (
1490  (y == 0 && x == 2)
1491  || (y == 0 && x == (this.mMasuCnt - 3))
1492  || (y == 2 && x == 0)
1493  || (y == 2 && x == 2)
1494  || (y == 2 && x == (this.mMasuCnt - 3))
1495  || (y == 2 && x == (this.mMasuCnt - 1))
1496  || (y == (this.mMasuCnt - 3) && x == 0)
1497  || (y == (this.mMasuCnt - 3) && x == 2)
1498  || (y == (this.mMasuCnt - 3) && x == (this.mMasuCnt - 3))
1499  || (y == (this.mMasuCnt - 3) && x == (this.mMasuCnt - 1))
1500  || (y == (this.mMasuCnt - 1) && x == 2)
1501  || (y == (this.mMasuCnt - 1) && x == (this.mMasuCnt - 3))
1502  ) {
1503  ret = 0;
1504  }
1505  return ret;
1506  }
1507 
1518  public int getEdgeSideThree(int y, int x)
1519  {
1520  int ret = -1;
1521  if (
1522  (y == 0 && (3 <= x && x <= (this.mMasuCnt - 4)))
1523  || ((3 <= y && y <= (this.mMasuCnt - 4)) && x == 0)
1524  || (y == (this.mMasuCnt - 1) && (3 <= x && x <= (this.mMasuCnt - 4)))
1525  || ((3 <= y && y <= (this.mMasuCnt - 4)) && x == (this.mMasuCnt - 1))
1526  ) {
1527  ret = 0;
1528  }
1529  return ret;
1530  }
1531  }
1532 }
void reset()
リセット
Definition: MyReversi.cs:243
ReversiAnz getPointAnz(int color, int y, int x)
ポイント座標解析取得
Definition: MyReversi.cs:1291
int getHistoryCnt()
履歴数取得
Definition: MyReversi.cs:1273
const int REVERSI_STS_WHITE
Definition: ReversiConst.cs:82
アプリ設定クラス
Definition: ReversiConst.cs:30
int [,] _mMasuStsEnaW
白の置ける場所
Definition: MyReversi.cs:42
int _mMasuBetCntW
白コマ数
Definition: MyReversi.cs:48
int _mMasuCnt
縦横マス数
Definition: MyReversi.cs:49
const int REVERSI_STS_BLACK
Definition: ReversiConst.cs:81
int getEdgeSideZero(int y, int x)
指定座標が角か取得
Definition: MyReversi.cs:1430
ReversiAnz [,] _mMasuStsAnzB
黒がその場所に置いた場合の解析結果
Definition: MyReversi.cs:38
int setMasuCnt(int cnt)
マスの数変更
Definition: MyReversi.cs:1154
リバーシ履歴クラス
int getMasuStsEna(int color, int y, int x)
指定座標に指定色を置けるかチェック
Definition: MyReversi.cs:1023
ReversiHistory [] _mMasuHist
履歴
Definition: MyReversi.cs:52
int getGameEndSts()
ゲーム終了かチェック
Definition: MyReversi.cs:1085
int [,] _mMasuStsPassB
黒が相手をパスさせる場所
Definition: MyReversi.cs:37
int getMasuSts(int y, int x)
マスステータスを取得
Definition: MyReversi.cs:988
ReversiAnz [,] _mMasuStsAnzW
白がその場所に置いた場合の解析結果
Definition: MyReversi.cs:45
int setMasuSts(int color, int y, int x)
指定座標にコマを置く
Definition: MyReversi.cs:1104
void AnalysisReversi(int bPassEna, int wPassEna)
解析を行う
Definition: MyReversi.cs:948
int makeMasuSts(int color)
各コマの置ける場所等のステータス作成
Definition: MyReversi.cs:273
リバーシ解析クラス
Definition: ReversiAnz.cs:30
リバーシポイント
Definition: ReversiPoint.cs:30
リバーシクラス
Definition: MyReversi.cs:30
int getEdgeSideTwo(int y, int x)
指定座標が角の二つ手前か取得
Definition: MyReversi.cs:1486
int [,] _mMasuStsCntB
黒の獲得コマ数
Definition: MyReversi.cs:36
void revMasuSts(int color, int y, int x)
コマをひっくり返す
Definition: MyReversi.cs:479
int _mMasuBetCntB
黒コマ数
Definition: MyReversi.cs:41
ReversiHistory getHistory(int num)
履歴取得
Definition: MyReversi.cs:1256
int getColorEna(int color)
指定色が現在置ける場所があるかチェック
Definition: MyReversi.cs:1063
int [,] _mMasuSts
マスの状態
Definition: MyReversi.cs:33
int setMasuStsForcibly(int color, int y, int x)
指定座標にコマを強制的に置く
Definition: MyReversi.cs:1136
int _mMasuPointCntW
白の置ける場所座標一覧数
Definition: MyReversi.cs:47
int _mMasuPointCntB
黒の置ける場所座標一覧数
Definition: MyReversi.cs:40
MyReversi Clone()
コピー
Definition: MyReversi.cs:230
ReversiPoint getPoint(int color, int num)
ポイント座標取得
Definition: MyReversi.cs:1179
int getPassEna(int color, int y, int x)
パス判定
Definition: MyReversi.cs:1237
void AnalysisReversiWhite()
解析を行う(白)
Definition: MyReversi.cs:808
const int REVERSI_STS_NONE
コマ無し
Definition: ReversiConst.cs:80
int [,] _mMasuStsCntW
白の獲得コマ数
Definition: MyReversi.cs:43
int [,] _mMasuStsPassW
白が相手をパスさせる場所
Definition: MyReversi.cs:44
int checkPara(int para, int min, int max)
パラメーター範囲チェック
Definition: MyReversi.cs:655
int [,] _mMasuStsEnaB
黒の置ける場所
Definition: MyReversi.cs:35
int [,] _mMasuStsOld
以前のマスの状態
Definition: MyReversi.cs:34
int getMasuStsCnt(int color, int y, int x)
指定座標の獲得コマ数取得
Definition: MyReversi.cs:1044
void reset()
リセット
Definition: ReversiAnz.cs:191
ReversiPoint [] _mMasuPointW
白の置ける場所座標一覧
Definition: MyReversi.cs:46
MyReversi(int masuCnt, int masuMax)
コンストラクタ
Definition: MyReversi.cs:168
void AnalysisReversiBlack()
解析を行う(黒)
Definition: MyReversi.cs:670
int getEdgeSideOne(int y, int x)
指定座標が角の一つ手前か取得
Definition: MyReversi.cs:1454
int getBetCnt(int color)
コマ数取得
Definition: MyReversi.cs:1215
int getMasuStsOld(int y, int x)
以前のマスステータスを取得
Definition: MyReversi.cs:1005
ReversiPoint [] _mMasuPointB
黒の置ける場所座標一覧
Definition: MyReversi.cs:39
const int DEF_MASU_CNT_MAX_VAL
マス縦横最大
Definition: ReversiConst.cs:78
int getPointCnt(int color)
ポイント座標数取得
Definition: MyReversi.cs:1198
int _mMasuCntMax
縦横マス最大数
Definition: MyReversi.cs:50
int getEdgeSideThree(int y, int x)
指定座標が角の三つ以上手前か取得
Definition: MyReversi.cs:1518
int checkEdge(int color, int y, int x)
角の隣に置いても角を取られないマス検索
Definition: MyReversi.cs:1312
int _mMasuHistCur
履歴現在位置
Definition: MyReversi.cs:51