public HiddenCards(GolfCardGameGameContainer gameContainer) : base(gameContainer.Command, gameContainer.Aggregator) { _gameContainer = gameContainer; Rows = 1; Columns = 2; HasFrame = true; Style = EnumStyleList.SingleCard; HasText = true; //no visible. hopefully works properly (?) //Visible = false; LoadBoard(); IsEnabled = false; //try this too (?) if (PileList !.Count != 2) { throw new BasicBlankException("Must have 2 piles"); } PileClickedAsync += HiddenCards_PileClickedAsync; int x = 0; PileList.ForEach(thisPile => { x++; thisPile.Text = $"Card {x}"; }); }
private void FindUncoveringMoves(int maxExtraSuits) { // Find all uncovering moves. UncoveringMoves.Clear(); for (int from = 0; from < NumberOfPiles; from++) { Pile fromPile = FindTableau[from]; int fromRow = fromPile.Count - RunFinder.GetRunUpAnySuit(from); if (fromRow == 0) { continue; } int fromSuits = RunFinder.CountSuits(from, fromRow); Card fromCard = fromPile[fromRow]; PileList faceList = FaceLists[(int)fromCard.Face + 1]; for (int i = 0; i < faceList.Count; i++) { HoldingStack.Clear(); int to = faceList[i]; if (fromSuits - 1 > maxExtraSuits) { int holdingSuits = FindHolding(FindTableau, HoldingStack, false, fromPile, from, fromRow, fromPile.Count, to, maxExtraSuits); if (fromSuits - 1 > maxExtraSuits + holdingSuits) { break; } } Pile toPile = FindTableau[to]; Card toCard = toPile[toPile.Count - 1]; int order = GetOrder(toCard, fromCard); UncoveringMoves.Add(new Move(from, fromRow, to, order, AddHolding(HoldingStack.Set))); } } }
public Game() { Seed = -1; TraceStartFinish = false; TraceDeals = false; TraceMoves = false; ComplexMoves = false; Diagnostics = false; Instance = -1; Shuffled = new Pile(); Tableau = new Tableau(); Candidates = new MoveList(); SupplementaryList = new MoveList(); RunFinder = new RunFinder(); FaceLists = new PileList[(int)Face.King + 2]; for (int i = 0; i < FaceLists.Length; i++) { FaceLists[i] = new PileList(); } Coefficients = null; TableauInputOutput = new TableauInputOutput(Tableau); MoveProcessor = new MoveProcessor(this); Variation = Variation.Spider4; AlgorithmType = AlgorithmType.Study; }
public Game() { Seed = -1; TraceStartFinish = false; TraceDeals = false; TraceMoves = false; ComplexMoves = false; Diagnostics = false; Instance = -1; Shuffled = new Pile(); Tableau = new Tableau(); Candidates = new MoveList(); SupplementaryList = new MoveList(); RunFinder = new RunFinder(); FaceLists = new PileList[(int)Face.King + 2]; for (int i = 0; i < FaceLists.Length; i++) { FaceLists[i] = new PileList(); } Coefficients = null; TableauInputOutput = new TableauInputOutput(Tableau); MoveProcessor = new MoveProcessor(this); Variation = Variation.Spider4; AlgorithmType = AlgorithmType.Study; }
public DeckRegularDict <RegularSimpleCard> GetSelectedCards() { var output = PileList.Where(items => items.IsSelected == true).Select(Items => Items.ThisObject).ToRegularDeckDict(); if (output.Count > 2) { throw new BasicBlankException("Cannot have more than 2 selected. Find out what happened"); } return(output); }
public CompositeSinglePileMoveFinder(Game game) : base(game) { UncoveringMoves = new MoveList(); OneRunPiles = new PileList(); Used = new PileList(); Roots = new PileList(); WorkingTableau = new Tableau(); HoldingStack = new HoldingStack(); SupplementaryMoves = new MoveList(); MoveStack = new FastList <Move>(); }
public CompositeSinglePileMoveFinder(Game game) : base(game) { UncoveringMoves = new MoveList(); OneRunPiles = new PileList(); Used = new PileList(); Roots = new PileList(); WorkingTableau = new Tableau(); HoldingStack = new HoldingStack(); SupplementaryMoves = new MoveList(); MoveStack = new FastList<Move>(); }
public int PointsPlayed(int player, DeckRegularDict <DutchBlitzCardInformation> otherList) { int output = 0; PileList.ForEach(thisPile => { var tempList = thisPile.ObjectList.ToRegularDeckDict(); output += tempList.Count(items => items.Player == player); }); output += otherList.Count(items => items.Player == player); return(output); }
public DutchBlitzCardInformation CardToUseForPublic(MoveInfo thisMove) { _moves += 3; DutchBlitzCardInformation thisCard; if (thisMove.FromStock) { thisCard = _gameContainer.CurrentComputer !.StockList.First(); _gameContainer.CurrentComputer.StockList.RemoveSpecificItem(thisCard); UpdateComputerCount(); return(thisCard); } if (thisMove.FromHand) { thisCard = _gameContainer.CurrentComputer !.PileList.Last(); _gameContainer.CurrentComputer.PileList.RemoveSpecificItem(thisCard); return(thisCard); } thisCard = _gameContainer.CurrentComputer !.Discard[thisMove.DiscardPile]; _gameContainer.CurrentComputer.Discard.RemoveSpecificItem(thisCard); return(thisCard); }
public void Find() { Candidates.Clear(); SupplementaryList.Clear(); int numberOfSpaces = FindTableau.NumberOfSpaces; int maxExtraSuits = ExtraSuits(numberOfSpaces); int maxExtraSuitsToSpace = ExtraSuits(numberOfSpaces - 1); for (int from = 0; from < NumberOfPiles; from++) { HoldingStack holdingStack = HoldingStacks[from]; Pile fromPile = FindTableau[from]; holdingStack.Clear(); holdingStack.StartingRow = fromPile.Count; int extraSuits = 0; for (int fromRow = fromPile.Count - 1; fromRow >= 0; fromRow--) { Card fromCard = fromPile[fromRow]; if (fromCard.IsEmpty) { break; } if (fromRow < fromPile.Count - 1) { Card previousCard = fromPile[fromRow + 1]; if (!previousCard.IsSourceFor(fromCard)) { break; } if (fromCard.Suit != previousCard.Suit) { // This is a cross-suit run. extraSuits++; if (extraSuits > maxExtraSuits + holdingStack.Suits) { break; } } } // Add moves to other piles. if (fromCard.Face < Face.King) { PileList piles = FaceLists[(int)fromCard.Face + 1]; for (int i = 0; i < piles.Count; i++) { for (int count = 0; count <= holdingStack.Count; count++) { HoldingSet holdingSet = new HoldingSet(holdingStack, count); if (extraSuits > maxExtraSuits + holdingSet.Suits) { continue; } int to = piles[i]; if (from == to || holdingSet.Contains(from)) { continue; } // We've found a legal move. Pile toPile = FindTableau[to]; Algorithm.ProcessCandidate(new Move(from, fromRow, to, toPile.Count, AddHolding(holdingSet))); // Update the holding pile move. int holdingSuits = extraSuits; if (fromRow > 0 && (!fromPile[fromRow - 1].IsTargetFor(fromCard) || fromCard.Suit != fromPile[fromRow - 1].Suit)) { holdingSuits++; } if (holdingSuits > holdingStack.Suits) { int length = holdingStack.FromRow - fromRow; holdingStack.Push(new HoldingInfo(from, fromRow, to, holdingSuits, length)); } break; } } } // Add moves to an space. for (int i = 0; i < FindTableau.NumberOfSpaces; i++) { int to = FindTableau.Spaces[i]; if (fromRow == 0) { // No point in moving from a full pile // from one open position to another unless // there are more cards to turn over. if (FindTableau.GetDownCount(from) == 0) { continue; } } else { // No point in moving anything less than // as much as possible to an space. Card nextCard = fromPile[fromRow - 1]; if (fromCard.Suit == nextCard.Suit) { if (nextCard.IsTargetFor(fromCard)) { continue; } } } for (int count = 0; count <= holdingStack.Count; count++) { HoldingSet holdingSet = new HoldingSet(holdingStack, count); if (holdingSet.FromRow == fromRow) { // No cards left to move. continue; } if (extraSuits > maxExtraSuitsToSpace + holdingSet.Suits) { // Not enough spaces. continue; } // We've found a legal move. Pile toPile = FindTableau[to]; Algorithm.ProcessCandidate(new Move(from, fromRow, to, toPile.Count, AddHolding(holdingSet))); break; } // Only need to check the first space // since all spaces are the same // except for undealt cards. break; } } } }
public DeckRegularDict <RegularSimpleCard> CardsLeft() => PileList.Where(items => items.Visible == true && items.IsSelected == false).Select(Items => Items.ThisObject).ToRegularDeckDict();
private BasicPileInfo <RegularSimpleCard> FindPile(int deck) { return(PileList.Single(items => items.ThisObject.Deck == deck)); }