@@ -75,10 +75,8 @@ abstract class Variant private[variant] (
75
75
'a' to '3' or 'c' to '4' are line moves of a single marble
76
76
77
77
we want to have :
78
- 1. moves of 1 marble (to an empty square) + side moves
79
- 2. side moves (as they are based on moves of 1 marble)
80
- 3. line moves of 2+ marbles
81
- 4. pushes
78
+ 1. moves of 1 marble + side moves (as we are reusing moves of 1 marble)
79
+ 2. line moves of 2+ marbles + pushes ((re-do a pass on line moves that were stuck ?))
82
80
then merge these as valid moves.
83
81
*/
84
82
def validMoves (situation : Situation ): Map [Pos , List [Move ]] = {
@@ -98,18 +96,11 @@ abstract class Variant private[variant] (
98
96
situation.board.piecesOf(situation.player).flatMap {
99
97
case ((pos, piece)) =>
100
98
Map (pos ->
101
- pos.neighbours.flatten // for each direction that would remain on the board...
102
- .filterNot(situation.board.pieces.contains(_)) // ...keep the piece only if the landing square is empty
99
+ pos.neighbours.flatten
100
+ .filterNot(situation.board.pieces.contains(_))
103
101
.map(landingSquare =>
104
102
Move (piece, pos, landingSquare, situation, boardAfter(situation, pos, landingSquare), false )
105
103
)
106
- // instead of .filterNot etc, if we wanted to take care of several cases directly from here, we could have written :
107
- // .flatMap {
108
- // case (landingSquare) if (!situation.board.pieces.contains(landingSquare)) =>
109
- // Some(Move(piece, pos, landingSquare, situation, boardAfter(situation, pos, landingSquare), false))
110
- // case (landingSquare) if (another condition)
111
- // case _ => None
112
- // }
113
104
)
114
105
}.toMap
115
106
@@ -119,27 +110,8 @@ abstract class Variant private[variant] (
119
110
120
111
def validLineMoves (@ nowarn situation : Situation ): Map [Pos , List [Move ]] = {
121
112
Map ()
122
- // situation.board.piecesOf(situation.player).flatMap {
123
- // case ((pos, piece)) => {
124
- // Map(pos -> List({
125
- // Stone.dirs.flatMap { // if the piece would remain on the board after applying a direction...
126
- // case dir => (dir, dir(pos))
127
- // case _ => None
128
- // }.flatMap { // ...check that it would move to square occupied by one of our pieces
129
- // case ((dir: Direction, landingSquare: Option[Pos]))
130
- // if (situation.board.pieces.contains(landingSquare) && situation.board.pieces(landingSquare).player == situation.player) =>
131
- // // let's check if the next square is occupied by us too, or empty :
132
- // if(dir(landingSquare))
133
- // Some(Move(piece, pos, landingSquare, situation, boardAfter(situation, pos, landingSquare), false))
134
- // else
135
- // None
136
-
137
- // case _ => None
138
- // }
139
- // }).flatten)
140
- // }
141
- // }.toMap
142
113
}
114
+
143
115
144
116
def validPushes (@ nowarn situation : Situation ): Map [Pos , List [Move ]] = {
145
117
Map ()
0 commit comments