예제 #1
0
파일: Capos.java 프로젝트: rwther/jmafio
  public boolean trySanction(Soldiers s) {

    // probability for the sanction in display!set a new parameter!

    sanctionProbability = sanctionProbability * 1.1;
    sanctionProbability = sanctionProbability > 1.0 ? 1.0 : sanctionProbability;

    // sanctionProbability =;
    double rnd = RandomHelper.nextDoubleFromTo(0.0, 1.0);
    if (rnd <= sanctionProbability) {
      sanction(s);
      return true;
    }
    return false;
  }
예제 #2
0
파일: Capos.java 프로젝트: rwther/jmafio
  public void giveExtorsionMoney(double amount, Soldiers soldier, Shop shop, Color territory) {
    // store money

    // distribute money
    // 50 persent for capos, then rest for solidiers

    System.out.println(
        "capo #"
            + this.getIndex()
            + "cummulatedIncome = "
            + cummulatedIncome
            + "extorsionCount = "
            + extorsionCount);

    extorsionCount++;

    cummulatedIncome += amount * 0.5;
    soldier.setMoney(soldier.getMoney() + amount * 0.5);
    System.out.println("capo #" + index + " has now: $" + cummulatedIncome);

    // draw edges between Capo and by own soldiers extorted shops
    Context<Object> context = ContextUtils.getContext(this);
    Network<Object> net = (Network<Object>) context.getProjection("network");
    net.addEdge(this, shop);

    // sanction if money from shop from other territory
    if (!territory.equals(familyColor)) {
      // decision process --> preliminary! --- TODO: could be implemented
      // with EMIL-S

      notPermittedExtorsionCount++;

      double rnd = RandomHelper.nextDoubleFromTo(0.0, 1.0);
      if (rnd <= sanctionProbability) {
        soldier.sanction(shop, territory);
        sanctionCount++;
      }
    }

    // notify the mandamento
    if (this != mandamento.getCapo()) {
      mandamento.onExtortMoney(index, cummulatedIncome);
    }
  }