mirror of
https://github.com/correl/mage.git
synced 2025-03-27 17:00:20 -09:00
Draft bot - only draft picks, will be auto eliminated and doesn't participate in tournament
This commit is contained in:
parent
7bcd512351
commit
354b07d50e
16 changed files with 176 additions and 17 deletions
Mage.Server.Plugins
Mage.Server
config
plugins
mage-player-ai-draft-bot.jarmage-player-ai-ma.jarmage-player-ai.jarmage-player-aimcts.jarmage-player-aiminimax.jarmage-player-human.jar
src/main/java/mage/server/tournament
Mage/src/mage
56
Mage.Server.Plugins/Mage.Player.AI.DraftBot/pom.xml
Normal file
56
Mage.Server.Plugins/Mage.Player.AI.DraftBot/pom.xml
Normal file
|
@ -0,0 +1,56 @@
|
|||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-server-plugins</artifactId>
|
||||
<version>0.8.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-player-ai-draft-bot</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Mage Player AI.DraftBot</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>mage</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>mage-player-ai</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.0.2</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
<finalName>mage-player-ai-draft-bot</finalName>
|
||||
</build>
|
||||
|
||||
<properties/>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.player.ai;
|
||||
|
||||
import mage.Constants.RangeOfInfluence;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author nantuko
|
||||
*/
|
||||
public class ComputerDraftPlayer extends ComputerPlayer<ComputerDraftPlayer> implements Player {
|
||||
|
||||
public ComputerDraftPlayer(String name, RangeOfInfluence range) {
|
||||
super(name, range);
|
||||
}
|
||||
|
||||
public ComputerDraftPlayer(String name, RangeOfInfluence range, int skill) {
|
||||
super(name, range);
|
||||
}
|
||||
|
||||
public ComputerDraftPlayer(final ComputerDraftPlayer player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComputerDraftPlayer copy() {
|
||||
return new ComputerDraftPlayer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean autoLoseGame() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean priority(Game game) {
|
||||
game.concede(playerId);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@
|
|||
<module>Mage.Player.AIMinimax</module>
|
||||
<module>Mage.Player.AI.MA</module>
|
||||
<module>Mage.Player.AIMCTS</module>
|
||||
<module>Mage.Player.AI.DraftBot</module>
|
||||
<module>Mage.Player.Human</module>
|
||||
<module>Mage.Tournament.BoosterDraft</module>
|
||||
<module>Mage.Tournament.Sealed</module>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<playerType name="Computer - minimax" jar="mage-player-aiminimax.jar" className="mage.player.ai.ComputerPlayer3"/>
|
||||
<playerType name="Computer - mad" jar="mage-player-ai-ma.jar" className="mage.player.ai.ComputerPlayer6"/>
|
||||
<playerType name="Computer - monte carlo" jar="mage-player-aimcts.jar" className="mage.player.ai.ComputerPlayerMCTS"/>
|
||||
<playerType name="Computer - draftbot" jar="mage-player-ai-draft-bot.jar" className="mage.player.ai.ComputerDraftPlayer"/>
|
||||
</playerTypes>
|
||||
<gameTypes>
|
||||
<gameType name="Two Player Duel" jar="mage-game-twoplayerduel.jar" className="mage.game.TwoPlayerMatch" typeName="mage.game.TwoPlayerDuelType"/>
|
||||
|
|
BIN
Mage.Server/plugins/mage-player-ai-draft-bot.jar
Normal file
BIN
Mage.Server/plugins/mage-player-ai-draft-bot.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -28,9 +28,6 @@
|
|||
|
||||
package mage.server.tournament;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import mage.MageException;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.game.GameException;
|
||||
|
@ -52,6 +49,10 @@ import mage.view.ChatMessage.MessageColor;
|
|||
import mage.view.TournamentView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
|
@ -28,27 +28,18 @@
|
|||
|
||||
package mage.game.tournament;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.ExpansionSet;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.game.events.Listener;
|
||||
import mage.game.events.PlayerQueryEvent;
|
||||
import mage.game.events.PlayerQueryEventSource;
|
||||
import mage.game.events.TableEvent;
|
||||
import mage.game.events.*;
|
||||
import mage.game.events.TableEvent.EventType;
|
||||
import mage.game.events.TableEventSource;
|
||||
import mage.game.match.Match;
|
||||
import mage.players.Player;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -177,6 +168,7 @@ public abstract class TournamentImpl implements Tournament {
|
|||
protected void updateResults() {
|
||||
for (TournamentPlayer player: players.values()) {
|
||||
player.setResults("");
|
||||
player.setPoints(0);
|
||||
}
|
||||
for (Round round: rounds) {
|
||||
for (TournamentPairing pair: round.getPairs()) {
|
||||
|
@ -193,6 +185,18 @@ public abstract class TournamentImpl implements Tournament {
|
|||
sb2.append("-").append(match.getPlayer(player1Id).getWins()).append(") ");
|
||||
players.get(player1Id).setResults(sb1.toString());
|
||||
players.get(player2Id).setResults(sb2.toString());
|
||||
if (match.getPlayer(player1Id).getWins() > match.getPlayer(player2Id).getWins()) {
|
||||
int points = players.get(player1Id).getPoints();
|
||||
players.get(player1Id).setPoints(points + 3);
|
||||
} else if (match.getPlayer(player1Id).getWins() < match.getPlayer(player2Id).getWins()) {
|
||||
int points = players.get(player2Id).getPoints();
|
||||
players.get(player2Id).setPoints(points + 3);
|
||||
} else {
|
||||
int points = players.get(player1Id).getPoints();
|
||||
players.get(player1Id).setPoints(points + 1);
|
||||
points = players.get(player2Id).getPoints();
|
||||
players.get(player2Id).setPoints(points + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,9 +28,10 @@
|
|||
|
||||
package mage.game.tournament;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.game.match.Match;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -75,4 +76,14 @@ public class TournamentPairing {
|
|||
player2.setEliminated();
|
||||
}
|
||||
}
|
||||
|
||||
public void eliminateComputer() {
|
||||
if (!player1.getPlayer().isHuman()) {
|
||||
player1.setEliminated();
|
||||
return;
|
||||
}
|
||||
if (!player2.getPlayer().isHuman()) {
|
||||
player2.setEliminated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
|
||||
package mage.game.tournament;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -40,6 +43,14 @@ public abstract class TournamentSingleElimination extends TournamentImpl {
|
|||
|
||||
@Override
|
||||
protected void runTournament() {
|
||||
|
||||
for (Map.Entry<UUID, TournamentPlayer> entry: players.entrySet()) {
|
||||
if (entry.getValue().getPlayer().autoLoseGame()) {
|
||||
entry.getValue().setEliminated();
|
||||
entry.getValue().setResults("Auto Eliminated");
|
||||
}
|
||||
}
|
||||
|
||||
while (this.getActivePlayers().size() > 1) {
|
||||
Round round = createRoundRandom();
|
||||
playRound(round);
|
||||
|
|
|
@ -110,6 +110,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
public UserData getUserData();
|
||||
public void setUserData(UserData userData);
|
||||
public boolean canLose(Game game);
|
||||
public boolean autoLoseGame();
|
||||
|
||||
/**
|
||||
* Returns a set of players which turns under you control.
|
||||
|
|
|
@ -1440,4 +1440,9 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
|||
public void setCanPaySacrificeCost(boolean canPaySacrificeCost) {
|
||||
this.canPaySacrificeCost = canPaySacrificeCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean autoLoseGame() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue