Example #1
0
  private void theirBetAction(PerformedAction performedAction) {
    theirBetsThisStreet += performedAction.getAmount();

    double potBet =
        (double) performedAction.getAmount() / (brain.potSize - performedAction.getAmount());

    if (potBet < 0.2) return;

    theirRaiseHistory[currentState.ordinal()].add(performedAction.getAmount());

    double PFR = adjustPFR(maj.getPFR());
    double AGGRO = adjustAggro(maj.getAggression());
    double AGGROFREQ = adjustAggroFreq(maj.getAggressionFrequency());

    double logFactor =
        HelperUtils.logisticSmall(3.0, 3.0, potBet)
            * Math.min(
                100.0,
                (HelperUtils.logistic(400.0, 400.0, performedAction.getAmount()) + 300.0) / 4);

    if (currentState == GameState.PREFLOP) {
      changeEquity -= pfRaiseFactor * logFactor / PFR;
    } else {
      changeEquity -= pfRaiseFactor * logFactor / AGGROFREQ;
    }

    changeEquityCall = 0.0;
  }
Example #2
0
  private Move.Rotation getBestRotationDirection() {
    Point2D centerPosition = getPlayerTank().getCenterPoint();
    double rotationAngle = (getPlayerTank().getRotationAngle() + 270) % 360;
    double fieldWidth = GameState.getFieldWidth(), fieldHeight = GameState.getFieldHeight();

    Point2D crossPoints[] = new Point2D[2];
    GameState.SystemSides targetSides[] = new GameState.SystemSides[2];
    targetSides[0] = findSystemSide(centerPosition, rotationAngle, fieldWidth, fieldHeight);
    targetSides[1] =
        findSystemSide(centerPosition, (rotationAngle + 180) % 360, fieldWidth, fieldHeight);

    for (int i = 0; i < 2; i++) {
      crossPoints[i] =
          getCrossPointWithSide(
              centerPosition, rotationAngle, fieldWidth, fieldHeight, targetSides[i]);
    }

    return getShortestRotation(fieldWidth, fieldHeight, crossPoints);
  }
Example #3
0
  private void theirCheckAction(PerformedAction performedAction) {
    checkHistory[currentState.ordinal()] = true;

    double PFR = adjustPFR(maj.getPFR());
    double AGGRO = adjustAggro(maj.getAggression());
    double AGGROFREQ = adjustAggroFreq(maj.getAggressionFrequency());
    double CHECKRAISE = maj.getCheckRaise();

    if (currentState == GameState.PREFLOP) {
      changeEquityCall = pfCheckFactor * PFR * (1.0 - 4 * CHECKRAISE);
    } else {
      changeEquityCall = pfCheckFactor * AGGROFREQ * (1.0 - 4 * CHECKRAISE);
    }
  }
Example #4
0
  private void theirRaiseAction(PerformedAction performedAction) {

    double potBet =
        (double) (performedAction.getAmount() - theirBetsThisStreet)
            / (brain.potSize - performedAction.getAmount());
    if (potBet < 0.2) {
      theirBetsThisStreet += performedAction.getAmount();
      return;
    }

    theirRaiseHistory[currentState.ordinal()].add(performedAction.getAmount());

    double PFR = adjustPFR(maj.getPFR());
    double AGGRO = adjustAggro(maj.getAggression());
    double AGGROFREQ = adjustAggroFreq(maj.getAggressionFrequency());

    double logFactor =
        HelperUtils.logisticSmall(3.0, 3.0, potBet)
            * Math.min(
                100.0,
                (HelperUtils.logistic(
                            400.0, 400.0, performedAction.getAmount() - theirBetsThisStreet)
                        + 300.0)
                    / 4);

    double THREEB = maj.get3BetRate();
    double TWOB = maj.get2BetRate();

    if (myRaiseHistory[currentState.ordinal()].size() == 1
        && theirRaiseHistory[currentState.ordinal()].size() == 1) {
      logFactor *=
          1.0
              + (0.2 - TWOB)
                  * Math.min(100.0, myRaiseHistory[currentState.ordinal()].get(0))
                  / 30.0;
    } else if (theirRaiseHistory[currentState.ordinal()].size() == 2) {
      logFactor *= 1.0 + (0.25 - THREEB) * 1.5;
    } else if (theirRaiseHistory[currentState.ordinal()].size() >= 3) {
      logFactor *= 1.0 + (0.25 - THREEB) * 3.0;
    }

    if (currentState == GameState.PREFLOP) {
      changeEquity -= pfRaiseFactor * logFactor / PFR;
    } else {
      changeEquity -= pfRaiseFactor * logFactor / AGGROFREQ;
    }

    changeEquityCall = 0.0;
    theirBetsThisStreet += performedAction.getAmount();
  }
