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"));
}
}
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");
}
Aggregations