Package fr.neatmonster.nocheatplus.utilities

Examples of fr.neatmonster.nocheatplus.utilities.ActionFrequency


    public double  reachDistance;
   

    public BlockBreakData(final BlockBreakConfig cc) {
    stats = cc.fastBreakDebug?(new Timings("NCP/FASTBREAK")):null;
    fastBreakPenalties = new ActionFrequency(cc.fastBreakBuckets, cc.fastBreakBucketDur);
    frequencyBuckets = new ActionFrequency(cc.frequencyBuckets, cc.frequencyBucketDur);
    wrongBlockVL = new ActionFrequency(6, 20000);
  }
View Full Code Here


    public MoveConsistency vehicleConsistency = MoveConsistency.INCONSISTENT;

    public MovingData(final ConfigFile config) {
        // TODO: Parameters from cc.
        final int nob = 2 * Math.max(1, Math.min(60, config.getInt(ConfPaths.MOVING_MOREPACKETS_SECONDS)));
        morePacketsFreq = new ActionFrequency(nob, 500);
        morePacketsBurstFreq = new ActionFrequency(12, 5000);
    }
View Full Code Here

  @Override
  protected float getScore(List<Character> chars, long ts) {
    lastAdd = ts;
    final char[] a = DigestedWords.toArray(chars);
    final String key = new String(a);
    ActionFrequency freq = entries.get(key);
    if (freq == null){
      freq = new ActionFrequency(nBuckets, durBucket);
      entries.put(key, freq);
      return 0.0f;
    }
    freq.update(ts);
    float score = Math.min(1.0f, freq.score(factor));
    freq.add(ts, 1.0f);
    return score;
  }
View Full Code Here

  /** Last explosion damaged entity (id). */
  public int            lastExplosionEntityId  = Integer.MAX_VALUE;
                    
 
  public FightData(final FightConfig cc){
    speedBuckets = new ActionFrequency(cc.speedBuckets, cc.speedBucketDur);
    // Start with full fast-heal buffer.
    fastHealBuffer = cc.fastHealBuffer;
  }
View Full Code Here

public class TestActionFrequency {

  @Test
  public void testSum() {
    ActionFrequency freq = new ActionFrequency(10, 100);
    for (int i = 0; i < 10; i++){
      freq.setBucket(i, 1);
    }
    if (freq.score(1f) != 10f) fail("10x1=10");
    freq.clear(0);
    if (freq.score(1f) != 0f) fail("clear=0");
   
    // TODO: more tests...
  }
View Full Code Here

  /**
   * Test adding 1 such that each bucket gets filled with an equal total amount.
   * @param time Point of time from which to start.
   */
  public void addFromTime(long time){
    ActionFrequency freq = new ActionFrequency(3, 333);
    freq.update(time);
    for (int i = 0; i < 999; i++){
      freq.add(time + i, 1f);
      // TODO: maybe test sums here already.
    }
    if (freq.score(1f) != 999) fail("Sum should be 999, got instead: " + freq.score(1f));
    freq.update(time + 999);
    if (freq.score(1f) != 666f) fail("Sum should be 666, got instead: " + freq.score(1f));
    freq.update(time + 1332);
    if (freq.score(1f) != 333f) fail("Sum should be 333, got instead: " + freq.score(1f));
    freq.update(time + 1665);
    if (freq.score(1f) != 0f) fail("Sum should be 0, got instead: " + freq.score(1f));
  }
View Full Code Here

 
  @Test
  public void testUpdateAlternatingSignumTimes(){
    // Basically fails if this generates an exception.
    int sig = 1;
    ActionFrequency freq = new ActionFrequency(10, 100);
    for (int i = 0; i < 1000; i++){
      freq.update(i * sig);
      sig = sig * -1;
    }
  }
 
View Full Code Here

    super(CheckType.CHAT_LOGINS);
  }
 
  private ActionFrequency getActionFrequency(String worldName, int buckets, long durBucket, boolean perWorldCount){
      if (!perWorldCount) worldName = "";
      ActionFrequency freq = counts.get(worldName);
      if (freq == null) freq = new ActionFrequency(buckets, durBucket);
      counts.put(worldName, freq);
      return freq;
  }
View Full Code Here

        final long now = System.currentTimeMillis();
        // Skip if is too close to the startup time.
        if (now - TickTask.getTimeStart() < cc.loginsStartupDelay) return false;
        // Split into 6 buckets always.
        final long durBucket = 1000L * cc.loginsSeconds / 6;
        final ActionFrequency freq = getActionFrequency(player.getWorld().getName(), 6, durBucket, cc.loginsPerWorldCount);
        freq.update(now);
        final boolean cancel = freq.score(1f) > cc.loginsLimit; // TODO: >= ...  This will be 1 after the first login (!).
        if (!cancel) freq.add(1f);
        return cancel;
    }
View Full Code Here

  public void playerLeaves(Player player) {
    freqMap.remove(player.getName());
  }
 
  private ActionFrequency getFreq(final String name) {
    final ActionFrequency freq = this.freqMap.get(name);
    if (freq != null) {
      return freq;
    } else {
      final ActionFrequency newFreq = new ActionFrequency(seconds, 1000);
      this.freqMap.put(name, newFreq);
      return newFreq;
    }
  }
View Full Code Here

TOP

Related Classes of fr.neatmonster.nocheatplus.utilities.ActionFrequency

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.