Package com.jacobpatterson.csci446.program1.core

Examples of com.jacobpatterson.csci446.program1.core.Cell


        case 1 :
          agents[BLACK] = new RandomAgent(konaneGame);
          agents[WHITE] = new RandomAgent(konaneGame);
          break;
        case 2 :
          agents[WHITE] = new AlphabetaAgent(konaneGame, 4);
          agents[BLACK] = new AlphabetaAgent(konaneGame, 4);
          break;
        case 3 :
          agents[WHITE] = new AlphabetaAgent(konaneGame, 4);
          agents[BLACK] = new MinimaxAgent(konaneGame, 4);
          break;
        case 4 :
          agents[BLACK] = new MinimaxAgent(konaneGame, 2);
          agents[WHITE] = new AlphabetaAgent(konaneGame, 6);
          break;
        case 5 :
          agents[BLACK] = new AlphabetaAgent(konaneGame, 6);
          agents[WHITE] = new MinimaxAgent(konaneGame, 2);
          break;
        case 6 :
          agents[BLACK] = new RandomAgent(konaneGame);
          agents[WHITE] = new AlphabetaAgent(konaneGame, 6);
          break;
      }
      this.play(agents, numGames, writer);
    }
    writer.close();
View Full Code Here


  /**
   * Plays the current recording.
   */
  public void replayRecording()
  {
    KonaneGamePlayer players = new KonaneGamePlayer(konaneGame,
        this.getMovesToPlay());
    players.replayGame();
  }
View Full Code Here

    this.agents = new Agent[2];

    konaneGameRecorder = new KonaneGameRecorder();
    konaneGame = new KonaneGame(dimension, konaneGameRecorder);
    konaneCanvas = new KonaneCanvas(konaneGame);
    konaneUI = new KonaneUI(konaneGame, konaneCanvas);
    konaneCanvas.addMouseListener(konaneUI);
    KonaneMenu konaneMenu = new KonaneMenu(konaneGame, konaneGameRecorder);
    for(int i = 0; i < konaneMenu.getMenuCount(); i++)
    {
      JMenu menu = konaneMenu.getMenu(i);
View Full Code Here

    this.setResizable(false);
   
    blackSearchDepth = 4;
    whiteSearchDepth = 2;
    agents[KonanePiece.WHITE.ordinal()]
        = new MinimaxAgent(konaneGame, whiteSearchDepth);
    agentMoveTimerDelay = 500;
    this.agentMoveTimer = new Timer(agentMoveTimerDelay, this);
    agentMoveTimer.setRepeats(false);
  }
