• R/O
  • SSH
  • HTTPS

shoginextmove: コミット


コミットメタ情報

リビジョン81 (tree)
日時2016-02-24 11:47:30
作者bellyoshi

ログメッセージ

変更サマリ

差分

--- Quantum/QuantumShogi/QuantumShogi.Logic/Piece.cs (revision 80)
+++ Quantum/QuantumShogi/QuantumShogi.Logic/Piece.cs (revision 81)
@@ -7,7 +7,7 @@
77 {
88 public class Piece
99 {
10- private bool[] _isTypeOf = new bool[CountOfType()];
10+ private bool[] _isTypeOf = new bool[CountOfType];
1111 /// <summary>
1212 /// 駒が指定した種類である可能性があるか
1313 /// </summary>
@@ -21,6 +21,10 @@
2121 ///なりごま
2222 public bool IsPromoted { get; set; }
2323
24+ /// <summary>
25+ /// 駒の種類の最小値
26+ /// </summary>
27+ public const int MIN = Pawn;
2428 public const int Pawn = 0;// 歩
2529 public const int Lance = 1;// 香車
2630 public const int Knight = 2;// 桂馬
@@ -29,7 +33,12 @@
2933 public const int Bishop = 5;// 角
3034 public const int Rook = 6;// 飛
3135 public const int King = 7;// 王
36+ /// <summary>
37+ /// 駒の種類の最大値
38+ /// </summary>
39+ public const int CountOfType = King + 1;
3240
41+
3342 // 現在先手の駒
3443 public bool IsBlack { get; set; }
3544 // 現在後手の駒
@@ -41,15 +50,9 @@
4150 }
4251 }
4352
53+
54+
4455 /// <summary>
45- /// 駒の種類の最大値
46- /// </summary>
47- /// <returns></returns>
48- public static int CountOfType()
49- {
50- return King + 1;
51- }
52- /// <summary>
5356 /// 駒を初期化する。
5457 /// </summary>
5558 public Piece(bool isBlack,bool isWhite,bool isTypeOf)
--- Quantum/QuantumShogi/QuantumShogi.Logic/MoveDirection.cs (revision 80)
+++ Quantum/QuantumShogi/QuantumShogi.Logic/MoveDirection.cs (revision 81)
@@ -7,7 +7,7 @@
77 /// 動かす方向の単位
88 /// 縦、横、斜め、直進か、一歩づつか桂馬飛びなどを表現する。
99 /// </summary>
10- class MoveDirection
10+ public class MoveDirection
1111 {
1212 /// <summary>
1313 /// 横方向の移動方向
@@ -32,5 +32,28 @@
3232 this.Row = row;
3333 this.IsLine = isLine;
3434 }
35+
36+ MoveDirection upper = new MoveDirection(0, -1, false);//前進
37+ MoveDirection upperLeft = new MoveDirection(1, -1, false);//左上
38+ MoveDirection upperRight = new MoveDirection(-1, -1, true);//右上
39+ MoveDirection down = new MoveDirection(0, 1, false);//下がる
40+ MoveDirection downLeft = new MoveDirection(1, 1, false);
41+ MoveDirection downRight = new MoveDirection(-1, 1, false);
42+ MoveDirection right = new MoveDirection(-1, 0, false);
43+ MoveDirection left = new MoveDirection(1, 0, false);
44+
45+ //飛びききにはすぐ1歩動く方向は含めない。
46+ //例えば香車は直進すると定義されるが、直進+一歩前進と重複して定義する。
47+ MoveDirection straightUpper = new MoveDirection(0, -1, true);//前へ直進
48+ MoveDirection straightUpperLeft = new MoveDirection(1, -1, false);
49+ MoveDirection straightUpperRight = new MoveDirection(-1, -1, true);
50+ MoveDirection straightDown = new MoveDirection(0, 1, false);
51+ MoveDirection straightDownLeft = new MoveDirection(1, 1, false);
52+ MoveDirection straightDownRight = new MoveDirection(-1, 1, false);
53+ MoveDirection straightRight = new MoveDirection(-1, 0, false);
54+ MoveDirection straightLeft = new MoveDirection(1, 0, false);
55+
56+ MoveDirection upper2Left = new MoveDirection(1, -2, false);//桂馬飛び
57+ MoveDirection upper2Right = new MoveDirection(-1, -2, true);//桂馬飛び
3558 }
3659 }
--- Quantum/QuantumShogi/QuantumShogi.Logic/DirectionsGenerator.cs (revision 80)
+++ Quantum/QuantumShogi/QuantumShogi.Logic/DirectionsGenerator.cs (revision 81)
@@ -5,40 +5,81 @@
55
66 namespace QuantumShogi.Logic
77 {
8- class DirectionsGenerator
8+ public class DirectionsGenerator
99 {
10- MoveDirectionsType[] moveDirections;
10+ /// <summary>
11+ /// 特定の駒に対する移動方向
12+ /// </summary>
13+ MoveDirectionsType[] MoveDirectionsOfPice;
1114
15+ /// <summary>
16+ /// 全移動方向の配列
17+ /// </summary>
18+ public MoveDirection[] moveDirectionsList { get; }
19+
20+ /// <summary>
21+ /// ある量子駒が動ける
22+ /// </summary>
23+ /// <param name="piece"></param>
24+ /// <returns></returns>
25+ public IEnumerable<MoveDirection> GetPieceOfMoveDirection(Piece piece)
26+ {
27+ List<MoveDirection> list = new List<MoveDirection>();
28+ for(int i = Piece.MIN; i < Piece.CountOfType; i++)
29+ {
30+ if (piece.IsTypeOf(i))
31+ {
32+ list.AddRange(
33+ MoveDirectionsOfPice[i].GetValues(piece.IsPromoted)
34+ );
35+ }
36+ }
37+ return list.Distinct();
38+ }
39+
40+ //一歩動く方向
41+ MoveDirection upper = new MoveDirection(0, -1, false);//前進
42+ MoveDirection upperLeft = new MoveDirection(1, -1, false);//左上
43+ MoveDirection upperRight = new MoveDirection(-1, -1, true);//右上
44+ MoveDirection down = new MoveDirection(0, 1, false);//下がる
45+ MoveDirection downLeft = new MoveDirection(1, 1, false);
46+ MoveDirection downRight = new MoveDirection(-1, 1, false);
47+ MoveDirection right = new MoveDirection(-1, 0, false);
48+ MoveDirection left = new MoveDirection(1, 0, false);
49+
50+ //飛びききにはすぐ1歩動く方向は含めない。
51+ //例えば香車は直進すると定義されるが、直進+一歩前進と重複して定義する。
52+ MoveDirection straightUpper = new MoveDirection(0, -1, true);//前へ直進
53+ MoveDirection straightUpperLeft = new MoveDirection(1, -1, false);
54+ MoveDirection straightUpperRight = new MoveDirection(-1, -1, true);
55+ MoveDirection straightDown = new MoveDirection(0, 1, false);
56+ MoveDirection straightDownLeft = new MoveDirection(1, 1, false);
57+ MoveDirection straightDownRight = new MoveDirection(-1, 1, false);
58+ MoveDirection straightRight = new MoveDirection(-1, 0, false);
59+ MoveDirection straightLeft = new MoveDirection(1, 0, false);
60+
61+ MoveDirection upper2Left = new MoveDirection(1, -2, false);//桂馬飛び
62+ MoveDirection upper2Right = new MoveDirection(-1, -2, true);//桂馬飛び
63+
1264 public DirectionsGenerator()
1365 {
14- //一歩動くきき
15- MoveDirection upper = new MoveDirection(0, -1, false);//前進
16- MoveDirection upperLeft = new MoveDirection(1,-1,false);//左上
17- MoveDirection upperRight = new MoveDirection(-1,-1,true);//右上
18- MoveDirection down = new MoveDirection(0,1,false);//下がる
19- MoveDirection downLeft = new MoveDirection(1,1,false);
20- MoveDirection downRight = new MoveDirection(-1,1, false);
21- MoveDirection right = new MoveDirection(-1,0, false);
22- MoveDirection left = new MoveDirection(1,0, false);
2366
24- //飛びききにはすぐ一つとなりのききは含めない。
25- //例えば香車は直進すると定義されるが、直進+一歩前進ができると定義する。
26- MoveDirection straightUpper = new MoveDirection(0, -1, true);//前へ直進
27- MoveDirection straightUpperLeft = new MoveDirection(1, -1, false);
28- MoveDirection straightUpperRight = new MoveDirection(-1, -1, true);
29- MoveDirection straightDown = new MoveDirection(0, 1, false);
30- MoveDirection straightDownLeft = new MoveDirection(1, 1, false);
31- MoveDirection straightDownRight = new MoveDirection(-1, 1, false);
32- MoveDirection straightRight = new MoveDirection(-1, 0, false);
33- MoveDirection straightLeft = new MoveDirection(1, 0, false);
67+ moveDirectionsList = new MoveDirection[]
68+ {
69+ upper, upperLeft, upperRight,
70+ left ,right,
71+ down, downLeft, downRight ,
72+ straightUpper, straightUpperLeft, straightUpperRight,
73+ straightLeft,straightRight,
74+ straightDown, straightDownLeft, straightDownRight,
75+ upper2Left,
76+ upper2Right
77+ };
3478
35- MoveDirection upper2Left = new MoveDirection(1, -2, false);//桂馬飛び
36- MoveDirection upper2Right = new MoveDirection(-1, -2, true);//桂馬飛び
79+ MoveDirectionsOfPice = new MoveDirectionsType[Piece.CountOfType];
3780
38- moveDirections = new MoveDirectionsType[Piece.CountOfType()];
39-
4081 //歩の移動方向
41- moveDirections[Piece.Pawn] = new MoveDirectionsType(
82+ MoveDirectionsOfPice[Piece.Pawn] = new MoveDirectionsType(
4283 upper
4384 ).AppendPromotedMove(
4485 //との移動方向
@@ -47,7 +88,7 @@
4788 down
4889 );
4990 //香車の移動方向
50- moveDirections[Piece.Lance] = new MoveDirectionsType(
91+ MoveDirectionsOfPice[Piece.Lance] = new MoveDirectionsType(
5192 upper,
5293 straightUpper
5394 ).AppendPromotedMove(
@@ -57,7 +98,7 @@
5798 down
5899 );
59100 //桂馬の移動方向
60- moveDirections[Piece.Knight] = new MoveDirectionsType(
101+ MoveDirectionsOfPice[Piece.Knight] = new MoveDirectionsType(
61102 upper2Left, upper2Right
62103 ).AppendPromotedMove(
63104 //圭の移動方向
@@ -66,7 +107,7 @@
66107 down
67108 );
68109 //銀の移動方向
69- moveDirections[Piece.Silver] = new MoveDirectionsType(
110+ MoveDirectionsOfPice[Piece.Silver] = new MoveDirectionsType(
70111 upperLeft, upper, upperRight,
71112 downLeft, downRight
72113 ).AppendPromotedMove(
@@ -76,13 +117,13 @@
76117 down
77118 );
78119 //金の移動方向
79- moveDirections[Piece.Gold] = new MoveDirectionsType(
120+ MoveDirectionsOfPice[Piece.Gold] = new MoveDirectionsType(
80121 upperLeft,upper,upperRight,
81122 left,right,
82123 down
83124 );
84125 //角の移動方向
85- moveDirections[Piece.Bishop] = new MoveDirectionsType(
126+ MoveDirectionsOfPice[Piece.Bishop] = new MoveDirectionsType(
86127 upperLeft,upperRight,
87128 downLeft,downRight,
88129 straightUpperLeft,straightUpperRight,
@@ -96,7 +137,7 @@
96137 straightDownLeft, straightDownRight
97138 );
98139 //飛車の移動方向
99- moveDirections[Piece.Rook] = new MoveDirectionsType(
140+ MoveDirectionsOfPice[Piece.Rook] = new MoveDirectionsType(
100141 straightUpper,
101142 straightLeft,straightRight,
102143 straightDown
@@ -110,7 +151,7 @@
110151 straightDown
111152 );
112153 //玉の移動方向
113- moveDirections[Piece.King] = new MoveDirectionsType(
154+ MoveDirectionsOfPice[Piece.King] = new MoveDirectionsType(
114155 upperLeft,upper,upperRight,
115156 left,right,
116157 downLeft,down,downRight
--- Quantum/QuantumShogi/QuantumShogi.Logic/MoveDirectionsType.cs (revision 80)
+++ Quantum/QuantumShogi/QuantumShogi.Logic/MoveDirectionsType.cs (revision 81)
@@ -17,8 +17,20 @@
1717 /// <summary>
1818 /// 先手から見た駒の移動方向成り駒のとき
1919 /// </summary>
20- MoveDirection[] promotedMoveDirections = new MoveDirection[] { };//金、玉は0個の配列
20+ MoveDirection[] promotedMoveDirections = null;
2121
22+ /// <summary>
23+ /// 駒はなることが可能か
24+ /// 金、玉はfalse
25+ /// </summary>
26+ public bool CanPromoted
27+ {
28+ get
29+ {
30+ return promotedMoveDirections != null;
31+ }
32+ }
33+
2234 public MoveDirection[] GetValues(bool promoted)
2335 {
2436 if (promoted)
旧リポジトリブラウザで表示