Search in sources :

Example 1 with TwoPlayerDuel

use of mage.game.TwoPlayerDuel in project mage by magefree.

the class RandomTest method test_GenerateRandomPlanarDicePng.

@Test
@Ignore
public void test_GenerateRandomPlanarDicePng() throws IOException {
    String dest = "f:/test/xmage/";
    // RandomUtil.setSeed(123);
    Player player = new HumanPlayer("random", RangeOfInfluence.ALL, 1);
    Game game = new TwoPlayerDuel(MultiplayerAttackOption.MULTIPLE, RangeOfInfluence.ALL, MulliganType.GAME_DEFAULT.getMulligan(0), 50);
    int height = 512;
    int weight = 512;
    BufferedImage image = new BufferedImage(weight, height, BufferedImage.TYPE_INT_RGB);
    for (int x = 0; x < weight; x++) {
        for (int y = 0; y < height; y++) {
            // roll planar dice
            PlanarDieRollResult res = player.rollPlanarDie(Outcome.Neutral, null, game);
            image.setRGB(x, y, new Color(res.equals(PlanarDieRollResult.CHAOS_ROLL) ? 255 : 0, res.equals(PlanarDieRollResult.PLANAR_ROLL) ? 255 : 0, res.equals(PlanarDieRollResult.BLANK_ROLL) ? 255 : 0).getRGB());
        }
    }
    ImageIO.write(image, "png", new File(dest + "xmage_random_planar_dice.png"));
}
Also used : Player(mage.players.Player) HumanPlayer(mage.player.human.HumanPlayer) Game(mage.game.Game) PlanarDieRollResult(mage.constants.PlanarDieRollResult) HumanPlayer(mage.player.human.HumanPlayer) TwoPlayerDuel(mage.game.TwoPlayerDuel) File(java.io.File) BufferedImage(java.awt.image.BufferedImage) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with TwoPlayerDuel

use of mage.game.TwoPlayerDuel in project mage by magefree.

the class RandomTest method test_GenerateRandomDicePng.

@Test
@Ignore
public void test_GenerateRandomDicePng() throws IOException {
    String dest = "f:/test/xmage/";
    // RandomUtil.setSeed(123);
    Player player = new HumanPlayer("random", RangeOfInfluence.ALL, 1);
    Game game = new TwoPlayerDuel(MultiplayerAttackOption.MULTIPLE, RangeOfInfluence.ALL, MulliganType.GAME_DEFAULT.getMulligan(0), 50);
    int height = 512;
    int weight = 512;
    BufferedImage image = new BufferedImage(weight, height, BufferedImage.TYPE_INT_RGB);
    for (int x = 0; x < weight; x++) {
        for (int y = 0; y < height; y++) {
            // roll dice
            int diceVal = player.rollDice(Outcome.Neutral, null, game, 12);
            int colorMult = Math.floorDiv(255, 12);
            image.setRGB(x, y, new Color(colorMult * diceVal, colorMult * diceVal, colorMult * diceVal).getRGB());
        }
    }
    ImageIO.write(image, "png", new File(dest + "xmage_random_dice.png"));
}
Also used : Player(mage.players.Player) HumanPlayer(mage.player.human.HumanPlayer) Game(mage.game.Game) HumanPlayer(mage.player.human.HumanPlayer) TwoPlayerDuel(mage.game.TwoPlayerDuel) File(java.io.File) BufferedImage(java.awt.image.BufferedImage) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with TwoPlayerDuel

use of mage.game.TwoPlayerDuel in project mage by magefree.

the class PlayGameTest method playOneGame.