View Full Code Here

        // TODO: Duplicate-ish switch code:
        switch(konaneGame.getBlackPlayerType())
        {
          case MINIMAX :
            agents[KonanePiece.BLACK.ordinal()]
                = new MinimaxAgent(konaneGame, blackSearchDepth);
            break;
          case ALPHA_BETA :
            agents[KonanePiece.BLACK.ordinal()]
                = new AlphabetaAgent(konaneGame, blackSearchDepth);
            break;
          case RANDOM :
            agents[KonanePiece.BLACK.ordinal()]
                = new RandomAgent(konaneGame);
            break;
        }
        switch(konaneGame.getWhitePlayerType())
        {
          case MINIMAX :
            agents[KonanePiece.WHITE.ordinal()]
                = new MinimaxAgent(konaneGame, whiteSearchDepth);
            break;
          case ALPHA_BETA :
            agents[KonanePiece.WHITE.ordinal()]
                = new AlphabetaAgent(konaneGame, whiteSearchDepth);
            break;
View Full Code Here

    {
      Agent[] agents = new Agent[2];
      switch(i)
      {
        case 0 :
          agents[BLACK] = new MinimaxAgent(konaneGame,2);
          agents[WHITE] = new MinimaxAgent(konaneGame, 2);
          break;
        case 1 :
          agents[BLACK] = new RandomAgent(konaneGame);
          agents[WHITE] = new RandomAgent(konaneGame);
          break;
        case 2 :
          agents[WHITE] = new AlphabetaAgent(konaneGame, 4);
          agents[BLACK] = new AlphabetaAgent(konaneGame, 4);
          break;
        case 3 :
          agents[WHITE] = new AlphabetaAgent(konaneGame, 4);
          agents[BLACK] = new MinimaxAgent(konaneGame, 4);
          break;
        case 4 :
          agents[BLACK] = new MinimaxAgent(konaneGame, 2);
          agents[WHITE] = new AlphabetaAgent(konaneGame, 6);
          break;
        case 5 :
          agents[BLACK] = new AlphabetaAgent(konaneGame, 6);
          agents[WHITE] = new MinimaxAgent(konaneGame, 2);
          break;
        case 6 :
          agents[BLACK] = new RandomAgent(konaneGame);
          agents[WHITE] = new AlphabetaAgent(konaneGame, 6);
          break;
View Full Code Here

            agents[KonanePiece.BLACK.ordinal()]
                = new AlphabetaAgent(konaneGame, blackSearchDepth);
            break;
          case RANDOM :
            agents[KonanePiece.BLACK.ordinal()]
                = new RandomAgent(konaneGame);
            break;
        }
        switch(konaneGame.getWhitePlayerType())
        {
          case MINIMAX :
            agents[KonanePiece.WHITE.ordinal()]
                = new MinimaxAgent(konaneGame, whiteSearchDepth);
            break;
          case ALPHA_BETA :
            agents[KonanePiece.WHITE.ordinal()]
                = new AlphabetaAgent(konaneGame, whiteSearchDepth);
            break;
          case RANDOM :
            agents[KonanePiece.WHITE.ordinal()]
                = new RandomAgent(konaneGame);
            break;
        }
        this.makeFirstMove();
        break;
      case MOVE_MADE :
View Full Code Here

        case 0 :
          agents[BLACK] = new MinimaxAgent(konaneGame,2);
          agents[WHITE] = new MinimaxAgent(konaneGame, 2);
          break;
        case 1 :
          agents[BLACK] = new RandomAgent(konaneGame);
          agents[WHITE] = new RandomAgent(konaneGame);
          break;
        case 2 :
          agents[WHITE] = new AlphabetaAgent(konaneGame, 4);
          agents[BLACK] = new AlphabetaAgent(konaneGame, 4);
          break;
        case 3 :
          agents[WHITE] = new AlphabetaAgent(konaneGame, 4);
          agents[BLACK] = new MinimaxAgent(konaneGame, 4);
          break;
        case 4 :
          agents[BLACK] = new MinimaxAgent(konaneGame, 2);
          agents[WHITE] = new AlphabetaAgent(konaneGame, 6);
          break;
        case 5 :
          agents[BLACK] = new AlphabetaAgent(konaneGame, 6);
          agents[WHITE] = new MinimaxAgent(konaneGame, 2);
          break;
        case 6 :
          agents[BLACK] = new RandomAgent(konaneGame);
          agents[WHITE] = new AlphabetaAgent(konaneGame, 6);
          break;
      }
      this.play(agents, numGames, writer);
    }
