@@ -59,7 +59,7 @@ void Update ()
if (Physics.Raycast(ray, out hit, 100f))
{
Card foundCard = (Card)hit.collider.gameObject.GetComponent<Card>();

BoardPos destination = getPositionForCard(foundCard);
// Here we'll check if we have a card already.
// If we do have a card we'll check where we're putting it.
if (selectedCard != null)
@@ -69,21 +69,30 @@ void Update ()
BoardPos source = getPositionForCard(selectedCard);
if (foundCard != null)
{
BoardPos destination = getPositionForCard(foundCard);
board.makeMove(source.stack, source.pos, destination.stack, destination.pos);
// Check if the current card is a King, Queen.


board.makeMove(source.stack, source.pos, destination.stack, destination.pos + 1, false);
board.makeMove(8, 0, 6, 0); // -1 put it at the bottom.

selectedCard = null;
return;

}

if (hit.collider.gameObject != null)
{
if (selectedCard.caravanValue() == Card.CV_KING || selectedCard.caravanValue() == Card.CV_QUEEN)
{
selectedCard = null;
return;
}

for (int i = 0; i != 6; i++)
{
if (board.boardPositions[i] == hit.collider.gameObject.transform.parent.gameObject)
{
board.makeMove(source.stack, source.pos, i, -1);
board.makeMove(source.stack, source.pos, i, -1, false);
board.makeMove(8, 0, 6, -1);

selectedCard = null;
return;
@@ -94,6 +103,10 @@ void Update ()

if (foundCard != null && selectedCard == null)
{
if(destination.stack < 6 || destination.stack == 7 || destination.stack == 9)
{
return;
}
selectedCard = foundCard;
}

@@ -28,11 +28,18 @@ public static class CaravanUtil
return result;
}

private static bool winningCaravan(List<int> stack)
public static bool winningCaravan(List<int> stack)
{
int val = caravanValue(stack);
return val > 20 && val < 27;
}

public static bool winningCaravan(List<int> stack, List<int> opposingStack)
{
int val1 = caravanValue(stack);
int val2 = caravanValue(opposingStack);
return val1 > 20 && val1 < 27 && val1 > val2;
}

public static int cardValue(List<int> stack, int idx)
{
@@ -64,6 +71,7 @@ public static int caravanValue(List<int> stack)
}
return result;
}


private static float heuristicForStack(List<int> stack, List<int> opposingStack)
{
@@ -73,7 +81,7 @@ private static float heuristicForStack(List<int> stack, List<int> opposingStack)
//If stack is between 20 - 27 and bigger than the opposing stack rturn large value for heuristic
if (stack_value >= 20 && stack_value <= 27 && stack_value > opposing_stack_value)
{
return 5000.0f;
return 500.0f;
}
//If stack is below 20, scale heuristic from 0 - 20
if (stack_value <= 21)
@@ -85,6 +93,12 @@ private static float heuristicForStack(List<int> stack, List<int> opposingStack)
{
return -20f;
}

if(opposing_stack_value < 20 && opposing_stack_value > 27)
{
return 30.0f;
}

return 0;
}

@@ -35,7 +35,7 @@ public static int getCaravanValue(int cardID)
}
if (cardID > 40 && cardID < 45)
{
return 11; // Just because.
return 11;
}
if (cardID > 44 && cardID < 49)
{

Large diffs are not rendered by default.