public Tuple <MoveList, MoveList> DoCrossover(MoveList firstMovelist, MoveList secondMovelist) { var notSelectedFields = new List <int>(); for (var i = 0; i < firstMovelist.Count; i++) { var selectField = _randomizer.NextBoolean(); if (selectField) { notSelectedFields.Add(i); } } var child1 = new MoveList(); for (var i = 0; i < firstMovelist.Count; i++) { if (notSelectedFields.Contains(i)) { child1.Add(secondMovelist[i]); } else { child1.Add(firstMovelist[i]); } } notSelectedFields.Clear(); for (var i = 0; i < firstMovelist.Count; i++) { var selectField = _randomizer.NextBoolean(); if (selectField) { notSelectedFields.Add(i); } } var child2 = new MoveList(); for (var i = 0; i < firstMovelist.Count; i++) { if (notSelectedFields.Contains(i)) { child2.Add(firstMovelist[i]); } else { child2.Add(secondMovelist[i]); } } return(new Tuple <MoveList, MoveList>(child1, child2)); }
public static void Main(string[] args) { MoveList ml = new MoveList(); ml.Add(1, 2); ml.Add(3, 4); WriteMoveList("test.moves", ml); MoveList ml2 = ReadMoveList("test.moves"); foreach (MoveList.Move move in ml2.moves) { Console.WriteLine("move: {0}, {1}", move.x, move.y); } }
public override List <Move> Play() { List <Ship> shipsWithoutCommands = UndockedShips.ToList(); for (int i = 0; i < UndockedShips.Count; i++) { Ship ship = shipsWithoutCommands[0]; Planet planet = Navigation.GetClosestPlanetToShip(ship, UnownedPlanets); ship = Navigation.GetClosestShipToPlanet(planet, shipsWithoutCommands); if (ship.CanDock(planet)) { MoveList.Add(new DockMove(ship, planet)); } else { ThrustMove newThrustMove = Navigation.NavigateShipToDock(GameMap, ship, planet, Constants.MAX_SPEED); if (newThrustMove != null) { MoveList.Add(newThrustMove); } } UnownedPlanets.Remove(planet); shipsWithoutCommands.Remove(ship); } return(MoveList); }
void CheckHex(int tmpX, int tmpY, int _currAbleSteps) { tmpHex = Map.instance.FindHexByPos(tmpX, tmpY); if (tmpHex != null) { if (tmpHex.unit == null) { if (avalibleHices.FindByHex(tmpHex) == null || avalibleHices.FindByHex(tmpHex).price > movePoints - _currAbleSteps) { avalibleHices.RemoveByHex(tmpHex); avalibleHices.Add(new Move(tmpHex, movePoints - _currAbleSteps)); } GetAvalibleHices(tmpHex, _currAbleSteps); } else { if (avalibleEnemyHices.FindByHex(tmpHex) == null || avalibleEnemyHices.FindByHex(tmpHex).price > movePoints - _currAbleSteps) { if (tmpHex.unit.owner != owner) { avalibleEnemyHices.RemoveByHex(tmpHex); avalibleEnemyHices.Add(new Move(tmpHex, movePoints - _currAbleSteps)); } } } } }
/// <summary> /// Add the current move of the board /// </summary> private void AddCurrentMove() { MoveItem moveItem; string strMove; string strMoveIndex; int iMoveCount; int iItemCount; int iIndex; MoveExt move; ChessBoard.PlayerE ePlayerToMove; ChessBoard chessBoard; chessBoard = m_chessCtl.Board; m_bIgnoreChg = true; move = chessBoard.MovePosStack.CurrentMove; ePlayerToMove = chessBoard.LastMovePlayer; chessBoard.UndoMove(); iMoveCount = chessBoard.MovePosStack.Count; iItemCount = listViewMoveList.Items.Count; while (iItemCount >= iMoveCount) { iItemCount--; MoveList.RemoveAt(iItemCount); } strMove = GetMoveDesc(move); chessBoard.RedoMove(); iIndex = iItemCount; strMoveIndex = (m_eDisplayMode == DisplayModeE.MovePos) ? (iIndex + 1).ToString() : (iIndex / 2 + 1).ToString() + ((Char)('a' + (iIndex & 1))).ToString(); moveItem = new MoveItem(strMoveIndex, (ePlayerToMove == ChessBoard.PlayerE.Black) ? "Black" : "White", strMove); MoveList.Add(moveItem); m_bIgnoreChg = false; }
public void Play(Bitboard move) { MoveList.Add(move); CurrentPosition ^= Mask; Mask |= move; Moves++; PlayerToMove = PlayerToMove == Player.PlayerA ? Player.PlayerB : Player.PlayerA; }
private MoveList CreateMoveList() { BoardRating whitMate1 = new BoardRating() { Situation = Situation.BlackVictory, Evaluation = Evaluation.WhiteCheckMate }; BoardRating whitMate2 = new BoardRating() { Situation = Situation.StaleMate, Evaluation = Evaluation.BlackStaleMate }; BoardRating blackMate1 = new BoardRating() { Situation = Situation.WhiteVictory, Evaluation = Evaluation.BlackCheckMate }; BoardRating blackMate2 = new BoardRating() { Situation = Situation.WhiteVictory, Evaluation = Evaluation.BlackCheckMate }; BoardRating whiteFavor3 = new BoardRating() { Evaluation = Evaluation.Normal, Weight = 3 }; BoardRating equal1 = new BoardRating() { Evaluation = Evaluation.Normal, Weight = 0 }; BoardRating equal2 = new BoardRating() { Evaluation = Evaluation.Normal, Weight = 0 }; BoardRating blackFavor3 = new BoardRating() { Evaluation = Evaluation.Normal, Weight = -3 }; List <BoardRating> ratings = new List <BoardRating>() { whitMate1, whitMate2, blackMate1, blackMate2, whiteFavor3, equal1, equal2, blackFavor3 }; ratings = RandomListAccess.GetShuffledList(ratings); int i = 1; MoveList moveList = new MoveList(); ratings.ForEach(rating => { Move move = new Move("A" + i, "A1", new Pawn(Color.White), MoveType.Normal) { Rating = rating }; moveList.Add(move); i++; }); return(moveList); }
public void Add(MoveState moveState, GameObject obj, Move move) { MoveList moves = MovesList[moveState]; if (!moves.Find(obj)) { moves.Add(obj, move); return; } moves.Change(obj, move); }
public Tuple <MoveList, MoveList> DoCrossover(MoveList firstMovelist, MoveList secondMovelist) { var child1 = new MoveList(); var child2 = new MoveList(); if (firstMovelist.Count > 2) { //If crossover = 0, you simply swap the entire sequence. This doesn't yield a new child //Same if the crossoverPoint = length - 1. var elementsToSkip = _randomizer.Next(1, firstMovelist.Count - 2); child1.AddRange(firstMovelist.Take(elementsToSkip).Concat(secondMovelist.Skip(elementsToSkip))); child2.AddRange(secondMovelist.Take(elementsToSkip).Concat(firstMovelist.Skip(elementsToSkip))); } else if (firstMovelist.Count == 1) { child1.Add(firstMovelist[0]); child2.Add(secondMovelist[0]); } else { var swapFirstMove = _randomizer.NextBoolean(); if (swapFirstMove) { child1.Add(secondMovelist[0]); child1.Add(firstMovelist[1]); child2.Add(firstMovelist[0]); child2.Add(secondMovelist[1]); } else { child1.Add(firstMovelist[0]); child1.Add(secondMovelist[1]); child2.Add(secondMovelist[0]); child2.Add(firstMovelist[1]); } } var children = new Tuple <MoveList, MoveList>(child1, child2); return(children); }
public void CancelEdit() { if (!_isEditing) { return; } Donated = _mDonated; CheckUpdates = _mCheckUpdates; CurrentLanguage = _mCurrentLanguage; Delimiters = _mDelimiters; Tasks.Clear(); foreach (Task task in _mTtasks) { Tasks.Add(task); task.CancelEdit(); } Profiles.Clear(); foreach (Profile profile in _mProfiles) { Profiles.Add(profile); profile.CancelEdit(); } MoveList.Clear(); foreach (PositionTransform positionTransform in _mMoveList) { MoveList.Add(positionTransform); positionTransform.CancelEdit(); } CopyList.Clear(); foreach (PositionTransform positionTransform in _mCopyList) { CopyList.Add(positionTransform); positionTransform.CancelEdit(); } Languages.Clear(); foreach (Language language in _mLanguages) { Languages.Add(language); language.CancelEdit(); } _mProfiles.Clear(); _mMoveList.Clear(); _mCopyList.Clear(); _mLanguages.Clear(); _mTtasks.Clear(); _isEditing = false; }
private void Transition(BarAnalyzerResult result, IBarDatum datum) { IMove prevMove = CurrentMove.Close(datum); var newMove = Move.Open(MoveList.Count, datum, (int)result.Trend); MoveList.Add(newMove); CurrentTrendType = result.Trend; MoveSubject.OnNext(prevMove); }
private void Update(BarAnalyzerResult result) { // set WorkingBar to result.WorkingBar if CurrentTrend is Unknown or result.IsValidTrendBar is true // if (!HighList.Any() && !LowList.Any()) if (CurrentTrendType == Trend.TrendType.Unknown) { if (result.Trend == Trend.TrendType.Up) { LowList.Add(result.WorkingBar); } else if (result.Trend == Trend.TrendType.Down) { HighList.Add(result.WorkingBar); } CurrentTrendType = result.Trend; WorkingBar = result.WorkingBar; MoveList.Add(Move.Open(MoveList.Count, result.WorkingBar, (int)result.Trend)); } else { if (result.IsValidTrendBar) { WorkingBar = result.WorkingBar; // currentTrend: undetermined: currentTrend = trend // currentTrend: Up: if( trend.Down) changecurrentTrend to down and add bar Highest high series I {Working ... barDatum} // currentTrend: Down: if (trend.up) changcurrentTrend to up and add bar with Lowest low in series {WorkingBar .. barDatum} switch (CurrentTrendType) { case Trend.TrendType.Up: { if (result.Trend == Trend.TrendType.Down) { TransitionToDownFromUp(result); } } break; case Trend.TrendType.Down: { if (result.Trend == Trend.TrendType.Up) { TransitionToUpFromDown(result); } } break; } } } }
public static void GetMoveList(Board board, int row, int column, Color color, MoveList moveList) { int[,] delta = { { -1, -1 }, { -1, 0 }, { -1, +1 }, { 0, -1 }, { 0, +1 }, { +1, -1 }, { +1, 0 }, { +1, +1 } }; for (int i = 0; i < 8; i++) { int actualRow = row + delta[i, 0]; if (actualRow >= 0 && actualRow < ChessEngineConstants.Length) { int actualColumn = column + delta[i, 1]; if (actualColumn >= 0 && actualColumn < ChessEngineConstants.Length) { if (color == Color.White) { if (board[actualRow, actualColumn] <= 0) { Move move = new Move(row, column, actualRow, actualColumn); moveList.Add(move); } } else { if (board[actualRow, actualColumn] >= 0) { Move move = new Move(row, column, actualRow, actualColumn); moveList.Add(move); } } } } } // ToDo : Add Rochades }
void bonanza_ReceivedCommand(object sender, BonanzaReceivedCommandEventArgs e) { var m = MoveRegex.Match(e.Command); if (m.Success) { var move = CsaMove.Parse(m.Groups[1].Value); if (move == null) { return; } var nback = int.Parse(m.Groups[2].Value); while (nback > 0 && MoveList.Any()) { MoveList.RemoveAt(MoveList.Count - 1); } MoveList.Add(move); // 奇数手目は先手側の手です。 PonderMove = ((MoveList.Count & 1) == 1 ? move : null); } m = VariationRegex.Match(e.Command); if (m.Success) { var variation = VariationInfo.Create( double.Parse(m.Groups[1].Value), e.Command.Substring(m.Length)); if (variation == null) { return; } if (VariationList.Count > 5) { VariationList.RemoveAt(0); } VariationList.Add(variation); } m = CpuRegex.Match(e.Command); if (m.Success) { CpuUsage = double.Parse(m.Groups[2].Value); Nps = double.Parse(m.Groups[3].Value); VariationList.Clear(); } }
public ComplexMove(int index, MoveList moves, MoveList supplementaryList) { Move scoreMove = moves[index]; ScoreMove = scoreMove; SupplementaryMoves = new MoveList(); for (int next = scoreMove.Next; next != -1; next = supplementaryList[next].Next) { SupplementaryMoves.Add(supplementaryList[next]); } HoldingList = new MoveList(); for (int next = scoreMove.HoldingNext; next != -1; next = supplementaryList[next].Next) { HoldingList.Add(supplementaryList[next]); } }
public void AppendMove(string command) { int colorId = 1; if (MoveList.Count % 2 == 0) { colorId = 1; } else { colorId = 2; } ConnectFourMove move = new ConnectFourMove(command, colorId); MoveList.Add(move); }
public Circle(double x, double y, double radius) : base(x, y) { Radius = radius; MoveList.Add(new Translation() { MaxDistance = 1 }); MoveList.Add(new Translation() { MaxDistance = 10 }); MoveList.Add(new Translation() { MaxDistance = 50 }); }
public MoveList Mutate(MoveList moveListToMutate) { var mutantMoveList = new MoveList(); var coordinates = moveListToMutate.Select(move => move.Coordinate).ToList(); var indexOfCoordinateToMove = _randomizer.Next(moveListToMutate.Count); var indexToMoveTo = _randomizer.Next(moveListToMutate.Count); var coordinateToMove = coordinates[indexOfCoordinateToMove]; coordinates.RemoveAt(indexOfCoordinateToMove); coordinates.Insert(indexToMoveTo, coordinateToMove); for (var i = 0; i < moveListToMutate.Count; i++) { mutantMoveList.Add( new Move( new Piece(moveListToMutate[i].Piece.Type, moveListToMutate[i].Piece.OuterColor, moveListToMutate[i].Piece.InnerColor), coordinates[i]) ); } return(mutantMoveList); }
public static void GetMoveList(Board board, int row, int column, Color color, MoveList moveList) { for (int actualRow = row - 1; actualRow >= 0; actualRow--) { if (color == Color.White) { if (board[actualRow, column] <= 0) { Move move = new Move(row, column, actualRow, column); moveList.Add(move); } } else { if (board[actualRow, column] >= 0) { Move move = new Move(row, column, actualRow, column); moveList.Add(move); } } if (board[actualRow, column] != 0) { break; } } for (int actualRow = row + 1; actualRow < ChessEngineConstants.Length; actualRow++) { if (color == Color.White) { if (board[actualRow, column] <= 0) { Move move = new Move(row, column, actualRow, column); moveList.Add(move); } } else { if (board[actualRow, column] <= 0) { Move move = new Move(row, column, actualRow, column); moveList.Add(move); } } if (board[actualRow, column] != 0) { break; } } for (int actualColumn = column - 1; actualColumn >= 0; actualColumn--) { if (color == Color.White) { if (board[row, actualColumn] <= 0) { Move move = new Move(row, column, row, actualColumn); moveList.Add(move); } } else { if (board[row, actualColumn] >= 0) { Move move = new Move(row, column, row, actualColumn); moveList.Add(move); } } if (board[row, actualColumn] != 0) { break; } } for (int actualColumn = column + 1; actualColumn < ChessEngineConstants.Length; actualColumn++) { if (color == Color.White) { if (board[row, actualColumn] <= 0) { Move move = new Move(row, column, row, actualColumn); moveList.Add(move); } } else { if (board[row, actualColumn] >= 0) { Move move = new Move(row, column, row, actualColumn); moveList.Add(move); } } if (board[row, actualColumn] != 0) { break; } } }
public void DoMove(Move move, bool overwrite = true) { //Debug.Log(USIExtensions.USI(move)); if (overwrite) { // 上書きする指し手の数 var num = MoveList.Count - Position.gamePly; if (num > 0) { // 棋譜を上書きする RemoveItem(Position.gamePly, num); MoveList.RemoveRange(Position.gamePly, num); CurrentValue = Position.gamePly; } EntryItem(move); MoveList.Add(move); } ++CurrentValue; //Debug.Log(CurrentValue); var us = Position.sideToMove; var from = move.From(); if (move.IsSpecial()) { if (move == Move.RESIGN) { Winner = us.Not(); } ScreenControl.Interactable(MyColor == SColor.NB, true); return; } ScreenControl.Interactable(MyColor == SColor.NB, false); Piece movedPc = move.IsDrop() ? move.DroppedPiece() : Position.PieceOn(from); Piece movedAfterPc = move.IsPromote() ? movedPc.ToInt() + Piece.PROMOTE : movedPc; PieceNo pn = move.IsDrop() ? Position.HandPieceNo(us, movedPc, Position.Hand(us).Count(movedPc) - 1) : Position.PieceNoOn(from); Debug.Assert(pn != PieceNo.NONE); PiecePrefabs.MovePiece((SquareHand)move.To(), movedAfterPc, pn, move.IsPromote()); PieceNo pn2 = Position.PieceNoOn(move.To()); if (pn2 != PieceNo.NONE) { var toPr = Position.PieceOn(move.To()).RawType(); var sq = Util.MakeSquareHand(us, toPr); PiecePrefabs.CapturePiece(sq, toPr, pn2, true); // テキストを表示 // if (Position.Hand(us).Count(toPr) == 1) // Counters(Util.MakeSquareHand(us, toPr)).text = "2"; } BoardManager.DoMove(move); EndGame(); }
public static void Main(string[] args) { MoveList ml = new MoveList (); ml.Add (1, 2); ml.Add (3, 4); WriteMoveList ("test.moves", ml); MoveList ml2 = ReadMoveList ("test.moves"); foreach (MoveList.Move move in ml2.moves) Console.WriteLine ("move: {0}, {1}", move.x, move.y); }
public override MoveList GetMoveList() { MoveList moveList = new MoveList(); for (int i = 0; i < 8; i++) { Position newPosition = Position.GetDeltaPosition(Delta[i, 0], Delta[i, 1]); if (newPosition != null) { AddPosition(moveList, newPosition); } } // Castle if (KingMoves != MoveType.Normal) { if (Color == Color.White) { if ((KingMoves & MoveType.WhiteCastle) > 0) { if (WhiteCastleFields.All(field => Board[field] == null)) { ThreatenedFields ??= GetThreatenedFields(Color.Black); if (WhiteCastleFields.All(field => !ThreatenedFields.Contains(field))) { moveList.Add(new Move(WhiteKingField, WhiteKingKnightField, this, MoveType.WhiteCastle)); } } } if ((KingMoves & MoveType.WhiteCastleLong) != 0) { if (WhiteLongCastleFields.All(field => Board[field] == null)) { ThreatenedFields ??= GetThreatenedFields(Color.Black); if (WhiteLongCastleFields.All(field => !ThreatenedFields.Contains(field))) { moveList.Add(new Move(WhiteKingField, WhiteQueenBishopField, this, MoveType.WhiteCastleLong)); } } } } else { if ((KingMoves & MoveType.BlackCastle) != 0) { if (BlackCastleFields.All(field => Board[field] == null)) { ThreatenedFields ??= GetThreatenedFields(Color.White); if (BlackCastleFields.All(field => !ThreatenedFields.Contains(field))) { moveList.Add(new Move(BlackKingField, BlackKingKnightField, this, MoveType.BlackCastle)); } } } if ((KingMoves & MoveType.BlackCastleLong) != 0) { if (BlackLongCastleFields.All(field => Board[field] == null)) { ThreatenedFields ??= GetThreatenedFields(Color.White); if (BlackLongCastleFields.All(field => !ThreatenedFields.Contains(field))) { moveList.Add(new Move(BlackKingField, BlackQueenBishopField, this, MoveType.BlackCastleLong)); } } } } } return(moveList); }
public Hakumen() : base("Hakumen", 12000, new Dictionary <string, GameMove>()) { var anim_Idle = new Animation(new[] { //new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha010_01.png"), new Point(124, 0)), //new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha010_00.png"), new Point(128, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha000_00.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha000_01.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha000_02.png"), new Point(152, 1)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha000_03.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha000_04.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha000_05.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha000_06.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha000_07.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha000_08.png"), new Point(153, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha000_09.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha000_10.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha000_11.png"), new Point(152, 0)) }, true); var anim_ForwardWalk = new Animation(new[] { new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha030_00.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha030_01.png"), new Point(142, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha030_02.png"), new Point(131, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha030_03.png"), new Point(115, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha030_04.png"), new Point(100, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha030_05.png"), new Point(103, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha030_06.png"), new Point(103, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha030_07.png"), new Point(108, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha030_08.png"), new Point(150, 0)) }, true, 1); var anim_BackwardWalk = new Animation(new[] { new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha031_00.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha031_01.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha031_02.png"), new Point(140, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha031_03.png"), new Point(147, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha031_04.png"), new Point(155, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha031_05.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha031_06.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha031_07.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha031_08.png"), new Point(134, 0)) }, true, 1); var anim_Crouch = new Animation(new[] { new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha010_00.png"), new Point(128, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha010_01.png"), new Point(124, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha010_02.png"), new Point(132, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha010_03.png"), new Point(132, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha010_04.png"), new Point(133, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha010_05.png"), new Point(132, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha010_06.png"), new Point(132, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha010_07.png"), new Point(132, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha010_08.png"), new Point(132, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha010_09.png"), new Point(132, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha010_10.png"), new Point(132, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha010_11.png"), new Point(133, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha010_12.png"), new Point(133, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha010_13.png"), new Point(133, 0)) }, true, 2); var anim_Jump = new Animation(new[] { //new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha020_00.png"), new Point(128, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha020_01.png"), new Point(128, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha020_01.png"), new Point(128, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha020_02.png"), new Point(128, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha020_02.png"), new Point(128, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha020_03.png"), new Point(128, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha020_03.png"), new Point(128, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha020_04.png"), new Point(128, 0)), //new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha020_05.png"), new Point(128, 0)) }, true, 4, 4); var anim_IdleTaunt = new Animation(new[] { new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha001_00.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha001_01.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha001_02.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha001_03.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha001_04.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha001_05.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha001_06.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha001_07.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha001_08.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha001_09.png"), new Point(152, 0)) }, false); var anim_5A_Ground = new Animation(new[] { new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha200_00.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha200_01.png"), new Point(152, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha200_02.png"), new Point(232, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha200_03.png"), new Point(217, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha200_04.png"), new Point(151, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha200_05.png"), new Point(151, 0)) }, false, speed: AnimationSpeed.Fast); var anim_2A_Ground = new Animation(new[] { new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha230_00.png"), new Point(130, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha230_01.png"), new Point(149, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha230_02.png"), new Point(322, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha230_03.png"), new Point(305, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha230_04.png"), new Point(201, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha230_05.png"), new Point(130, 0)) }, false, speed: AnimationSpeed.Fast); var anim_4A_Ground = new Animation(new[] { new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha210_00.png"), new Point(150, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha210_01.png"), new Point(150, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha210_02.png"), new Point(150, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha210_03.png"), new Point(150, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha210_04.png"), new Point(245, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha210_05.png"), new Point(198, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha210_06.png"), new Point(172, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha210_07.png"), new Point(179, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha210_08.png"), new Point(195, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha210_09.png"), new Point(150, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha210_10.png"), new Point(150, 0)) }, false, speed: AnimationSpeed.Fast); var anim_5A_Air = new Animation(new[] { new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha250_00.png"), new Point(134, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha250_01.png"), new Point(134, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha250_02.png"), new Point(256, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha250_03.png"), new Point(245, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha250_04.png"), new Point(184, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha250_05.png"), new Point(154, 170)) }, false, speed: AnimationSpeed.Fast); var anim_2A_Air = new Animation(new[] { new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha260_00.png"), new Point(195, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha260_01.png"), new Point(148, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha260_02.png"), new Point(143, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha260_03.png"), new Point(145, 2)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha260_04.png"), new Point(149, 30)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha260_05.png"), new Point(314, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha260_06.png"), new Point(314, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha260_07.png"), new Point(314, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha260_08.png"), new Point(214, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha260_09.png"), new Point(194, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha260_10.png"), new Point(134, 0)), }, false, speed: AnimationSpeed.Fast); var anim_5B_Ground = new Animation(new[] { new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha201_00.png"), new Point(98, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha201_01.png"), new Point(48, -16)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha201_02.png"), new Point(21, -13)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha201_03.png"), new Point(248, -16)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha201_04.png"), new Point(232, -16)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha201_05.png"), new Point(206, -16)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha201_06.png"), new Point(132, -15)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha201_07.png"), new Point(102, -15)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha201_08.png"), new Point(105, -14)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha201_09.png"), new Point(110, -11)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha201_10.png"), new Point(150, 0)) }, false, speed: AnimationSpeed.Fast); var anim_2B_Ground = new Animation(new[] { new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha231_00.png"), new Point(120, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha231_01.png"), new Point(108, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha231_02.png"), new Point(91, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha231_03.png"), new Point(126, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha231_04.png"), new Point(291, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha231_05.png"), new Point(283, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha231_06.png"), new Point(256, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha231_07.png"), new Point(203, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha231_08.png"), new Point(149, 0)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha231_09.png"), new Point(118, 0)) }, false, speed: AnimationSpeed.Fast); var anim_4B_Ground = new Animation(new[] { new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha211_00.png"), new Point(54, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha211_01.png"), new Point(70, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha211_02.png"), new Point(125, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha211_03add3.png"), new Point(120, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha211_03add4.png"), new Point(152, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha211_03.png"), new Point(228, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha211_04.png"), new Point(242, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha211_05.png"), new Point(240, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha211_06.png"), new Point(240, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha211_07.png"), new Point(236, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha211_08.png"), new Point(230, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha211_09.png"), new Point(230, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha211_10.png"), new Point(233, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha211_11.png"), new Point(156, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha211_12.png"), new Point(158, -2)) }, false, speed: AnimationSpeed.Fast); var anim_Super_Mugen_Ground = new Animation(new[] { new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_00.png"), new Point(150, -4)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_01.png"), new Point(140, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_02.png"), new Point(103, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_03.png"), new Point(109, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_04.png"), new Point(110, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_05.png"), new Point(113, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_06.png"), new Point(113, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_07.png"), new Point(113, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_08.png"), new Point(113, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_09.png"), new Point(113, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_10.png"), new Point(131, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_11.png"), new Point(159, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_12.png"), new Point(156, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_13.png"), new Point(139, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_14.png"), new Point(129, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_15.png"), new Point(113, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_16.png"), new Point(113, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_17.png"), new Point(113, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_18.png"), new Point(113, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_19.png"), new Point(133, -12)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_20.png"), new Point(154, -7)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_21.png"), new Point(140, -4)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_22.png"), new Point(149, -2)), new Sprite(new Bitmap(@"..\..\..\Resources\Images\Characters\Hakumen\ha450_23.png"), new Point(151, 0)), }, false, speed: AnimationSpeed.Average); // var moves = new List <GameMove> { //(A/B/C/D) + (A/G/B) + [Input] + ... new GameMove("Idle", anim_Idle, action: (player) => { player.Stop(); player.Busy = false; }), new GameMove("ForwardWalk", anim_ForwardWalk, action: (player) => { player.MoveForward(); }), new GameMove("BackwardWalk", anim_BackwardWalk, action: (player) => { player.MoveBackward(); }), new GameMove("Crouch", anim_Crouch, MoveType.GroundOnly), new GameMove("ForwardJump", anim_Jump, MoveType.Universal, action: (player) => { player.Jump(); player.MoveForward(); }), new GameMove("BackwardJump", anim_Jump, MoveType.Universal, action: (player) => { player.Jump(); player.MoveBackward(); }), new GameMove("UpJump", anim_Jump, MoveType.Universal, action: (player) => { player.Jump(); }), new GameMove("IdleTaunt", anim_IdleTaunt, condMove: "Idle", action: (player) => player.Busy = true), new GameMove("AG", anim_5A_Ground, damage: 200, action: (player) => player.Busy = true), new GameMove("AG2", anim_2A_Ground, condMove: "Crouch", damage: 200, action: (player) => player.Busy = true), new GameMove("AG4", anim_4A_Ground, damage: 600, action: (player) => { player.Busy = true; }), new GameMove("AA", anim_5A_Air, damage: 200, action: (player) => player.Busy = true), new GameMove("AA2", anim_2A_Air, damage: 300, action: (player) => player.Busy = true), new GameMove("BG", anim_5B_Ground, damage: 400, action: (player) => { player.Busy = true; }), new GameMove("BG2", anim_2B_Ground, condMove: "Crouch", damage: 400, action: (player) => { player.Busy = true; }), new GameMove("BG4", anim_4B_Ground, damage: 600, action: (player) => { player.Busy = true; }), new GameMove("BG6325632", anim_Super_Mugen_Ground, damage: 0, action: (player) => { player.Busy = true; }), }; foreach (var m in moves) { MoveList.Add(m.Name, m); } }
public static MoveList MoveList(string solution) { MoveList moveList = new MoveList(); bool isPull = false; string digits = ""; string moves = null; for (int i = 0; i < solution.Length; i++) { char c = solution[i]; if (Char.IsWhiteSpace(c)) { continue; } if (c == '-') { isPull = true; continue; } if (Char.IsDigit(c)) { digits += c; continue; } if (c == '(') { moves = ""; continue; } if (moves != null && c != ')') { moves += c; continue; } if (c != ')') { moves = c.ToString(); } int count = String.IsNullOrEmpty(digits) ? 1 : Int32.Parse(digits); for (int j = 0; j < count; j++) { for (int k = 0; k < moves.Length; k++) { c = moves[k]; Operation operation = DecodeOperation(c); Direction direction = DecodeDirection(c); if (isPull && operation == Operation.Push) { operation = Operation.Pull; } moveList.Add(new OperationDirectionPair(operation, direction)); } } digits = ""; moves = null; isPull = false; } return moveList; }
public override MoveList GetMoveList() { MoveList moveList = new MoveList(); if (Color == Color.White) { // beat left Position newPosition = Position.GetDeltaPosition(1, -1); if (newPosition != null) { Piece pieceToBeat = Board[newPosition]; if ((pieceToBeat != null) && (pieceToBeat.Color != Color)) { moveList.Add(new Move(Position, newPosition, this)); } } // up newPosition = Position.GetDeltaPosition(1, 0); if ((newPosition != null) && Board[newPosition] == null) { moveList.Add(new Move(Position, newPosition, this)); if (Position.Row == 1) { // pwn double step Position newPosition2 = Position.GetDeltaPosition(2, 0); if ((newPosition2 != null) && Board[newPosition2] == null) { moveList.Add(new Move(Position, newPosition2, this, MoveType.PawnDoubleStep)); } } } // beat right newPosition = Position.GetDeltaPosition(1, 1); if (newPosition != null) { Piece pieceToBeat = Board[newPosition]; if ((pieceToBeat != null) && (pieceToBeat.Color != Color)) { moveList.Add(new Move(Position, newPosition, this)); } } // enpassant if ((PossibleMoveType & MoveType.EnpassantWhiteLeft) > 0) { moveList.Add(new Move(Position, Position.GetDeltaPosition(1, -1), this, MoveType.EnpassantWhiteLeft)); } if ((PossibleMoveType & MoveType.EnpassantWhiteRight) > 0) { moveList.Add(new Move(Position, Position.GetDeltaPosition(1, +1), this, MoveType.EnpassantWhiteRight)); } } else { // beat left Position newPosition = Position.GetDeltaPosition(-1, -1); if (newPosition != null) { Piece pieceToBeat = Board[newPosition]; if ((pieceToBeat != null) && (pieceToBeat.Color != Color)) { moveList.Add(new Move(Position, newPosition, this)); } } // down newPosition = Position.GetDeltaPosition(-1, 0); if ((newPosition != null) && Board[newPosition] == null) { moveList.Add(new Move(Position, newPosition, this)); // start with two if (Position.Row == 6) { Position newPosition2 = Position.GetDeltaPosition(-2, 0); if ((newPosition2 != null) && (Board[newPosition2] == null)) { moveList.Add(new Move(Position, newPosition2, this, MoveType.PawnDoubleStep)); } } } // beat right newPosition = Position.GetDeltaPosition(-1, 1); if (newPosition != null) { Piece pieceToBeat = Board[newPosition]; if ((pieceToBeat != null) && (pieceToBeat.Color != Color)) { moveList.Add(new Move(Position, newPosition, this)); } } // enpassant if ((PossibleMoveType & MoveType.EnpassantBlackLeft) > 0) { moveList.Add(new Move(Position, Position.GetDeltaPosition(-1, +1), this, MoveType.EnpassantBlackLeft)); } if ((PossibleMoveType & MoveType.EnpassantBlackRight) > 0) { moveList.Add(new Move(Position, Position.GetDeltaPosition(-1, -1), this, MoveType.EnpassantBlackRight)); } } return(moveList); }
protected void CollectSolution(Node leaf) { foundSolution = true; // Don't bother if we're not collection solutions. if (!collectSolutions) { return; } // Prepare to construct the solution. MoveList solution = new MoveList(); Level tempLevel = new Level(originalLevel); tempLevel.Validate = validate; PathFinder tempFinder = PathFinder.CreateInstance(tempLevel, true); // Iterate over the nodes from the root to the leaf. int previousPushes = 0; #if false List<Node> nodeList = FindParents(root, leaf); #else List<Node> nodeList = new List<Node>(); for (int i = 0; i < current.ParentIndex; i++) { nodeList.Add(current.Parents[i]); } nodeList.Add(leaf); #endif foreach (Node node in nodeList) { // Check whether we need to move the sokoban. if (node.Coordinate != tempLevel.SokobanCoordinate) { // Move the sokoban to the box. solution.AddRange(tempFinder.FindAndGetPath(node.Coordinate)); tempLevel.MoveSokoban(node.Coordinate); } // Check whether we need to push a box. int consecutivePushes = node.Pushes - previousPushes; if (consecutivePushes != 0) { // Push the box one or more times. OperationDirectionPair push = new OperationDirectionPair(Levels.Operation.Push, node.Direction); for (int j = 0; j < consecutivePushes; j++) { solution.Add(push); tempLevel.Move(push); } previousPushes = node.Pushes; } } // Validate the solution. if (!tempLevel.IsComplete) { throw Abort("constructed move list does not solve level"); } if (optimizeMoves && solution.Count != leaf.Moves) { throw Abort("constructed move list does not match leaf tree in moves"); } if (LevelUtils.SolutionPushes(solution) != leaf.Pushes) { throw Abort("constructed move list does not match leaf tree in pushes"); } // Add the solution. solutions.Add(solution); int moves = solution.Count; int pushes = LevelUtils.SolutionPushes(solution); moveLimit = Math.Min(moveLimit, moves); pushLimit = Math.Min(pushLimit, pushes); #if DEBUG if (verbose) { Log.DebugPrint(" found solution: {0}/{1}", moves, pushes); } #endif }
private MoveList CreateRandomMovelist(IRandomizer random) { var list1 = new MoveList(); var validMovelist = true; for (var i = 0; i < PiecesQueue.Count; i++) { var piece = PiecesQueue[i]; if (piece.Type == PieceType.Flower) { var coordinate = Board.GetRandomEmptyCoordinate(random.GetRandom); if (!coordinate.Equals(Coordinate.InvalidCoordinate)) { var move = new Move(piece, coordinate); var moveSuccessful = Board.DoMove(move); if (moveSuccessful) { list1.Add(move); } else { validMovelist = false; } } else { validMovelist = false; } if (!validMovelist) { break; } } else if (piece.Type == PieceType.Butterfly) { var coordinate = Board.GetRandomNonRockCoordinate(random.GetRandom); if (coordinate != Coordinate.InvalidCoordinate) { var move = new Move(piece, coordinate); var moveSuccessful = Board.DoMove(move); if (moveSuccessful) { list1.Add(move); } else { validMovelist = false; } } else { validMovelist = false; } if (!validMovelist) { break; } } } if (validMovelist) { list1.Score = Board.GetNumberOfFreeSpaces(); if (MovelistCreated != null) { var args = new MovelistCreatedEventArgs { CreatedThroughMutation = false, CreatedThroughCrossover = false, Score = list1.Score, Moves = list1.ToString() }; MovelistCreated(args); } } else { list1 = null; } Board.Reset(); return(list1); }