Skip to content
/ JFAP Public

Java port of FAP (Fast APproximation)

License

Notifications You must be signed in to change notification settings

Jabbo16/JFAP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

JFAP

Description

JFAP is a Java port of FAP (Fast APproximation). Works with BWMirror 2.5+ and BWAPI4J.

FAP is a combat simulator for Starcraft:Brood War C++ bots originally made by Hannes Bredberg

How to use JFAP with BWMirror?

  1. Clone this project

    git clone https://github.com/Jabbo16/JFAP.git
  2. Copy the source code into your Eclipse/IntelliJ Idea Java project.

  3. This is an example code of how to start simulating combats:

    JFAP simulator = new JFAP(bwapi.getGame()); // Requires a 'Game' object to be passed by parameter
    simulator.clear(); // Before starting the simulations we need to clear the simulator
    simulator.addUnitPlayer1(new JFAPUnit(myUnit)); // Adds a friendly unit to the simulator
    simulator.addUnitPlayer2(new JFAPUnit(enemyUnit)); // Adds an enemy unit to the simulator
    Pair<Integer, Integer> preSimScores = simulator.playerScores(); // We can get each player scores before the simulation starts
    int preSimFriendlyUnitCount = simulator.getState().first.size(); // Friendly unit count introduced to JFAP before the simulation starts
    simulator.simulate(50); // Starts simulating the combat, number of frames to simulate is passed by parameters, default is 96 frames
    
    // After the simulation we can get the post battle score and the number of units that died for each player
    // You can use this info to know if the combat will be favourable for you or not
    Pair<Integer, Integer> postSimScores = simulator.playerScores();
    int postSimFriendlyUnitCount = simulator.getState().first.size();
    int myLosses = preSimFriendlyUnitCount - postSimFriendlyUnitCount;
    int myScoreDiff = preSimScores.first - postSimScores.first;
    int enemyScoreDiff = preSimScores.second - postSimScores.second;

How to use JFAP with BWAPI4J?

  1. Clone this project

    git clone https://github.com/Jabbo16/JFAP.git
  2. Copy the source code into your Eclipse/IntelliJ Idea Java project.

  3. This is an example code of how to start simulating combats:

    JFAP simulator = new JFAP(bw); // Requires a 'BW' object to be passed by parameter
    simulator.clear(); // Before starting the simulations we need to clear the simulator
    simulator.addUnitPlayer1(new JFAPUnit(myUnit)); // Adds a friendly unit to the simulator
    simulator.addUnitPlayer2(new JFAPUnit(enemyUnit)); // Adds an enemy unit to the simulator
    Pair<Integer, Integer> preSimScores = simulator.playerScores(); // We can get each player scores before the simulation starts
    int preSimFriendlyUnitCount = simulator.getState().first.size(); // Friendly unit count introduced to JFAP before the simulation starts
    simulator.simulate(50); // Starts simulating the combat, number of frames to simulate is passed by parameters, default is 96 frames
    
    // After the simulation we can get the post battle score and the number of units that died for each player
    // You can use this info to know if the combat will be favourable for you or not
    Pair<Integer, Integer> postSimScores = simulator.playerScores();
    int postSimFriendlyUnitCount = simulator.getState().first.size();
    int myLosses = preSimFriendlyUnitCount - postSimFriendlyUnitCount;
    int myScoreDiff = preSimScores.first - postSimScores.first;
    int enemyScoreDiff = preSimScores.second - postSimScores.second;

Credits

Releases

No releases published

Packages

No packages published

Languages