View Full Code Here

        caf = new CellAddressFactory(1);
        input = caf.getSpaceForNewRelation(1);//(a)
        standOper = new StandarizationOperator(caf, input);
        resultFormulas = standOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('B',1), "IF(ISNA($A1),0,1)");
        expectedResult.put(new Cell('C',1), "MATCH(ROW(),$B:$B,0)");
        expectedResult.put(new Cell('D',1), "INDEX(A:A,$C1)");
        expectedResult.put(new Cell('B',2), "IF(ISNA($A2),B1,B1+1)");
        expectedResult.put(new Cell('C',2), "MATCH(ROW(),$B:$B,0)");
        expectedResult.put(new Cell('D',2), "INDEX(A:A,$C2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
        resRelation = standOper.getResultRelation();
        assertEquals(new Column('D'), resRelation.getFirstCol());
        assertEquals(1, resRelation.getCardinality());

        caf = new CellAddressFactory(1);
        input = caf.getSpaceForNewRelation(2);//(a,b)
        standOper = new StandarizationOperator(caf, input);
        resultFormulas = standOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('C',1), "IF(ISNA($A1),0,1)");
        expectedResult.put(new Cell('D',1), "MATCH(ROW(),$C:$C,0)");
        expectedResult.put(new Cell('E',1), "INDEX(A:A,$D1)");
        expectedResult.put(new Cell('F',1), "INDEX(B:B,$D1)");
        expectedResult.put(new Cell('C',2), "IF(ISNA($A2),C1,C1+1)");
        expectedResult.put(new Cell('D',2), "MATCH(ROW(),$C:$C,0)");
        expectedResult.put(new Cell('E',2), "INDEX(A:A,$D2)");
        expectedResult.put(new Cell('F',2), "INDEX(B:B,$D2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
        resRelation = standOper.getResultRelation();
        assertEquals(new Column('E'), resRelation.getFirstCol());
        assertEquals(2, resRelation.getCardinality());

        caf = new CellAddressFactory(2);//zaczynamy od B
        input = caf.getSpaceForNewRelation(3);//(b,c,d)
        standOper = new StandarizationOperator(caf, input);
        resultFormulas = standOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('E',1), "IF(ISNA($B1),0,1)");
        expectedResult.put(new Cell('F',1), "MATCH(ROW(),$E:$E,0)");
        expectedResult.put(new Cell('G',1), "INDEX(B:B,$F1)");
        expectedResult.put(new Cell('H',1), "INDEX(C:C,$F1)");
        expectedResult.put(new Cell('I',1), "INDEX(D:D,$F1)");
        expectedResult.put(new Cell('E',2), "IF(ISNA($B2),E1,E1+1)");
        expectedResult.put(new Cell('F',2), "MATCH(ROW(),$E:$E,0)");
        expectedResult.put(new Cell('G',2), "INDEX(B:B,$F2)");
        expectedResult.put(new Cell('H',2), "INDEX(C:C,$F2)");
        expectedResult.put(new Cell('I',2), "INDEX(D:D,$F2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
View Full Code Here

        caf = new CellAddressFactory(1);
        inputRelation = caf.getSpaceForNewRelation(1);//(a)
        sortAscOper = new SortingAscendingOperator(caf, inputRelation, 1);
        resultFormulas = sortAscOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('B',1), "COUNTA($A:$A)-COUNTIF($A:$A,NA())");
        expectedResult.put(new Cell('C',1), "IF(ISNA($A1),$B$1+1,IF(ISERR($A1),1+$B$1-COUNTIF($A:$A,$A1),COUNTIF($A:$A,\"<\"&$A1)+COUNTIF($A$1:$A1,$A1)))");
        expectedResult.put(new Cell('D',1), "MATCH(ROW(),$C:$C,0)");
        expectedResult.put(new Cell('E',1), "INDEX(A:A,$D1)");
        expectedResult.put(new Cell('C',2), "IF(ISNA($A2),$B$1+1,IF(ISERR($A2),1+$B$1-COUNTIF($A:$A,$A2),COUNTIF($A:$A,\"<\"&$A2)+COUNTIF($A$1:$A2,$A2)))");
        expectedResult.put(new Cell('D',2), "MATCH(ROW(),$C:$C,0)");
        expectedResult.put(new Cell('E',2), "INDEX(A:A,$D2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
        resRelation = sortAscOper.getResultRelation();
        assertEquals(new Column('E'), resRelation.getFirstCol());
        assertEquals(1, resRelation.getCardinality());

        caf = new CellAddressFactory(1);
        inputRelation = caf.getSpaceForNewRelation(1);//(a)
        sortDescOper = new SortingDescendingOperator(caf, inputRelation, 1);
        resultFormulas = sortDescOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('B',1), "COUNTA($A:$A)-COUNTIF($A:$A,NA())");
        expectedResult.put(new Cell('C',1), "IF(ISNA($A1),$B$1+1,IF(ISERR($A1),1+$B$1-COUNTIF($A:$A,$A1),COUNTIF($A:$A,\">\"&$A1)+COUNTIF($A$1:$A1,$A1)))");
        expectedResult.put(new Cell('D',1), "MATCH(ROW(),$C:$C,0)");
        expectedResult.put(new Cell('E',1), "INDEX(A:A,$D1)");
        expectedResult.put(new Cell('C',2), "IF(ISNA($A2),$B$1+1,IF(ISERR($A2),1+$B$1-COUNTIF($A:$A,$A2),COUNTIF($A:$A,\">\"&$A2)+COUNTIF($A$1:$A2,$A2)))");
        expectedResult.put(new Cell('D',2), "MATCH(ROW(),$C:$C,0)");
        expectedResult.put(new Cell('E',2), "INDEX(A:A,$D2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
View Full Code Here

TOP

Related Classes of com.jacobpatterson.csci446.program1.core.Cell

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.