public async Task <IActionResult> OnPostAsync()//int? id) { if (Tableau == null || Tableau.TableauId == 0) { var image = await _context.Images.FirstOrDefaultAsync(m => m.ImageTableauId == ImageTableauId); var nombresImpression = _context.Tableaux.Count(t => t.Image.ImageTableauId == ImageTableauId) + 1; var utilisateur = await _userManager.GetUserAsync(User); var guid = System.Guid.NewGuid(); Tableau = new Tableau() { Image = image, Dimension = await _context.Dimensions.FirstOrDefaultAsync(m => m.DimensionId == DimensionId), Finition = await _context.Finitions.FirstOrDefaultAsync(m => m.FinitionId == FinitionId), NombreImpression = nombresImpression, NomPdf = image.Nom.Trim().Replace(" ", "_") + "_" + nombresImpression.ToString("D4") + ".pdf", Utilisateur = utilisateur, CodeVerif = guid.ToString().GetHashCode().ToString("x"), DateCreation = DateTime.Now.Date }; _context.Tableaux.Add(Tableau); _context.SaveChanges(); } return(RedirectToPage("./Show", new { Tableau.TableauId })); }
public bool ReducirColumnas(ref Tableau tabla, KeyValuePair <string, double> pivote, string variableMinima) { bool siCorrecto = false; if (tabla != null && !string.IsNullOrEmpty(pivote.Key) && !string.IsNullOrEmpty(variableMinima)) { OperacionesVectoriales op = new OperacionesVectoriales(); List <VectorEquation> resultado = new List <VectorEquation>(); VectorEquation evreferencia = tabla.StandardConstraint.Where(r => r.Nombre == pivote.Key).FirstOrDefault(); evreferencia = new VectorEquation(evreferencia.Nombre, evreferencia.NombresVariables, op.OperacionV1parametro(evreferencia.CuerpoNum, "/", pivote.Value), evreferencia.TerminoIndependiente / pivote.Value); foreach (VectorEquation ev in tabla.StandardConstraint) { if (ev.Nombre == pivote.Key) { resultado.Add(evreferencia); } else if (ev.Nombre != pivote.Key) { double pivoteev = ev.CuerpoVector.Where(r => r.Key == variableMinima).FirstOrDefault().Value; resultado.Add(new VectorEquation(ev.Nombre, ev.NombresVariables, op.OperacionV1parametroV2(ev.CuerpoNum, "-", pivoteev, evreferencia.CuerpoNum), op.OperacionV1parametroV2(ev.TerminoIndependiente, Constantes.Resta, pivoteev, evreferencia.TerminoIndependiente))); } } double pivotefo = tabla.FuncionObjetivo.CuerpoVector.Where(r => r.Key == variableMinima).FirstOrDefault().Value; ObjectiveFunction fo = new ObjectiveFunction(tabla.FuncionObjetivo.NombresVariables, op.OperacionV1parametroV2(tabla.FuncionObjetivo.CuerpoNum, "-", pivotefo, evreferencia.CuerpoNum), op.OperacionV1parametroV2(tabla.FuncionObjetivo.TerminoIndependiente, Constantes.Resta, pivotefo, evreferencia.TerminoIndependiente), tabla.FuncionObjetivo.SiMaximizar); tabla.FuncionObjetivo = fo; tabla.StandardConstraint = resultado; siCorrecto = ActualizarBaseTabla(ref tabla, evreferencia.Nombre, new KeyValuePair <string, double>(variableMinima, evreferencia.TerminoIndependiente)); } return(siCorrecto); }
public async Task <IActionResult> OnGetAsync(int imageTableauId, int dimensionId, int finitionId) { if (imageTableauId == 0 || dimensionId == 0 || finitionId == 0) { return(Redirect("/Tableaux/Index")); } ImageTableauId = imageTableauId; DimensionId = dimensionId; FinitionId = finitionId; var image = await _context.Images.FirstOrDefaultAsync(m => m.ImageTableauId == imageTableauId); Image = new ImagesInformation() { ImageTableauId = image.ImageTableauId, MaxImpression = image.MaxImpression, Nom = image.Nom, NomBase = image.NomBase, UrlAffichage = await _fichierService.GetUrlImage(image.ImageTableauId) }; Tableau = new Tableau() { Dimension = await _context.Dimensions.FirstOrDefaultAsync(m => m.DimensionId == dimensionId), Finition = await _context.Finitions.FirstOrDefaultAsync(m => m.FinitionId == finitionId), NombreImpression = _context.Tableaux.Count(t => t.Image.ImageTableauId == imageTableauId) + 1 }; return(Page()); }
private void MoveSelect(CardViewModel card) { Utils.WriteLine("MoveSelecting: {0}", card); if (card == null) { ResetMoveAndRefresh(); return; } if (Tableau.FromCard == null) { Tableau.FromCard = card; Refresh(); return; } Tableau.ToCard = card; if (Tableau.FromCard.Column == Tableau.ToCard.Column) { ResetMoveAndRefresh(); return; } if (Tableau.TryMove()) { AddCheckPoint(); ResetMoveAndRefresh(); return; } ResetMoveAndRefresh(); }
public async Task <IActionResult> OnGetAsync(int tableauId) { TableauId = tableauId; var tableau = await _context.Tableaux.FirstOrDefaultAsync(t => t.TableauId == TableauId); var image = await _context.Images.FirstOrDefaultAsync(m => m.ImageTableauId == tableau.ImageTableauId); Image = new ImagesInformation() { ImageTableauId = image.ImageTableauId, MaxImpression = image.MaxImpression, Nom = image.Nom, NomBase = image.NomBase, UrlAffichage = await _fichierService.GetUrlImage(image.ImageTableauId) }; Tableau = new Tableau() { Dimension = await _context.Dimensions.FirstOrDefaultAsync(m => m.DimensionId == tableau.DimensionId), Finition = await _context.Finitions.FirstOrDefaultAsync(m => m.FinitionId == tableau.FinitionId), NombreImpression = tableau.NombreImpression }; return(Page()); }
public void Indexer_returns_cards_starting_from_bottom() { var t = Tableau.Create("5H 9S 2D"); Assert.Equal(Card.Get("2D"), t[2]); Assert.Equal(Card.Get("5H"), t[0]); }
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; }
private void CheckLastCardOfPreviousStack() { if (previousParent != parentToReturnTo) { lastGoodParametres.lastCardAbove = null; Tableau tableau = previousParent.GetComponent <Tableau>(); if (tableau && previousParent.childCount > 0) { Card card = previousParent.GetChild(previousParent.childCount - 1).GetComponent <Card>(); if (card.isReversed) { animationQueueController.AddMovingCard(); card.RegisterOnReverseAnimationFinishCB(animationQueueController.FinishCardMoving); card.RotateCard(Constants.STOCK_ANIM_TIME); MatchStatistics.instance.AddScore(Constants.TURN_OVER_CARD_POINTS); SoundManager.instance.PlayReverseCardSound(); } else { lastGoodParametres.lastCardAbove = card; } } } else { //if parent not changed remove last save animationQueueController.AddMovingCard(); OnAnimationFinishCB = animationQueueController.FinishCardMoving; SaveManager.instance.RemoveLastSave(); } }
public void ModifierLabyrinthe(int i, int j, bool val) { if (i >= 0 && j >= 0 && i < Tableau.GetLength(0) && j < Tableau.GetLength(1)) { _tableau[i, j] = val; } }
public bool ExtraerDatosSimplex(string path, string NombreHoja, out Tableau tabla) { bool siCorrecto = false; tabla = null; List <string> cabeceraFila = new List <string>(); List <string> cabeceraColumna = new List <string>(); if (!string.IsNullOrWhiteSpace(path) && !string.IsNullOrWhiteSpace(NombreHoja)) { UsoExcel helperExcel = new UsoExcel(path); SimplexTService stService = new SimplexTService(); if (helperExcel.SiProcesoCorrecto && helperExcel.ComprobarSiExisteHoja(NombreHoja, out int indiceHoja) && helperExcel.ObtenerDimensionesHoja(indiceHoja, out int countFila, out int countCol)) { string[,] datosH = helperExcel.ObtenerDatosHoja(NombreHoja); List <Constraint> restricciones = ObtenerEcuaciones(datosH, countFila - 1, countCol - 1, out List <string> cabecera, out ObjectiveFunction funcionObjetivo); List <StandardConstraint> restriccionesEstand = stService.EstandarizarRestricciones(restricciones).ToList(); restriccionesEstand = stService.EstandarizarVector(restriccionesEstand).ToList(); if (stService.EstandarizarFuncionObjetivo(restriccionesEstand, ref funcionObjetivo)) { tabla = new Tableau(funcionObjetivo, restriccionesEstand); siCorrecto = true; } } helperExcel.CerrarLibroExcel(); } return(siCorrecto); }
/// <summary> /// Rempli le dico des loots spécifiés /// </summary> /// <param name="List"></param> public void CreationListLoot() { //ajout cle for (int cle = 0; cle < quantiteLoot.nbClés; cle++) { Liste.Add(this.CaseVide(), new Loot_ObjetCle()); } //ajout carte du labyrinthe for (int carte = 0; carte < quantiteLoot.nbCartes; carte++) { Liste.Add(this.CaseVide(), new Loot_Carte()); } //ajout pic for (int pic = 0; pic < quantiteLoot.nbPic; pic++) { Liste.Add(this.CaseVide(), new Loot_ObjetPic()); } //ajout etre for (int etre = 0; etre < quantiteLoot.nbCartes; etre++) { Liste.Add(this.CaseVide(), new Loot_Etre()); } //ajout Sort InstanciationLootSort(quantiteLoot.nbSortTeleportation, TypeSort.Immediat, NomSort.Teleportation, Liste); InstanciationLootSort(quantiteLoot.nbSortVision, TypeSort.Immediat, NomSort.Vision, Liste); InstanciationLootSort(quantiteLoot.nbSortForce, TypeSort.Immediat, NomSort.Force, Liste); //ajout Potion InstanciationLootSort(quantiteLoot.nbPotionForce, TypeSort.Potion, NomSort.Force, Liste); InstanciationLootSort(quantiteLoot.nbPotionForce, TypeSort.Potion, NomSort.Vision, Liste); InstanciationLootSort(quantiteLoot.nbPotionForce, TypeSort.Potion, NomSort.Vitesse, Liste); //ajout carte InstanciationLootSort(quantiteLoot.nbCartes, TypeSort.Carte, (NomSort)Utilitaire.RandNombre(0, 50), Liste); //ajout porte Liste.Add(CaseVide(Tableau.GetLength(0) * 0.9, Tableau.GetLength(1) * 0.5, Tableau.GetLength(0), Tableau.GetLength(1) * 0.51), new Loot_Porte()); }
public void ExecuteMove_auto_plays_all_possible_moves_next() { /* * HH CC DD SS * KH TC KD KS * * aa bb cc dd * QC -- -- -- * * 00 01 02 03 04 05 06 07 * -- -- -- -- -- -- -- -- * KC * JC */ var r = Reserve.Create("QC"); var f = Foundation.Create(Ranks.Rk, Ranks.R10, Ranks.Rk, Ranks.Rk); var t0 = Tableau.Create("KC JC"); var tRest = Tableau.Create(); var ts = Tableaus.Create(t0, tRest, tRest, tRest, tRest, tRest, tRest, tRest); var b = Board.Create(r, f, ts); Assert.True(b.IsValid()); // Act b = b.ExecuteMove(Move.Get(MoveType.TableauToFoundation, 0)); // Assert Assert.Equal(1, b._manualMoveCount); Assert.Equal(2, b.AutoMoveCount); Assert.Equal(3, b.MoveCount); Assert.True(b.IsSolved); }
} //VerifierObjet /// <summary> /// Change la scene en cours. /// </summary> /// <param name="nouvelleScene">Le nom de la nouvelle scene (tableau de jeu, combat ou menu).</param> public void ChangerScene(string nouvelleScene = null) { if (nouvelleScene == null) { nouvelleScene = _memNomScene; estRetourAuTableauEnMemoire = true; } //if Debug.Log("<color=grey>ChangerScene vers: " + nouvelleScene + "</color>"); if (SceneUtility.GetBuildIndexByScenePath(nouvelleScene) >= 0) //evite risque d'erreur si la scene n'existe pas //la scene demandee existe { if (!estRetourAuTableauEnMemoire) { //on sauvegarde seulement si on a pas besoin de l'info! _memNomScene = SceneManager.GetActiveScene().name; //sauvegarde du nom de la scene pour utilisation ulterieure _memPosPerso = _perso.ObtenirPosition(); //sauvegarde de la position pour utilisation ulterieure } //if if (nouvelleScene == "Combat") { Jeu.tableau = null; SceneManager.LoadScene(nouvelleScene); } else { //c'est un tableau de jeu SceneManager.LoadScene(nouvelleScene); } //if+else } else { Debug.LogWarning("ATTENTION! La scène demandée n'existe pas. Vérifiez son nom (" + nouvelleScene + ") et les «Build Settings» du projet."); } //if+else } //ChangerScene
private void GenererListe(Table donnees, string nomFeuille) { Classeur document = new Classeur(); Tableau tableau = new Tableau(donnees, ((ComboBoxItem)cmbChamp.SelectedItem).Text); tableau.AjouterTitre(((ComboBoxItem)cmbSousChamp.SelectedItem).Text); tableau.AjouterTitre(((ComboBoxItem)cmbActivite.SelectedItem).Text); Feuille feuille = new Feuille(nomFeuille, tableau.Titres.Count + 1); feuille.AjouterTableau(tableau); document.AjouterFeuille(feuille); frmPrincipal formulairePrincipal = ParentForm is frmPrincipal ? (frmPrincipal)ParentForm : null; if (formulairePrincipal != null) { formulairePrincipal.AfficherIndication("Génération du document Excel"); } document.Generer(); if (formulairePrincipal != null) { formulairePrincipal.EffacerIndication(); } }
public void GetValue_returns_value_at_specified_index() { var t = Tableau.Create("5H 9S 2D"); Assert.Equal(Card.Get("2D").RawValue, t.GetValue(2)); Assert.Equal(Card.Get("5H").RawValue, t.GetValue(0)); }
private int MoveOffUsingSpaces(int from, int fromRow, int to, int remainingSuits, int n) { int suits = Math.Min(remainingSuits, n); if (Diagnostics) { Utils.WriteLine("MOUS: {0} -> {1}: {2}", from, to, suits); } for (int i = n - suits; i < n; i++) { // Move as much as possible but not too much. Pile fromPile = Tableau[from]; int currentFromRow = fromPile.Count - Tableau.GetRunUp(from, fromPile.Count); if (currentFromRow < fromRow) { currentFromRow = fromRow; } int runLength = fromPile.Count - currentFromRow; MakeSimpleMove(from, -runLength, Spaces[i]); MoveStack.Push(new Move(Spaces[i], -runLength, to)); } for (int i = n - 2; i >= n - suits; i--) { int runLength = Tableau[Spaces[i]].Count; MakeSimpleMove(Spaces[i], -runLength, Spaces[n - 1]); MoveStack.Push(new Move(Spaces[n - 1], -runLength, Spaces[i])); } return(suits); }
public void Clone_clones_object() { var ts = Tableaus.Create( Tableau.Create(), Tableau.Create("KC"), Tableau.Create("KD"), Tableau.Create("KH"), Tableau.Create("KS"), Tableau.Create("QC"), Tableau.Create("QD"), Tableau.Create()); var clone = ts.CloneX(); Assert.Equal(ts.EmptyCount(), clone.EmptyCount()); Assert.Equal(Card.Null, clone[0].Top); Assert.Equal(Card.Get("KC"), clone[1].Top); Assert.Equal(Card.Get("KD"), clone[2].Top); Assert.Equal(Card.Get("KH"), clone[3].Top); Assert.Equal(Card.Get("KS"), clone[4].Top); Assert.Equal(Card.Get("QC"), clone[5].Top); Assert.Equal(Card.Get("QD"), clone[6].Top); Assert.Equal(Card.Null, clone[7].Top); Assert.NotSame(ts, clone); var fi = typeof(Tableau).GetField("_state", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); for (var i = 0; i < 8; i++) { Assert.True(ts[i].Equals(clone[i])); Assert.NotSame(ts[i], clone[i]); Assert.Equal(ts[i].Top, clone[i].Top); Assert.NotSame(fi.GetValue(ts[i]), fi.GetValue(clone[i])); } }
public void FromTableau(Tableau tableau) { Initialize(); TableauInputOutput.FromTableau(tableau); Variation = Tableau.Variation; Algorithm.PrepareToPlay(); }
protected override bool TestValidNode(Coordonnees coor) { if (coor == null) { throw new NullReferenceException("Les coordonnées de la node à valider sont nulles !"); } if (!coor.EstValide()) { throw new InvalidOperationException("Les coordonnées renseignées ne sont pas valides"); } // var node = (Node<Case>)tableau[i, j]; var node = (Node <Case>)Tableau.ElementAt(coor); CaseAgeOfKebab c = (CaseAgeOfKebab)node.Value; // CaseAgeOfKebab c = node.Value as CaseAgeOfKebab; if (c == null) { throw new NullReferenceException("Le type de case ne correspond pas !!"); } if (!c.Walkable) { //Console.WriteLine("Cette case n'est pas Walkable ! " + node.Coor); return(false); // la case n'est pas valide si elle n'est pas Walkable ! } return(true); }
private void AutoSelect(CardViewModel card) { Utils.WriteLine("Auto-selecting: {0}", card); if (card.Column == -1 && card.Row == -1) { Deal(); ResetMoveAndRefresh(); return; } Tableau.FromCard = card; int firstSpace = Tableau.FirstSpace; if (firstSpace == -1) { ResetMoveAndRefresh(); return; } Tableau.ToCard = Tableau.Piles[firstSpace][0]; if (Tableau.TryMove()) { AddCheckPoint(); ResetMoveAndRefresh(); return; } ResetMoveAndRefresh(); }
public void FindMoves(Tableau tableau) { PrepareToFindMoves(tableau); BasicMoveFinder.Find(); SwapMoveFinder.Find(); CompositeSinglePileMoveFinder.Find(); }
public void FindPivot() { var t = new Tableau(new [] { _y1, _y2, _y3, _z }); Variable head; Variable row; Assert.IsTrue(t.FindPivot(out head, out row)); }
public void Top_is_tracked_when_pushing() { var t = Tableau.Create("5H"); Assert.Equal(Card.Get("5H"), t.Top); t.Push(Card.Get("4S")); Assert.Equal(Card.Get("4S"), t.Top); }
public void Top_returns_top_card_or_null_if_empty() { var t = Tableau.Create("5H 9S 2D"); Assert.Equal(Card.Get("2D"), t.Top); t = Tableau.Create(""); Assert.Equal(Card.Null, t.Top); }
protected override void ChargerAlgorithmes() { if (Tableau == null) { throw new NullReferenceException("La grille est nulle !"); } Tableau.SetAlgoConstruction(new ConstructionGrilleAOK(Tableau)); Tableau.SetAlgoComputePath(new ComputePathsAOK(Tableau)); }
/// <summary> /// How to handle rehydration from being serialized. /// </summary> public override void Rehydrated() { base.Rehydrated(); DrawPile.Apply(c => c.Options = CardOptions); DiscardPile.Apply(c => c.Options = CardOptions); Table.Apply(c => c.Options = CardOptions); Tableau.Apply(c => c.Options = CardOptions); Hands.Apply(h => h.Apply(c => c.Options = CardOptions)); }
/// <summary> /// Créé un nouveau tableau. /// </summary> /// <param name="nouveauTableau"></param> /// <returns></returns> public async Task AddTableau(Tableau nouveauTableau) { try { using (var conn = new MySqlConnection(ConnectionString)) { // Création du Tableau string command = "INSERT INTO tableau (IdTableau, IdUser, NomTableau, DescriptionTable, DateFinInscription)" + " VALUES (@idTableau, @idUser, @nom, @description, @fin);"; using (var cmd = new MySqlCommand(command, conn)) { cmd.Parameters.AddWithValue("@idTableau", nouveauTableau.IdTableau); cmd.Parameters.AddWithValue("@idUser", nouveauTableau.IdUser); cmd.Parameters.AddWithValue("@nom", nouveauTableau.NomDuTableau); cmd.Parameters.AddWithValue("@description", nouveauTableau.Description); cmd.Parameters.AddWithValue("@fin", nouveauTableau.DateFinInscription); conn.Open(); int result = await cmd.ExecuteNonQueryAsync(); conn.Close(); } // Création des colonnes int maxLine = nouveauTableau.Colonnes.Count; string commandInsertColonne = "INSERT INTO Colonne (IdColonne, TableId, NomColonne, DescriptionColonne, TypeData) VALUES "; for (int i = 0; i < maxLine; i++) { commandInsertColonne += $"({nouveauTableau.Colonnes[i].IdColonne}" + $", '{nouveauTableau.Colonnes[i].TableId}'" + $", '{nouveauTableau.Colonnes[i].NomColonne}'" + $", '{nouveauTableau.Colonnes[i].Description}'" + $", '{nouveauTableau.Colonnes[i].TypeData}')"; if (i < (maxLine - 1)) { commandInsertColonne += ", "; } } commandInsertColonne += ";"; using (var cmd = new MySqlCommand(commandInsertColonne, conn)) { conn.Open(); await cmd.ExecuteNonQueryAsync(); conn.Close(); } } } catch (Exception ex) { throw ex; } }
public void Props_are_properly_initialized(string tableau, int expectedSize, int expectedSortedSize, string expectedTop) { // Arrange & act var t = Tableau.Create(tableau); // Assert Assert.Equal(expectedSize, t.Size); Assert.Equal(expectedSortedSize, t.SortedSize); Assert.Equal(Card.Get(expectedTop), t.Top); }
private void MakeSingleMove(Move move) { // Record the move. if (TraceMoves) { Utils.WriteLine("Move {0}: {1}", Tableau.Moves.Count, move); } // Make the move. Tableau.Move(move); }
public void Pop_tests() { // Arrange var cards = "8D 7C 6H 5S 4H 3C 2D"; var cardsArr = cards.Split(' ').Select(c => Card.Get(c)).ToArray(); var t = Tableau.Create(cards); Assert.Equal(7, t.Size); Assert.Equal(7, t.SortedSize); Assert.Equal(cardsArr[^ 1], t.Top);
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 SearchMoveFinder(Game game) : base(game) { UseDepthFirst = false; WorkingTableau = new Tableau(); TranspositionTable = new HashSet<int>(); MoveStack = new MoveList(); Moves = new MoveList(); MaxDepth = 20; MaxNodes = 10000; MoveAllocator = new ListAllocator<Move>(false); NodeAllocator = new ListAllocator<Node>(true); }
public static string ToAsciiString(Tableau tableau) { Pile discardRow = new Pile(); for (int i = 0; i < tableau.DiscardPiles.Count; i++) { Pile discardPile = tableau.DiscardPiles[i]; discardRow.Add(discardPile[discardPile.Count - 1]); } string s = ""; s += Fence; s += tableau.Variation.ToAsciiString() + PrimarySeparator; s += ToAsciiString(discardRow) + PrimarySeparator; s += ToAsciiString(tableau.DownPiles) + PrimarySeparator; s += ToAsciiString(tableau.UpPiles) + PrimarySeparator; s += ToAsciiString(tableau.StockPile); s += Fence; return WrapString(s, 60); }
public static string ToPrettyString(Tableau tableau) { string s = Environment.NewLine; s += " Spider"; s += Environment.NewLine; s += "--------------------------------"; s += Environment.NewLine; Pile discardRow = new Pile(); for (int i = 0; i < tableau.DiscardPiles.Count; i++) { Pile discardPile = tableau.DiscardPiles[i]; discardRow.Add(discardPile[discardPile.Count - 1]); } s += ToPrettyString(-1, discardRow); s += Environment.NewLine; s += ToPrettyString(tableau.DownPiles); s += Environment.NewLine; s += " " + ColumnHeadings(tableau.NumberOfPiles); s += Environment.NewLine; s += ToPrettyString(tableau.UpPiles); s += Environment.NewLine; int rowIndex = 0; Pile row = new Pile(); for (int index = tableau.StockPile.Count - 1; index >= 0; index--) { row.Add(tableau.StockPile[index]); if (row.Count == tableau.NumberOfPiles) { s += ToPrettyString(rowIndex++, row); row.Clear(); } } if (row.Count != 0) { s += ToPrettyString(rowIndex, row); } return s; }
public Game(Tableau tableau) : this() { FromTableau(tableau); }
public void FindMoves(Tableau tableau) { PrepareToFindMoves(tableau); BasicMoveFinder.Find(); SwapMoveFinder.Find(); }
public static void PrintSideBySide(Tableau game1, Tableau game2) { Utils.PrintSideBySide(game1, game2); }
public void Find(Tableau tableau) { this.tableau = tableau; int n = tableau.NumberOfPiles; for (int column = 0; column < n; column++) { Pile pile = tableau[column]; PileInfo pileInfo = pileInfoArray[column]; int m = pile.Count; pileInfo.Count = m; pileInfo.RunInfoArray[m] = new RunInfo(m, m, 0); if (m == 0) { pileInfo.RunUpAnySuitStart = 0; pileInfo.RunUpAnySuitLength = 0; continue; } if (m == 1) { pileInfo.RunUpAnySuitStart = 0; pileInfo.RunUpAnySuitLength = 1; pileInfo.RunInfoArray[0] = new RunInfo(0, 1, 1); continue; } RunInfo[] runInfoArray = pileInfo.RunInfoArray; int startRow = m - 1; int endRow = m; int suits = 1; Card previousCard = pile[endRow - 1]; for (int currentRow = m - 2; currentRow >= 0; currentRow--) { Card currentCard = pile[currentRow]; if (!currentCard.IsTargetFor(previousCard)) { break; } if (currentCard.Suit == previousCard.Suit) { startRow = currentRow; } else { RunInfo runInfo = new RunInfo(startRow, endRow, suits); for (int row = startRow; row < endRow; row++) { runInfoArray[row] = runInfo; } startRow = currentRow; endRow = currentRow + 1; suits++; } previousCard = currentCard; } { RunInfo runInfo = new RunInfo(startRow, endRow, suits); for (int row = startRow; row < endRow; row++) { runInfoArray[row] = runInfo; } } pileInfo.RunUpAnySuitStart = startRow; pileInfo.RunUpAnySuitLength = m - startRow; } }
public void PrepareToFindMoves(Tableau tableau) { game.PrepareToFindMoves(tableau); }
public Game(Tableau tableau, AlgorithmType algorithmType) : this() { AlgorithmType = algorithmType; FromTableau(tableau); }
public TableauInputOutput(Tableau tableau) { Tableau = tableau; }
public void FromTableau(Tableau tableau) { Tableau.Variation = tableau.Variation; Tableau.Clear(); foreach (Pile pile in tableau.DiscardPiles) { Tableau.DiscardPiles.Add(pile); } for (int column = 0; column < Tableau.NumberOfPiles; column++) { Tableau.DownPiles[column].Copy((tableau.DownPiles[column])); } for (int column = 0; column < Tableau.NumberOfPiles; column++) { Tableau.UpPiles[column].Copy((tableau.UpPiles[column])); } Tableau.StockPile.Copy((tableau.StockPile)); Tableau.Refresh(); }
public void PrepareToFindMoves(Tableau tableau) { FindTableau = tableau; Analyze(); }