Commit cc49c03e authored by Fabian Jakob Sauer's avatar Fabian Jakob Sauer

Added IsNothingSpecial method to sort placements from good to bad before choosing best.

parent 0f8922e2
......@@ -86,22 +86,22 @@
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="468" height="466" key="DebuggerActiveHint/0.0.1920.1040@0.0.1920.1040" timestamp="1588936167247" />
<state width="1877" height="227" key="GridCell.Tab.0.bottom" timestamp="1588938545886">
<state width="1877" height="227" key="GridCell.Tab.0.bottom" timestamp="1588941343441">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="227" key="GridCell.Tab.0.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1588938545886" />
<state width="1877" height="227" key="GridCell.Tab.0.center" timestamp="1588938545886">
<state width="1877" height="227" key="GridCell.Tab.0.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1588941343441" />
<state width="1877" height="227" key="GridCell.Tab.0.center" timestamp="1588941343441">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="227" key="GridCell.Tab.0.center/0.0.1920.1040@0.0.1920.1040" timestamp="1588938545886" />
<state width="1877" height="227" key="GridCell.Tab.0.left" timestamp="1588938545886">
<state width="1877" height="227" key="GridCell.Tab.0.center/0.0.1920.1040@0.0.1920.1040" timestamp="1588941343441" />
<state width="1877" height="227" key="GridCell.Tab.0.left" timestamp="1588941343441">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="227" key="GridCell.Tab.0.left/0.0.1920.1040@0.0.1920.1040" timestamp="1588938545886" />
<state width="1877" height="227" key="GridCell.Tab.0.right" timestamp="1588938545886">
<state width="1877" height="227" key="GridCell.Tab.0.left/0.0.1920.1040@0.0.1920.1040" timestamp="1588941343441" />
<state width="1877" height="227" key="GridCell.Tab.0.right" timestamp="1588941343441">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="227" key="GridCell.Tab.0.right/0.0.1920.1040@0.0.1920.1040" timestamp="1588938545886" />
<state width="1877" height="227" key="GridCell.Tab.0.right/0.0.1920.1040@0.0.1920.1040" timestamp="1588941343441" />
<state width="1073" height="173" key="GridCell.Tab.1.bottom" timestamp="1588936180713">
<screen x="0" y="0" width="1920" height="1040" />
</state>
......
......@@ -145,6 +145,47 @@ public class BasicPlayer implements Player {
return null;
}
private Placement IsNothingSpecial(GameState currentGameState, List<Placement> validPlacements)
{
Placement bestPlacementASC = null;
Placement bestPlacementDES = null;
for (Placement placement : validPlacements)
{
if (placement.getPosition() == CardPosition.OWN_ASCENDING_DISCARD_PILE)
{
if (bestPlacementASC == null)
{
bestPlacementASC = placement;
}
if (bestPlacementASC.getCard().getNumber() > placement.getCard().getNumber())
{
bestPlacementASC = placement;
}
}
else if (placement.getPosition() == CardPosition.OWN_DESCENDING_DISCARD_PILE)
{
if (bestPlacementDES == null)
{
bestPlacementDES = placement;
}
if (bestPlacementDES.getCard().getNumber() < placement.getCard().getNumber())
{
bestPlacementDES = placement;
}
}
}
int rand = random.nextInt(2);
if (rand == 0 && bestPlacementASC != null)
{
return bestPlacementASC;
}
else if (rand == 1 && bestPlacementDES != null)
{
return bestPlacementDES;
}
return null;
}
@Override
public Move computeMove(GameState newGameState) {
if (latestGameState == null)
......@@ -186,6 +227,8 @@ public class BasicPlayer implements Player {
nextPlacement = IsBackwardsTrick(latestGameState, validPlacements); // perform backwards trick if available
if (nextPlacement == null)
nextPlacement = IsHelpEnemyWithoutConsequences(latestGameState, validPlacements); // perform help enemy if available
if (nextPlacement == null)
nextPlacement = IsNothingSpecial(latestGameState, validPlacements); // perform card sorting to choose best possible card
if (nextPlacement == null)
nextPlacement = validPlacements.get(random.nextInt(validPlacements.size())); // pick random move if no special rule applied
......
......@@ -4,7 +4,7 @@ import de.upb.isml.thegamef2f.engine.CardPosition;
import de.upb.isml.thegamef2f.engine.Placement;
import de.upb.isml.thegamef2f.engine.board.Card;
public class ExtendedPlacement extends Placement {
public class ExtendedPlacement extends Placement{
private Card prevTopCard;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment