protected virtual void ExtractCases() { Cases = new List <ProofCase>(); var caseNumber = 0; var colorableCase = new ProofCase(Mind, 0, Mind.ColorableBoards); Cases.Add(colorableCase); caseNumber++; var remainingBoards = Mind.PlayableBoards.ToList(); var wonBoards = Mind.ColorableBoards.ToList(); while (remainingBoards.Count > 0) { var proofCase = new ProofCase(Mind, caseNumber); Cases.Add(proofCase); var addedBoards = new List <SuperSlimBoard>(); foreach (var board in remainingBoards) { var treeInfo = Mind.GetWinTreeInfo(board); if (treeInfo.All(bc => wonBoards.Contains(new SuperSlimBoard(board._trace, bc.Alpha, bc.Beta, bc.Response, board._stackCount)))) { addedBoards.Add(board); } } foreach (var board in addedBoards) { proofCase.AddBoard(board); wonBoards.Add(board); remainingBoards.Remove(board); } caseNumber++; } }
protected override void ExtractCases() { Cases = new List <ProofCase>(); _permutationLinked = new Dictionary <SuperSlimBoard, List <Tuple <Permutation, SuperSlimBoard> > >(); var indices = Enumerable.Range(0, Mind.ColorableBoards[0].Stacks.Value.Length).ToList(); var permutations = Permutation.EnumerateAll(indices.Count).ToList(); var caseNumber = 0; var colorableCase = new ProofCase(Mind, 0, Mind.ColorableBoards); Cases.Add(colorableCase); caseNumber++; var remainingBoards = Mind.PlayableBoards.Except(Mind.BreakerWonBoards).ToList(); var wonBoards = Mind.ColorableBoards.ToList(); while (remainingBoards.Count > 0) { var proofCase = new ProofCase(Mind, caseNumber); Cases.Add(proofCase); var addedRootBoards = new List <SuperSlimBoard>(); var addedBoards = new List <SuperSlimBoard>(); foreach (var board in remainingBoards) { if (addedBoards.Contains(board)) { continue; } var treeInfo = Mind.GetWinTreeInfo(board); var childBoards = treeInfo.Select(bc => new SuperSlimBoard(board._trace, bc.Alpha, bc.Beta, bc.Response, board._stackCount)).Distinct().ToList(); if (childBoards.SubsetEqual(wonBoards)) { addedRootBoards.Add(board); addedBoards.Add(board); _permutationLinked[board] = new List <Tuple <Permutation, SuperSlimBoard> >(); foreach (var p in permutations) { var pb = board.Permute(p, indices); if (wonBoards.Contains(pb) || addedBoards.Contains(pb)) { continue; } var closed = true; foreach (var cb in childBoards) { if (!wonBoards.Contains(cb.Permute(p, indices))) { closed = false; break; } } if (closed) { _permutationLinked[board].Add(new Tuple <Permutation, SuperSlimBoard>(p, pb)); addedBoards.Add(pb); } } } } foreach (var board in addedRootBoards) { proofCase.AddBoard(board); } foreach (var board in addedBoards) { wonBoards.Add(board); remainingBoards.Remove(board); } caseNumber++; } if (Mind.BreakerWonBoards.Count > 0) { foreach (var group in Mind.BreakerWonBoards.GroupBy(b => Mind.IsSuperabundant(b))) { var lostCase = new ProofCase(Mind, caseNumber, group.ToList()) { BreakerWin = true, Superabundant = group.Key }; Cases.Add(lostCase); } } }