CONNECT FOUR
TOPIC 03v2 – CONNECT FOUR AI

 

AI CALLING ANOTHER AI (MixItUpAI01)

 

 

DESCRIPTION

 

The following AIAgent, called MixItUpAI01, has a 50% chance of calling CampeauAI01 to make the move and a 50% chance of calling CampeauAI02 to make the move.  Check out the simple code to see how this is done.

 

//MixItUpAI01

//

//DESC: Every move, this AI acts like either CampeauAI01 or CampeauAI02.

//The hope is that you will get best from both AIAgents.  Of course, you

//might end up getting the worst of both instead.

//

//KNOWN FLAW: None.

//

//RESULTS VERSUS RandomAI01: ??? (Test it if you want to know.)

 

public class MixItUpAI01 implements AIAgent

{

       @Override

       public int playMove(Game g, int playerNumber)

       {

             if (Math.random() < 0.50)

                    return new CampeauAI01().playMove(g, playerNumber);  //CampeauAI01

             else

                    return new CampeauAI02().playMove(g, playerNumber);  //CampeauAI02

       }

 

       @Override

       public String getName()

       {

             return "MixItUpAI01";

       }

 

       @Override

       public String getWinQuote(double winPercentage)

       {

             return "Mixin' it up for the win!";

       }

 

       @Override

       public String getAuthor()

       {

             return "Patrick Campeau";

       }

 

       @Override

       public void justWon()

       {

       }

 

       @Override

       public void justLost()

       {           

       }

 

       @Override

       public void justTied()

       {     

       }

}