Example #5
0
  private void myRaiseAction(PerformedAction performedAction) {
    myBetsThisStreet += performedAction.getAmount();

    myRaiseHistory[currentState.ordinal()].add(performedAction.getAmount());
  }
Example #6
0
  public Move makeMove(double deltaTime) {
    Point2D tankPosition = getPlayerTank().getCenterPoint();
    switch (currentAction) {
      case Searching:
        if (target == null) {
          searchForTarget();
        }
        if (target != null) {
          currentAction = Action.ReachingTarget;
        }
        break;

      case ReachingTarget:
        if ((euclideanSpaceDistance(target, getPlayerTank().getCenterPoint()) < bonusRadius)) {
          target = null;
          isAngleSet = false;
        }
        if (target == null) {
          currentAction = Action.Searching;
          isSearchingStarted = false;
        }
        break;
    }

    switch (currentAction) {
      case Idle:
        break;

      case Searching:
        if (!isSearchingStarted) {
          rotationToDo = getBestRotationDirection();
          isSearchingStarted = true;
        }
        movementToDo = Move.Movement.Staying;
        break;

      case ReachingTarget:
        double bonusAngle =
            (Math.toDegrees(
                        Math.atan2(
                            target.getY() - tankPosition.getY(),
                            target.getX() - tankPosition.getX()))
                    + 360)
                % 360;
        double tankRotationAngle = (getPlayerTank().getRotationAngle() + 270) % 360;
        double bonusVisionAngle =
            (Math.toDegrees(Math.atan2(bonusRadius, euclideanSpaceDistance(tankPosition, target)))
                    + 360)
                % 360;
        double deltaAngle = (bonusAngle - tankRotationAngle + 360) % 360;

        double shift = euclideanSpaceDistance(tankPosition, lastPosition);
        double maxShift =
            2 * getPlayerTank().getVelocity() * (1.0 / GameState.getFramesPerSecond());
        if (shift > maxShift) {
          isAngleSet = false;
        }

        if (!isAngleSet) {
          if (deltaAngle < 180 + bonusVisionAngle && deltaAngle > 180 - bonusVisionAngle) {
            isAngleSet = true;
          } else if (deltaAngle >= 0 && deltaAngle <= 180 - bonusVisionAngle) {
            rotationToDo = Move.Rotation.CounterClockwise;
          } else if (deltaAngle >= 180 + bonusVisionAngle && deltaAngle < 360) {
            rotationToDo = Move.Rotation.Clockwise;
          }
          movementToDo = Move.Movement.Staying;
        } else {
          double tankRadius = getPlayerTank().getRadius();
          if (tankPosition.getY() - tankRadius <= tankRadius / 8) {
            if (tankRotationAngle >= 0 && tankRotationAngle < 90) {
              rotationToDo = Move.Rotation.CounterClockwise;
            } else if (tankRotationAngle > 90 && tankRotationAngle <= 180) {
              rotationToDo = Move.Rotation.Clockwise;
            }
          } else if (tankPosition.getX() + tankRadius
              >= GameState.getFieldWidth() - tankRadius / 8) {
            if (tankRotationAngle >= 90 && tankRotationAngle < 180) {
              rotationToDo = Move.Rotation.CounterClockwise;
            } else if (tankRotationAngle > 180 && tankRotationAngle <= 270) {
              rotationToDo = Move.Rotation.Clockwise;
            }
          } else if (tankPosition.getY() + tankRadius >= GameState.fieldHeight - tankRadius / 8) {
            if (tankRotationAngle >= 180 && tankRotationAngle < 270) {
              rotationToDo = Move.Rotation.CounterClockwise;
            } else if (tankRotationAngle > 270 && tankRotationAngle <= 360) {
              rotationToDo = Move.Rotation.Clockwise;
            }
          } else if (tankPosition.getX() - tankRadius <= tankRadius / 8) {
            if (tankRotationAngle >= 270 && tankRotationAngle < 360) {
              rotationToDo = Move.Rotation.CounterClockwise;
            } else if (tankRotationAngle > 0 && tankRotationAngle <= 90) {
              rotationToDo = Move.Rotation.Clockwise;
            }
          } else {
            rotationToDo = Move.Rotation.Staying;
          }
          if (rotationToDo != Move.Rotation.Staying) {
            isAngleSet = false;
          }
          movementToDo = Move.Movement.Backward;
        }

        lastPosition = getPlayerTank().getCenterPoint();

        break;
    }

    return new Move(movementToDo, rotationToDo, shootingToDo);
  }