mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
AI: fixed MCTS (Monte Carlo) errors in some simulations (#10154);
This commit is contained in:
parent
c8b5c1fa35
commit
72cf60085c
2 changed files with 76 additions and 3 deletions
|
|
@ -94,8 +94,10 @@ public class ComputerPlayerMCTS extends ComputerPlayer {
|
|||
root = new MCTSNode(playerId, sim);
|
||||
}
|
||||
applyMCTS(game, action);
|
||||
root = root.bestChild();
|
||||
root.emancipate();
|
||||
if (root != null && root.bestChild() != null) {
|
||||
root = root.bestChild();
|
||||
root.emancipate();
|
||||
}
|
||||
}
|
||||
|
||||
protected void getNextAction(Game game, NextAction nextAction) {
|
||||
|
|
|
|||
|
|
@ -2,15 +2,86 @@ package org.mage.test.cards.requirement;
|
|||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBaseWithMonteCarloAIHelps;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
@Ignore // TODO: research and fix attack/block simulations
|
||||
public class BecomeBlockTriggersMonteCarloAITest extends CardTestPlayerBaseWithMonteCarloAIHelps {
|
||||
|
||||
// continue from BecomeBlockTriggersTest
|
||||
@Test
|
||||
public void test_AI_Block_NoBlockers() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears", 1); // 2/2
|
||||
|
||||
attack(1, playerA, "Grizzly Bears");
|
||||
|
||||
aiPlayStep(1, PhaseStep.DECLARE_BLOCKERS, playerB);
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
setStrictChooseMode(true);
|
||||
execute();
|
||||
|
||||
assertLife(playerB, 20 - 2);
|
||||
assertPermanentCount(playerA, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_AI_Block_KillAttackerAndAlive() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears", 1); // 2/2
|
||||
//
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Apex Devastator", 1); // 10/10
|
||||
|
||||
attack(1, playerA, "Grizzly Bears");
|
||||
aiPlayStep(1, PhaseStep.DECLARE_BLOCKERS, playerB);
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
setStrictChooseMode(true);
|
||||
execute();
|
||||
|
||||
assertLife(playerB, 20);
|
||||
assertPermanentCount(playerA, 0);
|
||||
assertPermanentCount(playerB, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_AI_Block_KillAttackerAndDie() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Atarka Efreet", 1); // 5/1
|
||||
//
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Aarakocra Sneak", 1); // 1/4
|
||||
|
||||
attack(1, playerA, "Atarka Efreet");
|
||||
aiPlayStep(1, PhaseStep.DECLARE_BLOCKERS, playerB);
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
setStrictChooseMode(true);
|
||||
execute();
|
||||
|
||||
assertLife(playerB, 20);
|
||||
assertPermanentCount(playerA, 1);
|
||||
assertPermanentCount(playerB, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_AI_Block_BlockAttackerAndDie() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Apex Devastator", 1);// 10/10
|
||||
//
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Grizzly Bears", 1); // 2/2
|
||||
|
||||
attack(1, playerA, "Apex Devastator");
|
||||
aiPlayStep(1, PhaseStep.DECLARE_BLOCKERS, playerB);
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
setStrictChooseMode(true);
|
||||
execute();
|
||||
|
||||
assertLife(playerB, 20);
|
||||
assertPermanentCount(playerA, 1);
|
||||
assertPermanentCount(playerB, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_AI_CantBlockAgain() {
|
||||
// Monte Carlo bug: Triggered ability triggered twice (should be once), see https://github.com/magefree/mage/issues/6367
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue