Search in sources :

Example 6 with TwoPlayerDuel

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

the class RandomTest method test_GenerateRandomLibraryShufflePng.

@Test
@Ignore
public void test_GenerateRandomLibraryShufflePng() 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);
    Deck deck = DeckTestUtils.buildRandomDeck("WGUBR", false, "GRN");
    player.getLibrary().addAll(deck.getCards(), game);
    // multiple cards analyze
    for (int i = 0; i < player.getLibrary().size(); i++) {
        UUID cardId = player.getLibrary().getCardList().get(i);
        // int halfIndex = Math.floorDiv(player.getLibrary().size(), 2);
        int colorMult = Math.floorDiv(255, player.getLibrary().size());
        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++) {
                // shuffle, search card position and draw
                player.getLibrary().shuffle();
                int cardPos = player.getLibrary().getCardPosition(cardId);
                // image.setRGB(x, y, cardPos < halfIndex ? Color.white.getRGB() : Color.black.getRGB());
                image.setRGB(x, y, new Color(colorMult * cardPos, colorMult * cardPos, colorMult * cardPos).getRGB());
            }
        }
        ImageIO.write(image, "png", new File(dest + "xmage_random_shuffle_" + i + ".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) Deck(mage.cards.decks.Deck) UUID(java.util.UUID) File(java.io.File) BufferedImage(java.awt.image.BufferedImage) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with TwoPlayerDuel

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

the class TestPlayRandomGame method playOneGame.

private void playOneGame() throws GameException, FileNotFoundException, IllegalArgumentException {
    Game game = new TwoPlayerDuel(MultiplayerAttackOption.LEFT, RangeOfInfluence.ALL, MulliganType.GAME_DEFAULT.getMulligan(0), 20);
    Player computerA = createRandomPlayer("ComputerA");
    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 = createRandomPlayer("ComputerB");
    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());
    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");
}
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)

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