Пример #1
0
        public BgMove CommitMove()
        {
            if (IsAgentMoveing() && m_MoveRepresentationList.Count() > 0)
            {
                int    numBestMoves  = 1;
                double bestMoveScore = m_MoveRepresentationList.GetMoveRepresentation(0).GetScore();
                for (int i = 1; i < m_MoveRepresentationList.Count(); i++)
                {
                    double currentCompareMoveScore = m_MoveRepresentationList.GetMoveRepresentation(i).GetScore();
                    if (bestMoveScore == currentCompareMoveScore)
                    {
                        numBestMoves++;
                    }
                    else
                    {
                        break;
                    }
                }

                int selectedMove = m_Rand.Next(numBestMoves);

                MoveRepresentation bestMove = m_MoveRepresentationList.GetMoveRepresentation(selectedMove);
                BgMove             m        = bestMove.GetMoves().FirstMove;
                while (m != null)
                {
                    m_BgGame.MakeMove(m.From, m.To);
                    m = m.NextMove;
                }
                return(bestMove.GetMoves());
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
 public override void GradeBoards( MoveRepresentationList list, BoardRepresentation initialBoard )
 {
     for ( int i = 0; i < list.Count(); i++ )
     {
         double s = m_FuzzyController.ObtainBoardStrength( list.GetMoveRepresentation( i ) );
         list.GetMoveRepresentation( i ).AddScore( s );
     }
 }
Пример #3
0
 public override void GradeBoards( MoveRepresentationList list, BoardRepresentation initialBoard )
 {
     for ( int i = 0; i < list.Count(); i++ )
     {
         float[] output = Grade( list.GetMoveRepresentation( i ) );
         double s = output[0] + (2 * output[1]) + (3 * output[2]) - (2 * output[3]) - (3 * output[4]);
         list.GetMoveRepresentation( i ).AddScore( s );
     }
 }
        public void GeneratePossibleRepresentations(MoveRepresentationList knowledgeList)
        {
            string currentPattern = m_PatternEncoder.Encode(m_BgGame);

            if (!currentPattern.Equals(m_CurrentGeneratedPattern))
            {
                m_CurrentGeneratedMoves.Clear();
                m_MoveGenerator.GenerateMoves(m_MoveList);

                for (int i = 0; i < m_MoveList.Count(); i++)
                {
                    MoveRepresentation possibleMove = new MoveRepresentation(m_BgGame, m_MoveList.GetBgMove(i));
                    m_CurrentGeneratedMoves.AddMoveRepresentation(possibleMove, false);
                }

                m_CurrentGeneratedPattern = currentPattern;
            }

            knowledgeList.Clear();

            for (int i = 0; i < m_CurrentGeneratedMoves.Count(); i++)
            {
                knowledgeList.AddMoveRepresentation(m_CurrentGeneratedMoves.GetMoveRepresentation(i).GetClone(), true);
            }
        }
Пример #5
0
 public override void GradeBoards( MoveRepresentationList list, BoardRepresentation initialBoard )
 {
     for ( int i = 0; i < list.Count(); i++ )
     {
         double s = m_Random.NextDouble() - m_Random.NextDouble();
         list.GetMoveRepresentation( i ).AddScore( s );
     }
 }
Пример #6
0
        public void UpdatePossibleMovesList(MoveRepresentationList knowledgeList)
        {
            m_PossibilitiesList.Items.Clear();

            for (int i = 0; i < knowledgeList.Count(); i++)
            {
                string stringToAdd = "";

                BgMove m = knowledgeList.GetMoveRepresentation(i).GetMoves();
                while (m != null)
                {
                    stringToAdd += ((m.From == 25)? "bar" : m.From.ToString()) + "/" + ((m.To == 26)? "off" : m.To.ToString()) + "\t";
                    m            = m.NextMove;
                }
                stringToAdd += Math.Round(knowledgeList.GetMoveRepresentation(i).GetScore(), 5);
                m_PossibilitiesList.Items.Add(stringToAdd);
            }

            m_NumberPossibilitiesLabel.Text = "Possibilities: " + m_PossibilitiesList.Items.Count;
        }
Пример #7
0
 public override void GradeBoards( MoveRepresentationList list, BoardRepresentation initialBoard )
 {
     bool race = Race( initialBoard );
     for ( int i = 0; i < list.Count(); i++ )
     {
         Grade( list.GetMoveRepresentation( i ), race, m_Output );
         float regularLoseProberbilety = 1.0f - ( m_Output[0] + m_Output[1] + m_Output[2] + m_Output[3] + m_Output[4] );
         double equity = m_Output[0] + (2 * m_Output[1]) + (3 * m_Output[2]) - regularLoseProberbilety - (2 * m_Output[3]) - (3 * m_Output[4]);
         list.GetMoveRepresentation( i ).AddScore( equity );
     }
 }
Пример #8
0
        public void UpdatePossibleMovesList( MoveRepresentationList knowledgeList )
        {
            m_PossibilitiesList.Items.Clear();

            for ( int i = 0; i < knowledgeList.Count(); i++ )
            {
                string stringToAdd = "";

                BgMove m = knowledgeList.GetMoveRepresentation( i ).GetMoves();
                while ( m != null )
                {
                    stringToAdd += ( ( m.From == 25 )? "bar" : m.From.ToString() ) + "/" + ( ( m.To == 26 )? "off" : m.To.ToString() ) + "\t";
                    m = m.NextMove;
                }
                stringToAdd += Math.Round( knowledgeList.GetMoveRepresentation( i ).GetScore(), 5 );
                m_PossibilitiesList.Items.Add( stringToAdd );
            }

            m_NumberPossibilitiesLabel.Text = "Possibilities: " + m_PossibilitiesList.Items.Count;
        }
Пример #9
0
        public override void GradeBoards( MoveRepresentationList list, BoardRepresentation initialBoard )
        {
            int race = 1;
            bool opponentFound = false;
            for ( int i = 0; i < initialBoard.SquareCount() && race == 1; i++ )
            {
                if ( !opponentFound && initialBoard.GetPiecesAt( i ) < 0 )
                    opponentFound = true;

                if ( opponentFound && initialBoard.GetPiecesAt( i ) > 0 )
                    race = 0;
            }

            for ( int i = 0; i < list.Count(); i++ )
            {
                int[] pubevalBoard = new int[28];
                MoveRepresentation currentBoard = list.GetMoveRepresentation( i );

                for ( int j = 0; j < currentBoard.SquareCount(); j++ )
                    pubevalBoard[j] = currentBoard.GetPiecesAt( j );

                pubevalBoard[26] = currentBoard.BearOffCountCurrent();
                pubevalBoard[27] = currentBoard.BearOffCountOpponent();

                double s = PubevalGrade( race, pubevalBoard );
                list.GetMoveRepresentation( i ).AddScore( s );
            }
        }