// create all drops and moves for piece, position and board // checks movetype restriction if supplied, but Any means any // CHECK: I thought this was the way it used to be??? // checks position or zone restriction by peeking into movegen internal IEnumerable <MoveModel> CreateMoves(MoveKinds kind, PieceValue piece, PositionValue position, BoardModel board, MoveTypeValue movetype) { var movegens = (movetype == MoveTypeValue.Any) ? _movegens.Values.SelectMany(m => m) : _movegens.SafeLookup(movetype); if (movegens == null) { yield break; } foreach (var movegen in movegens) { var ok = (kind == MoveKinds.Move || movegen.PosOrZone.IsNull); if (!ok) { var posorzone = movegen.PosOrZone.Value as PositionOrZone; ok = (posorzone.IsPosition) ? (position == posorzone.Position) : board.InZone(posorzone.Zone, position); } if (ok) { Logger.WriteLine(4, "CreateMoves {0} piece:{1} position:{2} movetype:{3}", kind, piece, position, movetype); foreach (var move in movegen.Exec(kind, piece, position, board)) { yield return(move); } } } // TODO: after each Exec if the partial flag is set, add any possible further moves // (perhaps of a specific move type) }
BoolValue s_InZone_(ZoneValue zone, PositionOrDirection posordir = null) { return(BoolValue.Create(_board.InZone(zone, ToPosition(posordir)))); }