Examples of ScoreCalculator


Examples of org.drools.planner.core.score.calculator.ScoreCalculator

    /**
     * @param presumedScore never null
     */
    public void assertWorkingScore(Score presumedScore) {
        StatefulSession tmpWorkingMemory = ruleBase.newStatefulSession();
        ScoreCalculator tmpScoreCalculator = workingScoreCalculator.clone();
        tmpWorkingMemory.setGlobal(GLOBAL_SCORE_CALCULATOR_KEY, tmpScoreCalculator);
        for (Object fact : workingSolution.getFacts()) {
            tmpWorkingMemory.insert(fact);
        }
        tmpWorkingMemory.fireAllRules();
        Score realScore = tmpScoreCalculator.calculateScore();
        tmpWorkingMemory.dispose();
        if (!presumedScore.equals(realScore)) {
            throw new IllegalStateException(
                    "The presumedScore (" + presumedScore + ") is corrupted because it is not the realScore  ("
                            + realScore + ").\n"
View Full Code Here

Examples of org.drools.planner.core.score.calculator.ScoreCalculator

        }
    }

    public void assertWorkingScore(Score presumedScore) {
        StatefulSession tmpWorkingMemory = ruleBase.newStatefulSession();
        ScoreCalculator tmpScoreCalculator = workingScoreCalculator.clone();
        tmpWorkingMemory.setGlobal(GLOBAL_SCORE_CALCULATOR_KEY, tmpScoreCalculator);
        for (Object fact : workingSolution.getFacts()) {
            tmpWorkingMemory.insert(fact);
        }
        tmpWorkingMemory.fireAllRules();
        Score realScore = tmpScoreCalculator.calculateScore();
        tmpWorkingMemory.dispose();
        if (!presumedScore.equals(realScore)) {
            throw new IllegalStateException(
                    "The presumedScore (" + presumedScore + ") is corrupted because it is not the realScore  ("
                            + realScore + ").\n"
View Full Code Here

Examples of org.drools.planner.core.score.calculator.ScoreCalculator

    /**
     * @param presumedScore never null
     */
    public void assertWorkingScore(Score presumedScore) {
        StatefulSession tmpWorkingMemory = ruleBase.newStatefulSession();
        ScoreCalculator tmpScoreCalculator = workingScoreCalculator.clone();
        tmpWorkingMemory.setGlobal(GLOBAL_SCORE_CALCULATOR_KEY, tmpScoreCalculator);
        for (Object fact : getWorkingFacts()) {
            tmpWorkingMemory.insert(fact);
        }
        tmpWorkingMemory.fireAllRules();
        Score realScore = tmpScoreCalculator.calculateScore();
        tmpWorkingMemory.dispose();
        if (!presumedScore.equals(realScore)) {
            throw new IllegalStateException(
                    "The presumedScore (" + presumedScore + ") is corrupted because it is not the realScore  ("
                            + realScore + ").\n"
View Full Code Here

Examples of org.gnubridge.core.bidding.ScoreCalculator

    MainController mainController = makeController();
    mainController.getBiddingController().placeBid(7, "Clubs");
    mainController.playGame();
    playGameToTheEnd(mainController);
    Thread.sleep(300);
    int score = new ScoreCalculator(mainController.getBiddingController().getAuction().getHighBid(), mainController
        .getGameController().getGame().getTricksTaken(Player.NORTH_SOUTH), new Vulnerability(false, false))
        .getDeclarerScore();
    System.out.println("Game finished. Declarers took "
        + mainController.getGameController().getGame().getTricksTaken(Player.NORTH_SOUTH) + " tricks. Score: "
        + score);

    assertTrue(1000 + 20 * 7 == score || 1500 + 20 * 7 == score);

    System.out.println("Running Human Score: " + mainController.getRunningHumanScore());
    System.out.println("Running Computer Score: " + mainController.getRunningComputerScore());
    assertEquals(0, mainController.getRunningComputerScore());

    preInitializeGame13Tricks();
    mainController.getGameController().newGame();
    mainController.getBiddingController().placeBid(7, "Spades");

    Thread.sleep(300);

    mainController.playGame();
    playGameToTheEnd(mainController);
    score = new ScoreCalculator(mainController.getBiddingController().getAuction().getHighBid(), mainController
        .getGameController().getGame().getTricksTaken(Player.NORTH_SOUTH), new Vulnerability(false, false))
        .getDefenderScore();

    System.out.println("Running Human Score: " + mainController.getRunningHumanScore());
    System.out.println("Running Computer Score: " + mainController.getRunningComputerScore());
View Full Code Here

Examples of org.gnubridge.core.bidding.ScoreCalculator

  }

  public void processFinishedGame(int directionOfHuman, Bid highBid, int declarerTricksTaken) {
    this.directionOfHuman = directionOfHuman;

    ScoreCalculator calculator = new ScoreCalculator(highBid, declarerTricksTaken, usThemVulnerability
        .asDeclarerDefender(directionOfHuman));

    latestDeclarerScoreChange = calculator.getDeclarerScore();
    latestDefenderScoreChange = calculator.getDefenderScore();

    if (isHumanDeclarer()) {
      runningHumanScore += latestDeclarerScoreChange;
      runningComputerScore += latestDefenderScoreChange;
    } else {
View Full Code Here

Examples of org.olat.course.run.scoring.ScoreCalculator

  /**
   * @return Returns the scoreCalculator.
   */
  public ScoreCalculator getScoreCalculator() {
    if (scoreCalculator == null) {
      scoreCalculator = new ScoreCalculator(null, null);
    }
    passedExpression = new Condition();
    passedExpression.setConditionId("passed");
    if (scoreCalculator.getPassedExpression() != null) {
      passedExpression.setConditionExpression(scoreCalculator.getPassedExpression());
View Full Code Here

Examples of org.olat.course.run.scoring.ScoreCalculator

    Condition accessCondition = stNode.getPreConditionAccess();
    accessibilityCondContr = new ConditionEditController(ureq, getWindowControl(), groupMgr, accessCondition, "accessabilityConditionForm",
        assessableChildren, euce);   
    this.listenTo(accessibilityCondContr);

    ScoreCalculator scoreCalc = stNode.getScoreCalculator();
    if (scoreCalc != null) {
      if (scoreCalc.isExpertMode() && scoreCalc.getPassedExpression() == null && scoreCalc.getScoreExpression() == null) {
        scoreCalc = null;
      } else if (!scoreCalc.isExpertMode() && scoreCalc.getPassedExpressionFromEasyModeConfiguration() == null
          && scoreCalc.getScoreExpressionFromEasyModeConfiguration() == null) {
        scoreCalc = null;
      }
    }

    if (assessableChildren.size() == 0 && scoreCalc == null) {
      // show only the no assessable children message, if no previous score
      // config exists.
      score.contextPut("noAssessableChildren", Boolean.TRUE);
    } else {
      score.contextPut("noAssessableChildren", Boolean.FALSE);
    }

    // Init score calculator form
    if (scoreCalc != null && scoreCalc.isExpertMode()) {
      initScoreExpertForm();
    } else {
      initScoreEasyForm();
    }
  }
View Full Code Here

Examples of org.olat.course.run.scoring.ScoreCalculator

        String msg = getWarningMessage(testElemWithNoResource);
        if(msg!=null) {               
          getWindowControl().setWarning(msg);
        }
       
        ScoreCalculator sc = scoreExpertForm.getScoreCalulator();
        /*
         * OLAT-1144 bug fix if a ScoreCalculator == NULL !
         */
        if (sc != null) {
          sc.clearEasyMode();
        }
        // ..setScoreCalculator(sc) can handle NULL values!
        stNode.setScoreCalculator(sc);
        fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
      } else if (event == Form.EVNT_FORM_CANCELLED) { // reload form
        initScoreExpertForm();
      }
    } else if (source == scoreEasyForm) {
      if (event == Form.EVNT_VALIDATION_OK) { 
        //show warning if the score might be wrong because of the invalid nodes used for calculation
        List<String> testElemWithNoResource = scoreEasyForm.getInvalidNodeDescriptions();
        String msg = getWarningMessage(testElemWithNoResource);
        if(msg!=null) {               
          getWindowControl().setWarning(msg);
        }
               
        ScoreCalculator sc = scoreEasyForm.getScoreCalulator();
        /*
         * OLAT-1144 bug fix if Calculation Score -> NO and Calculate passing
         * score -> NO we get a ScoreCalculator == NULL !
         */
        if (sc != null) {
          sc.setPassedExpression(sc.getPassedExpressionFromEasyModeConfiguration());
          sc.setScoreExpression(sc.getScoreExpressionFromEasyModeConfiguration());
        }
        // ..setScoreCalculator(sc) can handle NULL values!
        stNode.setScoreCalculator(sc);
        initScoreEasyForm(); // reload form, remove deleted nodes
        fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.