Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2016
1,173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 12.27 KB | None | 0 0
  1. package game;
  2.  
  3. import org.testng.annotations.Test;
  4.  
  5. import static game.Move.*;
  6. import static org.testng.Assert.assertEquals;
  7.  
  8. @Test
  9. public class BestMoveFinderTest extends AbstractBestMoveFinderTest {
  10.  
  11.     @Test
  12.     void testMoveWithAllowedRange() {
  13.         assertEquals(Utils.moveToWithAllowedRange(0, 0, 0, 0, 5), new Point(0, 0));
  14.         assertEquals(Utils.moveToWithAllowedRange(1, 0, 0, 0, 5), new Point(1, 0));
  15.         assertEquals(Utils.moveToWithAllowedRange(10, 0, 0, 0, 5), new Point(5, 0));
  16.         assertEquals(Utils.moveToWithAllowedRange(1, 1, 2, 2, 1), new Point(2, 2));
  17.     }
  18.  
  19.     @Test
  20.     void testCarryGhostToBase() {
  21.         ally(10, 0).carryingGhost();
  22.         checkMove(
  23.                 move(4, 0)
  24.         );
  25.     }
  26.  
  27.     @Test
  28.     void avoidEnemies() {
  29.         ally(0, 10).carryingGhost().stunCooldown(20);
  30.         enemy(7, 8);
  31.         checkMove(move(0, 10));
  32.     }
  33.  
  34.     @Test
  35.     void dontFearStunnedEnemy() {
  36.         ally(0, 10).carryingGhost().stunCooldown(20);
  37.         enemy(7, 8).stunDuration(10);
  38.         checkMove(move(0, 4));
  39.     }
  40.  
  41.     @Test
  42.     void dontFearIfYouHaveStun() {
  43.         ally(0, 10).carryingGhost();
  44.         enemy(7, 8);
  45.         checkMove(move(0, 4));
  46.     }
  47.  
  48.     @Test
  49.     void runAway() {
  50.         ally(0, 10).carryingGhost().stunCooldown(20);
  51.         enemy(0, 3);
  52.         checkMove(move(25, 25));
  53.     }
  54.  
  55.     @Test
  56.     void testBust() {
  57.         ally(0, 10);
  58.         ghost(0, 14, 3);
  59.         checkMove(bust(0));
  60.     }
  61.  
  62.     @Test
  63.     void testCatch() {
  64.         ally(0, 10);
  65.         ghost(0, 14, 0);
  66.         checkMove(bust(0));
  67.     }
  68.  
  69.     @Test
  70.     void goToGhost() {
  71.         ally(0, 10);
  72.         ghost(0, 50, 3);
  73.         checkMove(move(0, 50));
  74.     }
  75.  
  76.     @Test
  77.     void testCheckpoints() {
  78.         ally(0, 10);
  79.         checkMove(move(25, 25));
  80.     }
  81.  
  82.     @Test
  83.     void avoidFatGhosts() {
  84.         ally(0, 10);
  85.         ghost(0, 20, 40);
  86.         checkMove(move(25, 25));
  87.     }
  88.  
  89.     @Test
  90.     void testMinBustRange() {
  91.         ally(0, 10);
  92.         ghost(0, 11, 1);
  93.         checkMove(move(0, 4));
  94.     }
  95.  
  96.     @Test
  97.     void testBug() {
  98.         ally(0, 5).carryingGhost().stunCooldown(20);
  99.         enemy(0, 50);
  100.         checkMove(move(0, 4));
  101.     }
  102.  
  103.     @Test
  104.     void dontFearEnemyIfYouHaveNoGhost() {
  105.         ally(0, 25).stunCooldown(20);
  106.         enemy(6, 25);
  107.         checkMove(move(25, 25));
  108.     }
  109.  
  110.     @Test
  111.     void testGhostPriority() {
  112.         ally(0, 10);
  113.         ghost(0, 18, 0);
  114.         ghost(3, 10, 20);
  115.         checkMove(move(0, 18));
  116.     }
  117.  
  118.     @Test
  119.     void ghostRunsAway() {
  120.         ally(0, 10);
  121.         ghost(0, 12, 3);
  122.         checkMove(move(0, 10));
  123.     }
  124.  
  125.     @Test
  126.     void ghostDoesntRunAwayIfHeWasBustedOnPreviousMove() {
  127.         ally(0, 10);
  128.         ghost(0, 12, 3, 1);
  129.         checkMove(move(0, 4));
  130.     }
  131.  
  132.     @Test
  133.     void ghostDoesntRunAwayIfSomeAllyStartedToBustHimOnThisMove() {
  134.         ally(0, 10);
  135.         ghost(0, 12, 3);
  136.         alreadyBusted(0);
  137.         checkMove(move(0, 4));
  138.     }
  139.  
  140.     @Test
  141.     void minimizeDistToGhost() {
  142.         ally(24, 25);
  143.         ghost(31, 25, 3);
  144.         alreadyBusted(0);
  145.         checkMove(move(31, 25));
  146.     }
  147.  
  148.     @Test
  149.     void chaseEnemy() {
  150.         ally(50, 45);
  151.         enemy(50, 36).carryingGhost();
  152.         checkMove(move(50, 36));
  153.     }
  154.  
  155.     @Test
  156.     void beCloserToBaseWhenBusting() {
  157.         ally(0, 25);
  158.         ghost(0, 25, 3);
  159.         checkMove(move(0, 4));
  160.     }
  161.  
  162.     @Test
  163.     void extendedChaseTooLate() {
  164.         ally(41, 46);
  165.         enemy(50, 42).carryingGhost();
  166.         checkMove(move(25, 25));
  167.     }
  168.  
  169.     @Test
  170.     void extendedChase2() {
  171.         ally(41, 42);
  172.         enemy(50, 38).carryingGhost();
  173.         checkMove(move(50, 40)); // it looks strange but it's correct
  174.     }
  175.  
  176.     @Test
  177.     void considerStunCooldownWhenChasing() {
  178.         ally(41, 42).stunCooldown(2);
  179.         enemy(50, 38).carryingGhost();
  180.         checkMove(move(50, 40));
  181.     }
  182.  
  183.     @Test
  184.     void considerStunCooldownWhenChasing2() {
  185.         ally(41, 42).stunCooldown(3);
  186.         enemy(50, 38).carryingGhost();
  187.         checkMove(move(2, 2));
  188.     }
  189.  
  190.     @Test
  191.     void chaseBug() {
  192.         ally(0, 0);
  193.         enemy(50, 46).carryingGhost();
  194.         checkMove(move(25, 25)); // just no exception
  195.     }
  196.  
  197.     @Test
  198.     void chaseBug2() {
  199.         ally(25, 30);
  200.         enemy(50, 44).carryingGhost();
  201.         checkMove(move(25, 25));
  202.     }
  203.  
  204.     @Test
  205.     void chaseBug3() {
  206.         ally(43, 44);
  207.         enemy(50, 42).carryingGhost();
  208.         checkMove(move(2, 2));
  209.     }
  210.  
  211.     @Test
  212.     void preferStunningEnemyWithGhost() {
  213.         ally(0, 10);
  214.         enemy(0, 11);
  215.         enemy(0, 12).carryingGhost();
  216.         checkMove(stun(2));
  217.     }
  218.  
  219.     @Test
  220.     void preferStunEnemyWithLessStunCooldown() {
  221.         ally(0, 10);
  222.         enemy(0, 11).stunCooldown(10);
  223.         enemy(0, 12).stunCooldown(9);
  224.         checkMove(stun(2));
  225.     }
  226.  
  227.     @Test
  228.     void ghostCantMoveThroughWall() {
  229.         testGameParameters.MOVE_RANGE = 3;
  230.         ally(2, 25);
  231.         ghost(0, 25, 3);
  232.         checkMove(move(0, 3));
  233.     }
  234.  
  235.     @Test
  236.     void testEscortSimple() {
  237.         ally(0, 10);
  238.         ally(0, 20).carryingGhost();
  239.         enemy(1, 20);
  240.         checkMove(move(0, 20));
  241.     }
  242.  
  243.     @Test
  244.     void dontStayTooCloseToCourier() {
  245.         ally(4, 8);
  246.         ally(0, 10).carryingGhost();
  247.         enemy(0, 4);
  248.         checkMove(move(3, 8));
  249.     }
  250.  
  251.     @Test
  252.     void whenChasingTryAlwaysSeeEnemy() {
  253.         ally(50, 20).stunCooldown(10);
  254.         enemy(50, 10).carryingGhost();
  255.         checkMove(move(50, 10));
  256.     }
  257.  
  258.     @Test
  259.     void preferNotStunEnemyWithStunReady() {
  260.         ally(0, 10);
  261.         enemy(0, 11).stunCooldown(1);
  262.         enemy(0, 12);
  263.         checkMove(stun(1));
  264.     }
  265.  
  266.     @Test
  267.     void chaseEnemyIfSomeAllyCanCatchHim() {
  268.         ally(50, 0);
  269.         ally(50, 31);
  270.         enemy(50, 36).carryingGhost();
  271.         checkMove(move(50, 36));
  272.     }
  273.  
  274.     @Test
  275.     void chaseEnemyIfSomeAllyCanCatchHim2() {
  276.         ally(50, 0);
  277.         ally(43, 32);
  278.         enemy(50, 30).carryingGhost();
  279.         checkMove(move(50, 30));
  280.     }
  281.  
  282.     @Test
  283.     void chaseEnemyIfSomeAllyCanCatchHim3() {
  284.         ally(50, 0);
  285.         ally(43, 42);
  286.         enemy(50, 40).carryingGhost();
  287.         checkMove(move(50, 40));
  288.     }
  289.  
  290.     @Test
  291.     void chaseEnemyIfSomeAllyCanCatchHim4() {
  292.         ally(50, 0);
  293.         ally(42, 42);
  294.         enemy(50, 40).carryingGhost();
  295.         checkMove(move(25, 25));
  296.     }
  297.  
  298.     @Test
  299.     void chaseEnemyIfSomeAllyCanCatchHim5() {
  300.         ally(50, 0);
  301.         ally(43, 42).stunCooldown(1);
  302.         enemy(50, 40).carryingGhost();
  303.         checkMove(move(50, 40));
  304.     }
  305.  
  306.     @Test
  307.     void chaseEnemyIfSomeAllyCanCatchHim6() {
  308.         ally(50, 0);
  309.         ally(43, 42).stunCooldown(2);
  310.         enemy(50, 40).carryingGhost();
  311.         checkMove(move(25, 25));
  312.     }
  313.  
  314.     @Test
  315.     void chaseEnemyIfSomeAllyCanCatchHim7() {
  316.         ally(50, 0);
  317.         ally(50, 25).stunCooldown(2);
  318.         enemy(50, 30).carryingGhost();
  319.         checkMove(move(50, 30));
  320.     }
  321.  
  322.     @Test
  323.     void chaseEnemyIfSomeAllyCanCatchHimPriority() {
  324.         ally(50, 0);
  325.         ally(50, 31);
  326.         enemy(50, 36).carryingGhost();
  327.         ghost(10, 10, 3);
  328.         checkMove(move(50, 36));
  329.     }
  330.  
  331.     @Test
  332.     void improvedEscort() {
  333.         ally(0, 30);
  334.         ally(0, 20).carryingGhost();
  335.         enemy(0, 14);
  336.         checkMove(move(0, 20));
  337.     }
  338.  
  339.     @Test
  340.     void improvedEscort2() {
  341.         ally(0, 30);
  342.         ally(0, 9).carryingGhost();
  343.         enemy(7, 7);
  344.         checkMove(move(0, 9));
  345.     }
  346.  
  347.     @Test
  348.     void improvedEscort3() {
  349.         ally(0, 30);
  350.         ally(0, 9).carryingGhost();
  351.         enemy(8, 7);
  352.         checkMove(move(25, 25));
  353.     }
  354.  
  355.     @Test
  356.     void chaseConsiderStunnedAlly() {
  357.         ally(50, 0);
  358.         ally(50, 30).stunDuration(2);
  359.         enemy(50, 30).carryingGhost();
  360.         checkMove(move(50, 30));
  361.     }
  362.  
  363.     @Test
  364.     void chaseConsiderStunnedAlly2() {
  365.         ally(50, 0);
  366.         ally(50, 30).stunDuration(3);
  367.         enemy(50, 30).carryingGhost();
  368.         checkMove(move(25, 25));
  369.     }
  370.  
  371.     @Test
  372.     void courierIsGonnaUseStun() {
  373.         ally(0, 14);
  374.         ally(0, 10).carryingGhost();
  375.         enemy(5, 10);
  376.         checkMove(move(0, 13));
  377.     }
  378.  
  379.     @Test
  380.     void dontHelpEnemyBust() {
  381.         ally(0, 10).stunCooldown(20);
  382.         enemy(0, 10);
  383.         enemy(0, 10);
  384.         ghost(3, 10, 14);
  385.         checkMove(move(0, 10));
  386.     }
  387.  
  388.     @Test
  389.     void dontHelpEnemyBustEvenWhenWeCantSeeThem() {
  390.         ally(0, 10);
  391.         ghost(3, 10, 14, 3);
  392.         checkMove(move(0, 10));
  393.     }
  394.  
  395.     @Test
  396.     void dontHelpEnemyBustEvenWhenTheyAreStunned() {
  397.         ally(0, 10).stunCooldown(20);
  398.         enemy(0, 10);
  399.         enemy(0, 10).stunDuration(3);
  400.         ghost(3, 10, 14);
  401.         checkMove(move(0, 10));
  402.     }
  403.  
  404.     @Test
  405.     void chasedEnemyIsGonnaUseStun() {
  406.         ally(50, 7).stunCooldown(20);
  407.         ally(50, 10);
  408.         enemy(50, 10).carryingGhost();
  409.         checkMove(move(50, 7));
  410.     }
  411.  
  412.     @Test
  413.     void chasedEnemyIsGonnaUseStun2() {
  414.         ally(50, 6).stunCooldown(20);
  415.         ally(50, 10);
  416.         enemy(50, 10).carryingGhost();
  417.         checkMove(move(50, 7));
  418.     }
  419.  
  420.     @Test
  421.     void chasedEnemyIsGonnaUseStun3() {
  422.         ally(50, 9).stunCooldown(1);
  423.         enemy(50, 10).carryingGhost().stunCooldown(1);
  424.         checkMove(move(50, 9));
  425.     }
  426.  
  427.     @Test
  428.     void chasedEnemyIsGonnaUseStun4() {
  429.         ally(50, 8).stunCooldown(1);
  430.         enemy(50, 10).carryingGhost().stunCooldown(1);
  431.         checkMove(move(50, 9));
  432.     }
  433.  
  434.     @Test
  435.     void preferStunEnemyWhoCanTakeMyGhost() {
  436.         ally(0, 10).carryingGhost();
  437.         enemy(0, 12);
  438.         enemy(0, 13);
  439.         checkMove(stun(2));
  440.     }
  441.  
  442.     @Test
  443.     void tooManyEscorters() {
  444.         ally(0, 30);
  445.         ally(0, 10).carryingGhost();
  446.         ally(0, 10);
  447.         enemy(0, 10).stunCooldown(1);
  448.         checkMove(move(25, 25));
  449.     }
  450.  
  451.     @Test
  452.     void tooManyEscorters2() {
  453.         ally(0, 30);
  454.         ally(0, 10).carryingGhost();
  455.         ally(0, 10).stunDuration(10);
  456.         enemy(0, 10);
  457.         checkMove(move(0, 10));
  458.     }
  459.  
  460.     @Test
  461.     void avoidFightIfSmallStunCooldown() {
  462.         ally(0, 25).stunCooldown(3);
  463.         enemy(8, 25);
  464.         checkMove(move(0, 25));
  465.     }
  466.  
  467.     @Test
  468.     void avoidFightIfSmallStunCooldown2() {
  469.         ally(0, 25).stunCooldown(1);
  470.         enemy(8, 25);
  471.         checkMove(move(25, 25));
  472.     }
  473.  
  474.     @Test
  475.     void goToBattle() {
  476.         iVeSeenItAll();
  477.  
  478.         ally(0, 40);
  479.         ghost(3, 40, 40);
  480.  
  481.         ally(0, 10);
  482.         enemy(0, 10);
  483.         ghost(3, 10, 39);
  484.  
  485.         checkMove(move(3, 10));
  486.     }
  487.  
  488.     @Test
  489.     void escortWhenEnemyAlmostWokeUp() {
  490.         ally(0, 20);
  491.         ally(0, 10).carryingGhost();
  492.         enemy(0, 10).stunDuration(1);
  493.         checkMove(move(0, 10));
  494.     }
  495.  
  496.     @Test
  497.     void escortWhenEnemyAlmostWokeUp2() {
  498.         ally(0, 20);
  499.         ally(0, 10).carryingGhost();
  500.         enemy(0, 14).stunDuration(2);
  501.         checkMove(move(25, 25));
  502.     }
  503.  
  504.     @Test
  505.     void thereIsNoBattleIfGhostIsFatAndNotBusted() {
  506.         iVeSeenItAll();
  507.  
  508.         ally(0, 40);
  509.         ghost(3, 40, 40);
  510.  
  511.         ally(0, 10);
  512.         enemy(0, 10);
  513.         ghost(3, 10, 40);
  514.  
  515.         checkMove(bust(0));
  516.     }
  517.  
  518.     @Test
  519.     void dontUseStunTest() {
  520.         halfGhostsCollected();
  521.         ally(0, 10);
  522.         enemy(0, 10);
  523.         ghost(3, 10, 26);
  524.         checkMove(bust(0));
  525.     }
  526.  
  527.     @Test
  528.     void dontUseStunTest2() {
  529.         testGameParameters.STUN_RANGE = 6;
  530.         halfGhostsCollected();
  531.         ally(50, 10);
  532.         enemy(50, 16);
  533.         ghost(50, 13, 8);
  534.         checkMove(stun(1));
  535.     }
  536.  
  537.     @Test
  538.     void dontUseStunTest3() {
  539.         testGameParameters.STUN_RANGE = 6;
  540.         halfGhostsCollected();
  541.         ally(50, 10);
  542.         enemy(50, 16);
  543.         ghost(50, 13, 9);
  544.         checkMove(stun(1));
  545.     }
  546.  
  547.     @Test
  548.     void dontUseStunTest4() {
  549.         testGameParameters.STUN_RANGE = 6;
  550.         halfGhostsCollected();
  551.         ally(0, 23);
  552.         enemy(0, 17);
  553.         ghost(0, 20, 9);
  554.         checkMove(bust(0));
  555.     }
  556. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement