public CardGrid(int numberOfCardsPerSide, List<Card> cards) { StateScorer = new MathematicalHandScorer(); StatePermuter = new CardSwapPermuter(); LengthOfSide = numberOfCardsPerSide; if ((cards == null) || (cards.Count < numberOfCardsPerSide * numberOfCardsPerSide)) { SetupCards(numberOfCardsPerSide); } else { Cards = cards; } }
static SimulatedAnnealingDriver SetupAnnealingDriver(string fileNameOfCardPopulation) { SimulatedAnnealingDriver result; ISimulatedAnnealingSubject subject; IStatePermuter permuter = new CardSwapPermuter(); List<Card> cards = new Deck(fileNameOfCardPopulation).Cards; subject = new CardGrid(5, cards, permuter, new MathematicalHandScorer()); SimulatedAnnealingMathematicalDriver math = MathDriver; result = new SimulatedAnnealingDriver { Subject = subject, MathDriver = math as ISimulatedAnnealingMathematicalDriver, Randomizer = math as ISimulatedAnnealingRandomzier }; //sad.NewSolution += new PropertyChangedEventHandler(ThereIsANewSolution); return result; }