Exemple #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);
            }
        }
        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);
            }
        }
Exemple #3
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 );
     }
 }
Exemple #4
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 );
     }
 }
Exemple #5
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 );
     }
 }
Exemple #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;
        }
Exemple #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 );
     }
 }
Exemple #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;
        }
Exemple #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 );
            }
        }