Commit 3415a61f authored by Fabian Jakob Sauer's avatar Fabian Jakob Sauer

Removed Backup stack value class.

parent 267bf95a
package util.Extensions;
import de.upb.isml.thegamef2f.engine.GameState;
import de.upb.isml.thegamef2f.engine.board.Card;
import java.util.List;
public class BackupStackValue {
public float value;
private boolean isMine;
private boolean isAscending;
public int ownTheo;
public int ownPrac;
public int oppTheo;
public int oppPrac;
public BackupStackValue(boolean isMine, boolean isAscending) {
this.isMine = isMine;
this.isAscending = isAscending;
}
public float GetValue() {
return value;
}
private int GetNotSkippedCards(boolean isSmallerThanTopCard, List<Card> playedCards, Card topCard)
{
int notSkippedCards = 0;
for (Card card : playedCards) {
if (isSmallerThanTopCard)
{
if (card.getNumber() <= topCard.getNumber()) {
notSkippedCards++;
}
}
else
{
if (card.getNumber() >= topCard.getNumber()) {
notSkippedCards++;
}
}
}
return notSkippedCards;
}
public void calcValues(GameState potentialGameState, CardTracker cardTracker, float weightOwn, float weightOpp) {
Card topCard;
int maybeSkippedCards;
if (isMine)
{
ownTheo = 58 - cardTracker.cardsPlacedByMe.size();
oppTheo = 58 - cardTracker.cardsPlacedByOp.size();
if (isAscending)
{
topCard = potentialGameState.getTopCardOnOwnAscendingDiscardPile();
if (topCard.getNumber() == 1)
{
ownPrac = ownTheo;
oppPrac = oppTheo;
}
else
{
maybeSkippedCards = topCard.getNumber() - 1;
ownPrac = ownTheo - (maybeSkippedCards - GetNotSkippedCards(true, cardTracker.cardsPlacedByMe, topCard));
//maybeSkippedCards = 60 - topCard.getNumber() - 1;
oppPrac = GetNotSkippedCards(false, cardTracker.cardsPlacedByOp, topCard); // to be continued
}
}
else // isDescending
{
topCard = potentialGameState.getTopCardOnOwnDescendingDiscardPile();
if (topCard.getNumber() == 60)
{
ownPrac = ownTheo;
oppPrac = oppTheo;
}
else
{
maybeSkippedCards = 60 - topCard.getNumber();
ownPrac = ownTheo - (maybeSkippedCards + GetNotSkippedCards(false, cardTracker.cardsPlacedByMe, topCard));
maybeSkippedCards = 58 - (60 - topCard.getNumber());
oppPrac = oppTheo - (maybeSkippedCards + GetNotSkippedCards(true, cardTracker.cardsPlacedByOp, topCard));
}
}
}
else // isOpponent
{
ownTheo = 58 - cardTracker.cardsPlacedByOp.size();
oppTheo = 58 - cardTracker.cardsPlacedByMe.size();
if (isAscending)
{
topCard = potentialGameState.getTopCardOnOpponentsAscendingDiscardPile();
if (topCard.getNumber() == 1)
{
ownPrac = ownTheo;
oppPrac = oppTheo;
}
else
{
maybeSkippedCards = topCard.getNumber() - 1;
ownPrac = ownTheo - (maybeSkippedCards + GetNotSkippedCards(true, cardTracker.cardsPlacedByOp, topCard));
maybeSkippedCards = 60 - topCard.getNumber();
oppPrac = oppTheo - (maybeSkippedCards + GetNotSkippedCards(false, cardTracker.cardsPlacedByMe, topCard));
}
}
else // isDescending
{
topCard = potentialGameState.getTopCardOnOpponentsDescendingDiscardPile();
if (topCard.getNumber() == 60)
{
ownPrac = ownTheo;
oppPrac = oppTheo;
}
else
{
ownPrac = ownTheo - (60 - topCard.getNumber()) + GetNotSkippedCards(false, cardTracker.cardsPlacedByOp, topCard);
oppPrac = oppTheo - (topCard.getNumber() - 60) + GetNotSkippedCards(true, cardTracker.cardsPlacedByMe, topCard);
}
}
}
value = weightOwn * (ownTheo - ownPrac) + weightOpp * (oppPrac - oppTheo);
//PrintStackValueCalc(potentialGameState, weightOwn, weightOpp);
}
private void PrintStackValueCalc(GameState potentialGameState, float weightOwn, float weightOpp)
{
System.out.println("\nHand cards: " + potentialGameState.getHandCards());
System.out.println("IsMine: " + isMine + " | IsAscending: " + isAscending);
System.out.println("Stack value calc: " + weightOwn + " * (" + ownTheo + "-" + ownPrac + ") + " + weightOpp + " * ( " + oppPrac + " - " + oppTheo + " ) " + " = " + value);
}
}
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