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);
            }
        }
Esempio n. 2
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 );
            }
        }
 public MoveRepresentationGenerator(GammonInterface game)
 {
     m_BgGame                = game;
     m_MoveList              = new BgMoveList();
     m_MoveGenerator         = new BgMoveGenerator(game);
     m_PatternEncoder        = new PatternEncoder();
     m_CurrentGeneratedMoves = new MoveRepresentationList();
 }
Esempio n. 4
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 );
     }
 }
Esempio n. 5
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 );
     }
 }
Esempio n. 6
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 );
     }
 }
Esempio n. 7
0
        private void GradePossibleMoves(MoveRepresentationList knowledgeList, BoardRepresentation initialBoard)
        {
            int evaluator = m_GUI.SelectedEvaluator();

            if (evaluator >= 0)
            {
                m_Plugins[evaluator].GradeBoards(knowledgeList, initialBoard);
            }
        }
Esempio n. 8
0
        public Agent( GammonInterface game )
        {
            m_GUI = new AgentGUI( "Agent " + (++m_InstanceCounter) );
            m_Rand = new Random();
            m_BgGame = game;
            m_MoveRepresentationList = new MoveRepresentationList();

            if ( m_MoveRepresentationGenerator == null )
                m_MoveRepresentationGenerator = new MoveRepresentationGenerator( game );

            LoadPlugins();
            OutputMovesAndScore = true;
        }
Esempio n. 9
0
        public Agent(GammonInterface game)
        {
            m_GUI    = new AgentGUI("Agent " + (++m_InstanceCounter));
            m_Rand   = new Random();
            m_BgGame = game;
            m_MoveRepresentationList = new MoveRepresentationList();

            if (m_MoveRepresentationGenerator == null)
            {
                m_MoveRepresentationGenerator = new MoveRepresentationGenerator(game);
            }

            LoadPlugins();
            OutputMovesAndScore = true;
        }
Esempio n. 10
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;
        }
        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 );
        }
 public MoveRepresentationGenerator( GammonInterface game )
 {
     m_BgGame = game;
     m_MoveList = new BgMoveList();
     m_MoveGenerator = new BgMoveGenerator( game );
     m_PatternEncoder = new PatternEncoder();
     m_CurrentGeneratedMoves = new MoveRepresentationList();
 }
Esempio n. 13
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 );
     }
 }
Esempio n. 14
0
 public abstract void GradeBoards(MoveRepresentationList list, BoardRepresentation initialBoard);
Esempio n. 15
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;
        }
Esempio n. 16
0
 private void GradePossibleMoves( MoveRepresentationList knowledgeList, BoardRepresentation initialBoard )
 {
     int evaluator = m_GUI.SelectedEvaluator();
     if ( evaluator >= 0 )
         m_Plugins[evaluator].GradeBoards( knowledgeList, initialBoard );
 }