@Ignore
@Test
public void playOneGame() throws GameException, FileNotFoundException, IllegalArgumentException {
    Game game = new TwoPlayerDuel(MultiplayerAttackOption.LEFT, RangeOfInfluence.ALL, MulliganType.GAME_DEFAULT.getMulligan(0), 20);
    Player computerA = createPlayer("ComputerA", PlayerType.COMPUTER_MINIMAX_HYBRID);
    // Player playerA = createPlayer("ComputerA", "Computer - mad");
    // Deck deck = Deck.load(Sets.loadDeck("RB Aggro.dck"));
    Deck deck = generateRandomDeck();
    if (deck.getCards().size() < DECK_SIZE) {
        throw new IllegalArgumentException("Couldn't load deck, deck size = " + deck.getCards().size() + ", but must be " + DECK_SIZE);
    }
    game.addPlayer(computerA, deck);
    game.loadCards(deck.getCards(), computerA.getId());
    Player computerB = createPlayer("ComputerB", PlayerType.COMPUTER_MINIMAX_HYBRID);
    // Player playerB = createPlayer("ComputerB", "Computer - mad");
    // Deck deck2 = Deck.load(Sets.loadDeck("RB Aggro.dck"));
    Deck deck2 = generateRandomDeck();
    if (deck2.getCards().size() < DECK_SIZE) {
        throw new IllegalArgumentException("Couldn't load deck, deck size = " + deck2.getCards().size() + ", but must be " + DECK_SIZE);
    }
    game.addPlayer(computerB, deck2);
    game.loadCards(deck2.getCards(), computerB.getId());
    // parseScenario("scenario1.txt");
    // game.cheat(playerA.getId(), commandsA);
    // game.cheat(playerA.getId(), libraryCardsA, handCardsA, battlefieldCardsA, graveyardCardsA);
    // game.cheat(playerB.getId(), commandsB);
    // game.cheat(playerB.getId(), libraryCardsB, handCardsB, battlefieldCardsB, graveyardCardsB);
    // boolean testMode = false;
    boolean testMode = true;
    long t1 = System.nanoTime();
    GameOptions options = new GameOptions();
    options.testMode = true;
    game.setGameOptions(options);
    game.start(computerA.getId());
    long t2 = System.nanoTime();
    logger.info("Winner: " + game.getWinner());
    logger.info("Time: " + (t2 - t1) / 1000000 + " ms");
/*if (!game.getWinner().equals("Player ComputerA is the winner")) {
            throw new RuntimeException("Lost :(");
        }*/
}
Also used : Player(mage.players.Player) ComputerPlayer(mage.player.ai.ComputerPlayer) Game(mage.game.Game) GameOptions(mage.game.GameOptions) TwoPlayerDuel(mage.game.TwoPlayerDuel) Deck(mage.cards.decks.Deck) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with TwoPlayerDuel

use of mage.game.TwoPlayerDuel in project mage by magefree.

the class CardTestPlayerBaseAI method createNewGameAndPlayers.

@Override
protected Game createNewGameAndPlayers() throws GameException, FileNotFoundException {
    Game game = new TwoPlayerDuel(MultiplayerAttackOption.LEFT, RangeOfInfluence.ONE, MulliganType.GAME_DEFAULT.getMulligan(0), 20);
    playerA = createPlayer(game, playerA, "PlayerA");
    playerB = createPlayer(game, playerB, "PlayerB");
    return game;
}
Also used : Game(mage.game.Game) TwoPlayerDuel(mage.game.TwoPlayerDuel)

Example 5 with TwoPlayerDuel

use of mage.game.TwoPlayerDuel in project mage by magefree.

the class CardTestPlayerBase method createNewGameAndPlayers.

@Override
protected Game createNewGameAndPlayers() throws GameException, FileNotFoundException {
    Game game = new TwoPlayerDuel(MultiplayerAttackOption.LEFT, RangeOfInfluence.ONE, MulliganType.GAME_DEFAULT.getMulligan(0), 20);
    playerA = createPlayer(game, playerA, "PlayerA", deckNameA);
    playerB = createPlayer(game, playerB, "PlayerB", deckNameB);
    return game;
}
Also used : Game(mage.game.Game) TwoPlayerDuel(mage.game.TwoPlayerDuel)

Aggregations

Game (mage.game.Game)7 TwoPlayerDuel (mage.game.TwoPlayerDuel)7 Player (mage.players.Player)5 Ignore (org.junit.Ignore)4 Test (org.junit.Test)4 BufferedImage (java.awt.image.BufferedImage)3 File (java.io.File)3 Deck (mage.cards.decks.Deck)3 HumanPlayer (mage.player.human.HumanPlayer)3 GameOptions (mage.game.GameOptions)2 ComputerPlayer (mage.player.ai.ComputerPlayer)2 UUID (java.util.UUID)1 PlanarDieRollResult (mage.constants.PlanarDieRollResult)1