| @@ -8,9 +8,13 @@ | ||
| 8 | 8 | class DirectionsGenerator |
| 9 | 9 | { |
| 10 | 10 | /// <summary> |
| 11 | - /// 先手からみた駒の移動方向 | |
| 11 | + /// 先手からみた駒の移動方向なっていないとき | |
| 12 | 12 | /// </summary> |
| 13 | - MoveDirection[][] directions; | |
| 13 | + MoveDirection[][] normalMoveDirections; | |
| 14 | + /// <summary> | |
| 15 | + /// 先手から見た駒の移動方向成り駒のとき | |
| 16 | + /// </summary> | |
| 17 | + MoveDirection[][] promotedMoveDirections; | |
| 14 | 18 | public DirectionsGenerator() |
| 15 | 19 | { |
| 16 | 20 | MoveDirection upper = new MoveDirection(0, -1, false);//前 |
| @@ -31,31 +35,31 @@ | ||
| 31 | 35 | MoveDirection straightLeft = new MoveDirection(1, 0, false); |
| 32 | 36 | MoveDirection upper2Left = new MoveDirection(1, -2, false); |
| 33 | 37 | MoveDirection upper2Right = new MoveDirection(-1, -2, true); |
| 34 | - directions = new MoveDirection[Piece.CountOfType()][]; | |
| 38 | + normalMoveDirections = new MoveDirection[Piece.CountOfType()][]; | |
| 35 | 39 | |
| 36 | 40 | //歩の移動方向 |
| 37 | - directions[Piece.Pawn] = new MoveDirection[] | |
| 41 | + normalMoveDirections[Piece.Pawn] = new MoveDirection[] | |
| 38 | 42 | { |
| 39 | 43 | upper |
| 40 | 44 | }; |
| 41 | 45 | //香車の移動方向 |
| 42 | - directions[Piece.Lance] = new MoveDirection[] | |
| 46 | + normalMoveDirections[Piece.Lance] = new MoveDirection[] | |
| 43 | 47 | { |
| 44 | 48 | straightUpper |
| 45 | 49 | }; |
| 46 | 50 | //桂馬の移動方向 |
| 47 | - directions[Piece.Knight] = new MoveDirection[] | |
| 51 | + normalMoveDirections[Piece.Knight] = new MoveDirection[] | |
| 48 | 52 | { |
| 49 | 53 | upper2Left,upper2Right |
| 50 | 54 | }; |
| 51 | 55 | //銀の移動方向 |
| 52 | - directions[Piece.Silver] = new MoveDirection[] | |
| 56 | + normalMoveDirections[Piece.Silver] = new MoveDirection[] | |
| 53 | 57 | { |
| 54 | 58 | upperLeft,upper,upperRight, |
| 55 | 59 | downLeft,downRight |
| 56 | 60 | }; |
| 57 | 61 | //金の移動方向 |
| 58 | - directions[Piece.Gold] = new MoveDirection[] | |
| 62 | + normalMoveDirections[Piece.Gold] = new MoveDirection[] | |
| 59 | 63 | { |
| 60 | 64 | upperLeft,upper,upperRight, |
| 61 | 65 | left,right, |
| @@ -62,18 +66,78 @@ | ||
| 62 | 66 | down |
| 63 | 67 | }; |
| 64 | 68 | //角の移動方向 |
| 65 | - directions[Piece.Bishop] = new MoveDirection[] | |
| 69 | + normalMoveDirections[Piece.Bishop] = new MoveDirection[] | |
| 66 | 70 | { |
| 67 | 71 | straightUpperLeft,straightUpperRight, |
| 68 | 72 | straightDownLeft,straightDownRight |
| 69 | 73 | }; |
| 70 | 74 | //飛車の移動方向 |
| 71 | - directions[Piece.Rook] = new MoveDirection[] | |
| 75 | + normalMoveDirections[Piece.Rook] = new MoveDirection[] | |
| 72 | 76 | { |
| 73 | 77 | straightUpper, |
| 74 | 78 | straightLeft,straightRight, |
| 75 | 79 | straightDown |
| 76 | 80 | }; |
| 81 | + //玉の移動方向 | |
| 82 | + normalMoveDirections[Piece.King] = new MoveDirection[] | |
| 83 | + { | |
| 84 | + upperLeft,upper,upperRight, | |
| 85 | + left,right, | |
| 86 | + downLeft,down,downRight | |
| 87 | + }; | |
| 88 | + | |
| 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 | + }; | |
| 77 | 141 | } |
| 78 | 142 | } |
| 79 | 143 | } |