<commit_before>package com.github.lstephen.ootp.ai.value;

import com.github.lstephen.ootp.ai.player.Player;
import com.github.lstephen.ootp.ai.player.Slot;
import com.github.lstephen.ootp.ai.report.RosterReport;
import com.github.lstephen.ootp.ai.roster.Changes;
import com.github.lstephen.ootp.ai.roster.Changes.ChangeType;
import com.github.lstephen.ootp.ai.site.Site;

import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.function.Supplier;

import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
import com.google.common.collect.Sets;

import com.github.lstephen.ai.search.Heuristic;
import com.github.lstephen.ai.search.HillClimbing;
import com.github.lstephen.ai.search.RepeatedHillClimbing;
import com.github.lstephen.ai.search.action.Action;
import com.github.lstephen.ai.search.action.ActionGenerator;

/**
 *
 * @author lstephen
 */
public final class FreeAgentAcquisition {

    private final Player fa;

    private final Player release;

    private FreeAgentAcquisition(Player fa, Player release) {
        this.fa = fa;
        this.release = release;
    }

    private FreeAgentAcquisition withFreeAgent(Player fa) {
        return new FreeAgentAcquisition(fa, release);
    }

    private FreeAgentAcquisition withRelease(Player release) {
        return new FreeAgentAcquisition(fa, release);
    }

    public Player getFreeAgent() {
        return fa;
    }

    public Player getRelease() {
        return release;
    }

    public Integer score(RosterReport rr, TradeValue value) {
        Integer score = 0;

        score += value.getTradeTargetValue(fa);
        score -= value.getTradeTargetValue(release);

        // Penalize for releasing player in needed slot
        for (Slot s : release.getSlots()) {
            if (s != Slot.P) {
                score -= Math.max(0, rr.getTargetRatio() - rr.getRatio(s));
            }
        }

        // Reward for acquiring player in needed slot
        score += Math.max(0, rr.getTargetRatio() - rr.getRatio(Slot.getPrimarySlot(fa)));

        return score;
    }

    public static FreeAgentAcquisition create(Player fa, Player release) {
        return new FreeAgentAcquisition(fa, release);
    }

    public static ImmutableSet<FreeAgentAcquisition> select(Site site, Changes changes, Iterable<Player> roster, Iterable<Player> fas, TradeValue value, Integer n) {<commit_msg>Ignore H slot in FAA logic<commit_after>package com.github.lstephen.ootp.ai.value;

import com.github.lstephen.ootp.ai.player.Player;
import com.github.lstephen.ootp.ai.player.Slot;
import com.github.lstephen.ootp.ai.report.RosterReport;
import com.github.lstephen.ootp.ai.roster.Changes;
import com.github.lstephen.ootp.ai.roster.Changes.ChangeType;
import com.github.lstephen.ootp.ai.site.Site;

import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.function.Supplier;

import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
import com.google.common.collect.Sets;

import com.github.lstephen.ai.search.Heuristic;
import com.github.lstephen.ai.search.HillClimbing;
import com.github.lstephen.ai.search.RepeatedHillClimbing;
import com.github.lstephen.ai.search.action.Action;
import com.github.lstephen.ai.search.action.ActionGenerator;

/**
 *
 * @author lstephen
 */
public final class FreeAgentAcquisition {

    private final Player fa;

    private final Player release;

    private FreeAgentAcquisition(Player fa, Player release) {
        this.fa = fa;
        this.release = release;
    }

    private FreeAgentAcquisition withFreeAgent(Player fa) {
        return new FreeAgentAcquisition(fa, release);
    }

    private FreeAgentAcquisition withRelease(Player release) {
        return new FreeAgentAcquisition(fa, release);
    }

    public Player getFreeAgent() {
        return fa;
    }

    public Player getRelease() {
        return release;
    }

    public Integer score(RosterReport rr, TradeValue value) {
        Integer score = 0;

        score += value.getTradeTargetValue(fa);
        score -= value.getTradeTargetValue(release);

        // Penalize for releasing player in needed slot
        for (Slot s : release.getSlots()) {
            if (s != Slot.P && s != Slot.H) {
                score -= Math.max(0, rr.getTargetRatio() - rr.getRatio(s));
            }
        }

        // Reward for acquiring player in needed slot
        score += Math.max(0, rr.getTargetRatio() - rr.getRatio(Slot.getPrimarySlot(fa)));

        return score;
    }

    public static FreeAgentAcquisition create(Player fa, Player release) {
        return new FreeAgentAcquisition(fa, release);
    }

    public static ImmutableSet<FreeAgentAcquisition> select(Site site, Changes changes, Iterable<Player> roster, Iterable<Player> fas, TradeValue value, Integer n) {
{'fraction_non_alphanumeric': 0.10563114134542706, 'fraction_numerical': 0.0011337868480725624, 'mean_word_length': 3.4218880534670006, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5014152', 'n_tokens_mistral': 1660, 'n_tokens_neox': 1594, 'n_words': 341}