public void Indexing() { var dds = new DoubleDummySolution(); dds.Add(new Contract(3, Denomination.Hearts, Risk.None, Seat.East)); dds.Add(new Contract(4, Denomination.Hearts, Risk.None, Seat.West)); Assert.AreEqual("3H by East", dds[Seat.East, Denomination.Hearts].ToString()); Assert.AreEqual("4H by West", dds[Seat.West, Denomination.Hearts].ToString()); Assert.AreEqual(0, dds[Seat.North, Denomination.Hearts].Level); Assert.AreEqual(Contract.PassedIn, dds[Seat.South, Denomination.NoTrumps]); }
/// <summary> /// Determines all the contracts that can be made for the specified <see cref="Board"/>. /// </summary> /// <param name="board"> /// The <see cref="Board"/> to analyse. /// </param> /// <returns> /// A <see cref="DoubleDummySolution"/> that contains all the contracts that can /// be made. /// </returns> public DoubleDummySolution MakeableContracts(Board board) { if (log.IsDebugEnabled) { log.Debug("Starting MakeableContracts"); } var table = new Solver.tableDealPBN(board.Hands.ToPbn(board.Dealer)); var results = new Solver.tableResults { solution = new int[20] }; var status = Solver.CalcDDtablePBN(table, ref results); if (status < 0) { throw new Exception(string.Format("Bo Haglund's DDS returned error code of {0}.", status)); } var dds = new DoubleDummySolution(); var next = 0; foreach (var strain in strainOrder) { foreach (var declaror in seatOrder) { var tricks = results.solution[next++]; if (tricks > 6) { var contract = new Contract(tricks - 6, strain, Risk.None, declaror); dds.Add(contract); if (log.IsDebugEnabled) { log.Debug(contract.ToString()); } } } } if (log.IsDebugEnabled) { log.Debug("Finished MakeableContracts"); } return(dds); }