GithubHelp home page GithubHelp logo

jfap's Introduction

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

jfap's People

Contributors

jabbo16 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

jfap's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.