示例#1
0
        private int CompareMoves(Move left, Move right)
        {
            // Maaliin jos pääsee
            if (IsInGoal(left.EndPosition) && !IsInGoal(left.StartPosition))
            {
                if (!IsInGoal(right.EndPosition) || IsInGoal(right.StartPosition))
                {
                    return -1;
                }
            }
            else if (IsInGoal(right.EndPosition) && !IsInGoal(left.StartPosition))
            {
                return 1;
            }

            // Syö, poistu kotipesästä, tuplaa aina kuin voit
            if (left.Type != right.Type)
            {
                MoveType[] preferences = { MoveType.Eat, MoveType.OutOfHome, MoveType.DoubleUp, MoveType.Move, MoveType.SelfTackle };
                foreach(MoveType preference in preferences)
                {
                    if (left.Type == preference) return -1;
                    if (right.Type == preference) return 1;
                }
            }

            return 0;
        }
示例#2
0
 public int SelectMove(Situation situation, Move[] moves, Piece side, int roll)
 {
     Move[] c = new Move[moves.Length];
     Array.Copy(moves, c, moves.Length);
     Array.Sort<Move>(c, CompareMoves);
     return Array.IndexOf<Move>(moves, c[0]);
 }
示例#3
0
        public int SelectMove(Situation situation, Move[] moves, Piece side, int roll)
        {
            Console.WriteLine("Side: " + side);
            Console.WriteLine("Roll: " + roll);
            Console.WriteLine("Situation: ");
            Console.WriteLine(situation.ToString());
            int selectedMove = -1;
            do
            {
                Console.WriteLine("Moves");
                for (int i = 0; i < moves.Length; i++)
                {
                    Console.WriteLine(i + ": " + moves[i].ToString());
                }
                Console.WriteLine("Select move: ");
                selectedMove = Convert.ToInt32(Console.ReadLine());
            } while (selectedMove < 0 || selectedMove >= moves.Length);

            return selectedMove;
        }
示例#4
0
        // Event handlers for threadedlimakegame
        private void SelectMoveHandler(Situation situation, Move[] moves, Piece side, int roll)
        {
            this.availableMoves = moves;
            this.currentSituation = situation;

            for (int i = 0; i < moves.Length; i++)
            {
                Move move = moves[i];
                pieces[move.Piece].Movable = true;
                if (situation.groupingDict.ContainsKey(move.Piece))
                {
                    foreach (int otherPiece in situation.groupingDict[move.Piece])
                    {
                        if (otherPiece != move.Piece)
                        {
                            pieces[otherPiece].Movable = true;
                        }
                    }
                }
            }
        }
示例#5
0
 public int SelectMove(Situation situation, Move[] moves, Piece side, int roll)
 {
     return rand.Next(moves.Length);
 }
示例#6
0
 void IGameDisplay.DispĺayMove(Move move)
 {
     Console.WriteLine(move.ToString());
 }
示例#7
0
 int IPlayer.SelectMove(Situation situation, Move[] moves, Piece side, int roll)
 {
     selectedMove = -1;
     moveARE.Reset();
     Deployment.Current.Dispatcher.BeginInvoke(delegate()
     {
         SelectMove(situation, moves, side, roll);
     });
     moveARE.WaitOne();
     return selectedMove;
 }
示例#8
0
 void IGameDisplay.DispĺayMove(Move move)
 {
     if (DisplayMove != null)
     {
         Deployment.Current.Dispatcher.BeginInvoke(delegate()
         {
             DisplayMove(move);
         });
         Delay(false);
     }
 }
示例#9
0
文件: Game.cs 项目: omahlama/Limake
 public HistoryEntry(Situation sit, Move move)
 {
     this.situation = sit;
     this.move = move;
 }
示例#10
0
 void IGameDisplay.DispĺayMove(Move move)
 {
 }