001    package jagafa.ai;
002    
003    import jagafa.flags.TestingFlags;
004    import jagafa.scores.SchieberScoreTable;
005    import jagafa.scores.ScoreTable;
006    import jagafa.view.newui.RoundController2;
007    
008    import java.awt.event.ActionEvent;
009    import java.awt.event.ActionListener;
010    
011    import javax.swing.Timer;
012    
013    public class AITest {
014    
015            private static ScoreTable scoreTable_;
016    
017            /**
018             * @param args
019             */
020            public static void main(String[] args) {
021                    TestingFlags.automatedTest_ = true;
022                    TestingFlags.silentTest_ = true;
023                    TestingFlags.redirectSystemOut_ = false;
024                    TestingFlags.repeatedTest_ = true;
025                    TestingFlags.maxRepeats_ = 300;
026                    TestingFlags.speedUp_ = true;
027                    
028                    //AIFlags.GRADE_WEIGHT = 0.8;
029                    installRestartTimer();
030                    
031                    startTest();
032    
033                    
034            }
035    
036            private static void startTest() {
037                    
038                    TestingFlags.repeats_ = 0;
039                    TestingFlags.repeatedTest_ = true;
040                    scoreTable_ = new SchieberScoreTable(2000);
041                    controller = new RoundController2();
042                    controller.startRound(scoreTable_);
043                    
044            }
045    
046            private static RoundController2 controller;
047    
048            private static void playRound() {
049    
050                    controller.startRound(scoreTable_);
051                    while (controller.getRound().isRunning() ) {
052    
053                    }
054            }
055    
056            
057            private static void installRestartTimer() {
058                    /**
059                     * The restart timer is needed to wait for a new game to start
060                     * If he is called, then the game waits 6 seconds, then the game 
061                     * will reset and restart itself if the game is endless
062                     */
063                    Timer restartTimer_ = new Timer(900, new ActionListener() {
064    
065                            public void actionPerformed(ActionEvent e) {
066                                    if (TestingFlags.repeatedTest_==false) {
067                                            startTest();
068                                    }
069                            }
070    
071                    });
072                    restartTimer_.start();
073            }
074    }