| @@ -1,18 +0,0 @@ | ||
| 1 | -using System; | |
| 2 | -using System.Collections.Generic; | |
| 3 | -using System.Linq; | |
| 4 | -using System.Text; | |
| 5 | - | |
| 6 | -namespace QuantumShogi.Logic | |
| 7 | -{ | |
| 8 | - class PieceGroup | |
| 9 | - { | |
| 10 | - | |
| 11 | - int[] counts; | |
| 12 | - public PieceGroup() | |
| 13 | - { | |
| 14 | - counts = new int[Piece.CountOfType()]; | |
| 15 | - } | |
| 16 | - | |
| 17 | - } | |
| 18 | -} |
| @@ -24,7 +24,7 @@ | ||
| 24 | 24 | /// </summary> |
| 25 | 25 | const int MEM_SIZE_OF_Y = SIZE_OF_Y + 2; |
| 26 | 26 | |
| 27 | - int GetIndexOfCell(int x, int y) | |
| 27 | + private int GetIndexOfCell(int x, int y) | |
| 28 | 28 | { |
| 29 | 29 | return MEM_SIZE_OF_X * y + x; |
| 30 | 30 | } |
| @@ -7,16 +7,11 @@ | ||
| 7 | 7 | { |
| 8 | 8 | class DirectionsGenerator |
| 9 | 9 | { |
| 10 | - /// <summary> | |
| 11 | - /// 先手からみた駒の移動方向なっていないとき | |
| 12 | - /// </summary> | |
| 13 | - MoveDirection[][] normalMoveDirections; | |
| 14 | - /// <summary> | |
| 15 | - /// 先手から見た駒の移動方向成り駒のとき | |
| 16 | - /// </summary> | |
| 17 | - MoveDirection[][] promotedMoveDirections; | |
| 10 | + MoveDirectionsType[] moveDirections; | |
| 11 | + | |
| 18 | 12 | public DirectionsGenerator() |
| 19 | 13 | { |
| 14 | + //一歩動くきき | |
| 20 | 15 | MoveDirection upper = new MoveDirection(0, -1, false);//前進 |
| 21 | 16 | MoveDirection upperLeft = new MoveDirection(1,-1,false);//左上 |
| 22 | 17 | MoveDirection upperRight = new MoveDirection(-1,-1,true);//右上 |
| @@ -25,6 +20,9 @@ | ||
| 25 | 20 | MoveDirection downRight = new MoveDirection(-1,1, false); |
| 26 | 21 | MoveDirection right = new MoveDirection(-1,0, false); |
| 27 | 22 | MoveDirection left = new MoveDirection(1,0, false); |
| 23 | + | |
| 24 | + //飛びききにはすぐ一つとなりのききは含めない。 | |
| 25 | + //例えば香車は直進すると定義されるが、直進+一歩前進ができると定義する。 | |
| 28 | 26 | MoveDirection straightUpper = new MoveDirection(0, -1, true);//前へ直進 |
| 29 | 27 | MoveDirection straightUpperLeft = new MoveDirection(1, -1, false); |
| 30 | 28 | MoveDirection straightUpperRight = new MoveDirection(-1, -1, true); |
| @@ -33,111 +31,91 @@ | ||
| 33 | 31 | MoveDirection straightDownRight = new MoveDirection(-1, 1, false); |
| 34 | 32 | MoveDirection straightRight = new MoveDirection(-1, 0, false); |
| 35 | 33 | MoveDirection straightLeft = new MoveDirection(1, 0, false); |
| 34 | + | |
| 36 | 35 | MoveDirection upper2Left = new MoveDirection(1, -2, false);//桂馬飛び |
| 37 | 36 | MoveDirection upper2Right = new MoveDirection(-1, -2, true);//桂馬飛び |
| 38 | - normalMoveDirections = new MoveDirection[Piece.CountOfType()][]; | |
| 39 | 37 | |
| 38 | + moveDirections = new MoveDirectionsType[Piece.CountOfType()]; | |
| 39 | + | |
| 40 | 40 | //歩の移動方向 |
| 41 | - normalMoveDirections[Piece.Pawn] = new MoveDirection[] | |
| 42 | - { | |
| 41 | + moveDirections[Piece.Pawn] = new MoveDirectionsType( | |
| 43 | 42 | upper |
| 44 | - }; | |
| 43 | + ).AppendPromotedMove( | |
| 44 | + //との移動方向 | |
| 45 | + upperLeft, upper, upperRight, | |
| 46 | + left, right, | |
| 47 | + down | |
| 48 | + ); | |
| 45 | 49 | //香車の移動方向 |
| 46 | - normalMoveDirections[Piece.Lance] = new MoveDirection[] | |
| 47 | - { | |
| 50 | + moveDirections[Piece.Lance] = new MoveDirectionsType( | |
| 51 | + upper, | |
| 48 | 52 | straightUpper |
| 49 | - }; | |
| 53 | + ).AppendPromotedMove( | |
| 54 | + //成香の移動方向 | |
| 55 | + upperLeft, upper, upperRight, | |
| 56 | + left, right, | |
| 57 | + down | |
| 58 | + ); | |
| 50 | 59 | //桂馬の移動方向 |
| 51 | - normalMoveDirections[Piece.Knight] = new MoveDirection[] | |
| 52 | - { | |
| 53 | - upper2Left,upper2Right | |
| 54 | - }; | |
| 60 | + moveDirections[Piece.Knight] = new MoveDirectionsType( | |
| 61 | + upper2Left, upper2Right | |
| 62 | + ).AppendPromotedMove( | |
| 63 | + //圭の移動方向 | |
| 64 | + upperLeft, upper, upperRight, | |
| 65 | + left, right, | |
| 66 | + down | |
| 67 | + ); | |
| 55 | 68 | //銀の移動方向 |
| 56 | - normalMoveDirections[Piece.Silver] = new MoveDirection[] | |
| 57 | - { | |
| 58 | - upperLeft,upper,upperRight, | |
| 59 | - downLeft,downRight | |
| 60 | - }; | |
| 69 | + moveDirections[Piece.Silver] = new MoveDirectionsType( | |
| 70 | + upperLeft, upper, upperRight, | |
| 71 | + downLeft, downRight | |
| 72 | + ).AppendPromotedMove( | |
| 73 | + //全の移動方向)] | |
| 74 | + upperLeft, upper, upperRight, | |
| 75 | + left, right, | |
| 76 | + down | |
| 77 | + ); | |
| 61 | 78 | //金の移動方向 |
| 62 | - normalMoveDirections[Piece.Gold] = new MoveDirection[] | |
| 63 | - { | |
| 79 | + moveDirections[Piece.Gold] = new MoveDirectionsType( | |
| 64 | 80 | upperLeft,upper,upperRight, |
| 65 | 81 | left,right, |
| 66 | 82 | down |
| 67 | - }; | |
| 83 | + ); | |
| 68 | 84 | //角の移動方向 |
| 69 | - normalMoveDirections[Piece.Bishop] = new MoveDirection[] | |
| 70 | - { | |
| 85 | + moveDirections[Piece.Bishop] = new MoveDirectionsType( | |
| 86 | + upperLeft,upperRight, | |
| 87 | + downLeft,downRight, | |
| 71 | 88 | straightUpperLeft,straightUpperRight, |
| 72 | 89 | straightDownLeft,straightDownRight |
| 73 | - }; | |
| 90 | + ).AppendPromotedMove( | |
| 91 | + //馬の移動方向 | |
| 92 | + upperLeft, upper,upperRight, | |
| 93 | + left, right, | |
| 94 | + upperLeft,down,downRight, | |
| 95 | + straightUpperLeft, straightUpperRight, | |
| 96 | + straightDownLeft, straightDownRight | |
| 97 | + ); | |
| 74 | 98 | //飛車の移動方向 |
| 75 | - normalMoveDirections[Piece.Rook] = new MoveDirection[] | |
| 76 | - { | |
| 99 | + moveDirections[Piece.Rook] = new MoveDirectionsType( | |
| 77 | 100 | straightUpper, |
| 78 | 101 | straightLeft,straightRight, |
| 79 | 102 | straightDown |
| 80 | - }; | |
| 103 | + ).AppendPromotedMove( | |
| 104 | + //竜の移動方向 | |
| 105 | + upperLeft, upper, upperRight, | |
| 106 | + left, right, | |
| 107 | + upperLeft, down, downRight, | |
| 108 | + straightUpper, | |
| 109 | + straightLeft, straightRight, | |
| 110 | + straightDown | |
| 111 | + ); | |
| 81 | 112 | //玉の移動方向 |
| 82 | - normalMoveDirections[Piece.King] = new MoveDirection[] | |
| 83 | - { | |
| 113 | + moveDirections[Piece.King] = new MoveDirectionsType( | |
| 84 | 114 | upperLeft,upper,upperRight, |
| 85 | 115 | left,right, |
| 86 | 116 | downLeft,down,downRight |
| 87 | - }; | |
| 117 | + ); | |
| 88 | 118 | |
| 89 | - promotedMoveDirections = new MoveDirection[Piece.CountOfType()][]; | |
| 90 | - | |
| 91 | - //との移動方向 | |
| 92 | - promotedMoveDirections[Piece.Pawn] = new MoveDirection[] | |
| 93 | - { | |
| 94 | - upperLeft,upper,upperRight, | |
| 95 | - left,right, | |
| 96 | - down | |
| 97 | - }; | |
| 98 | - //成香の移動方向 | |
| 99 | - promotedMoveDirections[Piece.Lance] = new MoveDirection[] | |
| 100 | - { | |
| 101 | - upperLeft,upper,upperRight, | |
| 102 | - left,right, | |
| 103 | - down | |
| 104 | - }; | |
| 105 | - //圭の移動方向 | |
| 106 | - promotedMoveDirections[Piece.Knight] = new MoveDirection[] | |
| 107 | - { | |
| 108 | - upperLeft,upper,upperRight, | |
| 109 | - left,right, | |
| 110 | - down | |
| 111 | - }; | |
| 112 | - //全の移動方向 | |
| 113 | - promotedMoveDirections[Piece.Silver] = new MoveDirection[] | |
| 114 | - { | |
| 115 | - upperLeft,upper,upperRight, | |
| 116 | - left,right, | |
| 117 | - down | |
| 118 | - }; | |
| 119 | - promotedMoveDirections[Piece.Gold] = new MoveDirection[] | |
| 120 | - { | |
| 121 | - //金はなれない | |
| 122 | - }; | |
| 123 | - //馬の移動方向 | |
| 124 | - promotedMoveDirections[Piece.Bishop] = new MoveDirection[] | |
| 125 | - { | |
| 126 | - upper, | |
| 127 | - left,right, | |
| 128 | - down, | |
| 129 | - straightUpperLeft,straightUpperRight, | |
| 130 | - straightDownLeft,straightDownRight | |
| 131 | - }; | |
| 132 | - //竜の移動方向 | |
| 133 | - promotedMoveDirections[Piece.Rook] = new MoveDirection[] | |
| 134 | - { | |
| 135 | - upperLeft,upperRight, | |
| 136 | - downLeft,downRight, | |
| 137 | - straightUpper, | |
| 138 | - straightLeft,straightRight, | |
| 139 | - straightDown | |
| 140 | - }; | |
| 141 | 119 | } |
| 142 | 120 | } |
| 143 | 121 | } |
| @@ -0,0 +1,15 @@ | ||
| 1 | +using System; | |
| 2 | +using System.Collections.Generic; | |
| 3 | +using System.Linq; | |
| 4 | +using System.Text; | |
| 5 | + | |
| 6 | +namespace QuantumShogi.Logic | |
| 7 | +{ | |
| 8 | + class PieceNumbersOfSide | |
| 9 | + { | |
| 10 | + Piece[] pieces; | |
| 11 | + Piece[][] piecesOfDirection; | |
| 12 | + int[] maxOfpieceDirection; | |
| 13 | + int[] maxOfpieceType; | |
| 14 | + } | |
| 15 | +} |
| @@ -0,0 +1,46 @@ | ||
| 1 | +using System; | |
| 2 | +using System.Collections.Generic; | |
| 3 | +using System.Linq; | |
| 4 | +using System.Text; | |
| 5 | + | |
| 6 | +namespace QuantumShogi.Logic | |
| 7 | +{ | |
| 8 | + /// <summary> | |
| 9 | + /// 各駒に対応する動きをまとめたもの | |
| 10 | + /// </summary> | |
| 11 | + class MoveDirectionsType | |
| 12 | + { | |
| 13 | + /// <summary> | |
| 14 | + /// 先手からみた駒の移動方向なっていないとき | |
| 15 | + /// </summary> | |
| 16 | + MoveDirection[] normalMoveDirections; | |
| 17 | + /// <summary> | |
| 18 | + /// 先手から見た駒の移動方向成り駒のとき | |
| 19 | + /// </summary> | |
| 20 | + MoveDirection[] promotedMoveDirections = new MoveDirection[] { };//金、玉は0個の配列 | |
| 21 | + | |
| 22 | + public MoveDirection[] GetValues(bool promoted) | |
| 23 | + { | |
| 24 | + if (promoted) | |
| 25 | + { | |
| 26 | + return promotedMoveDirections; | |
| 27 | + } | |
| 28 | + else | |
| 29 | + { | |
| 30 | + return normalMoveDirections; | |
| 31 | + } | |
| 32 | + } | |
| 33 | + | |
| 34 | + public MoveDirectionsType(params MoveDirection[] normalMoveDirections) | |
| 35 | + { | |
| 36 | + this.normalMoveDirections = normalMoveDirections; | |
| 37 | + | |
| 38 | + } | |
| 39 | + | |
| 40 | + public MoveDirectionsType AppendPromotedMove(params MoveDirection[] promotedMoveDirections) | |
| 41 | + { | |
| 42 | + this.promotedMoveDirections = promotedMoveDirections; | |
| 43 | + return this; | |
| 44 | + } | |
| 45 | + } | |
| 46 | +} |
| @@ -0,0 +1,18 @@ | ||
| 1 | +using System; | |
| 2 | +using System.Collections.Generic; | |
| 3 | +using System.Linq; | |
| 4 | +using System.Text; | |
| 5 | + | |
| 6 | +namespace QuantumShogi.Logic | |
| 7 | +{ | |
| 8 | + class PieceNumbers | |
| 9 | + { | |
| 10 | + PieceNumbersOfSide PieceNumbersOfBlackSide; | |
| 11 | + PieceNumbersOfSide PieceNumbersOfWhiteSide; | |
| 12 | + public PieceNumbers() | |
| 13 | + { | |
| 14 | + | |
| 15 | + } | |
| 16 | + | |
| 17 | + } | |
| 18 | +} |