Beispiel #1
0
        public void AllErrorEquations()
        {
            //总的误差方程计算
            int m_Pnumber = UnknowPoints.Count();
            int numAngle  = StationInfos.Count();

            B = new Matrix(DistNum + numAngle, m_Pnumber * 2);
            L = new Matrix(DistNum + numAngle, 1);
            int bi, bj;

            for (bi = 0; bi < numAngle; bi++)
            {
                for (bj = 0; bj < m_Pnumber * 2; bj++)
                {
                    B.SetNum(bi, bj, Ba.getNum(bi, bj));
                }
                L.SetNum(bi, 0, La.getNum(bi, 0));
            }
            for (bi = numAngle; bi < DistNum + numAngle; bi++)
            {
                for (bj = 0; bj < m_Pnumber * 2; bj++)
                {
                    double tt = Bd.getNum(bi - numAngle, bj);
                    B.SetNum(bi, bj, tt);
                }
                L.SetNum(bi, 0, Ld.getNum(bi - numAngle, 0));
            }
        }
Beispiel #2
0
        public static T ObtenerValor <T>(string query, SqlParameter[] parameters, Bd bd)
        {
            string connString = LeerConnString(bd);

            try
            {
                using (SqlConnection connection = new SqlConnection(connString))
                    using (SqlCommand command = new SqlCommand(query, connection))
                    {
                        command.CommandType = CommandType.Text;
                        command.Parameters.AddRange(parameters);
                        command.Connection.Open();
                        object value = command.ExecuteScalar();

                        T valor = value is DBNull || value == null ? default : (T)Convert.ChangeType(value, typeof(T));
                                  command.Connection.Close();
                                  return(valor);
                    }
            }
            catch (Exception ex)
            {
                Log.Grabar(ex);
                if (bd != Bd.Bitacora)
                {
                    throw ex;
                }
                return(default);
Beispiel #3
0
 /// <summary>
 /// Marque le mot courant comme rempli
 /// </summary>
 /// <param name="motDico"></param>
 /// <param name="bd"></param>
 public void MarquerCommeRempli(MotDico motDico, Bd bd, bool verifierTransversaux)
 {
     if (rempli)
     {
         if (Contenu.Contains("."))
         {
             rempli = false;
             bd.MarquerMotUtilise(this.motDico, false);
             this.motDico = null;
         }
     }
     else
     {
         if (!Contenu.Contains("."))
         {
             rempli       = true;
             this.motDico = motDico;
             bd.MarquerMotUtilise(motDico, true);
         }
     }
     if (verifierTransversaux)
     {
         foreach (Lettre lettre in listeLettres)
         {
             lettre.MarquerMotRempliDansDirection(!horizontal, bd);
         }
     }
 }
Beispiel #4
0
 /// <summary>
 /// Enregistre une valeur dans le mot courant (mais ne le marque pas immédiatement comme rempli)
 /// </summary>
 /// <param name="motDico"></param>
 /// <param name="bd"></param>
 public void EnregistrerMot(MotDico motDico, Bd bd)
 {
     for (int i = 0; i < this.taille; i++)
     {
         listeLettres[i].EnregistrerLettre(motDico.contenu.Substring(i, 1).ToUpper());
     }
 }
 /// <summary>
 /// Retire de la grille tous les transversaux d'un mot spécifié
 /// </summary>
 /// <param name="grille"></param>
 /// <param name="motCourant"></param>
 /// <param name="bd"></param>
 /// <param name="afficher"></param>
 public void RetirerMotsTransversaux(Grille grille, Mot motCourant, Bd bd, bool afficher)
 {
     foreach (Lettre lettre in motCourant.ListeLettres)
     {
         RetirerMot(lettre.ObtenirMotDansDirection(!motCourant.Horizontal), grille, bd, afficher);
     }
 }
 public void ValidateDestinationPosition(Position origin, Position destination)
 {
     if (!Bd.Piece(origin).PossibleMove(destination))
     {
         throw new BoardException("Posição de destino inválida!");
     }
 }
Beispiel #7
0
        public ActionResult Consultar()
        {
            var listaProdutos = new Bd();
            var todosProdutos = listaProdutos.BuscaProdutos();

            return(View(todosProdutos));
        }
 /// <summary>
 /// Rempli le mot spécifié
 /// </summary>
 /// <param name="mot"></param>
 /// <param name="bd"></param>
 /// <param name="nbEssaisMaxPourMot"></param>
 /// <param name="afficher"></param>
 public void RemplirMot(Mot mot, Bd bd, int nbEssaisMaxPourMot, bool afficher)
 {
     listeMotsPossibles = bd.ListeMotsPossibles(mot.Contenu);
     for (int j = 0, nbMotsPossibles = listeMotsPossibles.Count; j < nbEssaisMaxPourMot && j < nbMotsPossibles; j++)
     {
         int rnd = Random.Range(0, nbMotsPossibles - 1);
         mot.EnregistrerMot(listeMotsPossibles[rnd], bd);
         if (mot.ExistentMotsTransversaux(bd))
         {
             //Debug.Log("Ai écris " + mot.Contenu);
             mot.MarquerCommeRempli(listeMotsPossibles[rnd], bd, true);
             if (afficher)
             {
                 mot.AfficherMot();
             }
             break;
         }
         else
         {
             //Debug.Log("Ai tenté d'écrire " + mot.Contenu + " mais pas de mots transversaux existants");
             mot.EffacerMot(bd);
             listeMotsPossibles.RemoveAt(rnd);
             nbMotsPossibles--;
         }
     }
 }
Beispiel #9
0
 public void ConstruireGrilleVide(string gridAsString)
 {
     grille = new Grille(gridAsString);
     for (int y = 0; y < grille.nbLignes; y++)
     {
         for (int x = 0; x < grille.nbLignes; x++)
         {
             if (grille.listeLettres[x, y].valeur != null)
             {
                 grille.listeLettres[x, y].Go         = Object.Instantiate(whiteSpace, new Vector3((float)x, (float)-y, 0.0f), Quaternion.identity);
                 grille.listeLettres[x, y].GoText     = grille.listeLettres[x, y].Go.GetComponentInChildren <TextMesh>();
                 grille.listeLettres[x, y].GoRenderer = grille.listeLettres[x, y].Go.GetComponent <SpriteRenderer>();
             }
             else
             {
                 grille.listeLettres[x, y].Go = Object.Instantiate(blackSpace, new Vector3((float)x, (float)-y, 0.0f), Quaternion.identity);
             }
         }
     }
     for (int y = 0; y < grille.nbLignes; y++)
     {
         GameObject numero = Object.Instantiate(greySpace, new Vector3(-1.0f, (float)-y, 0.0f), Quaternion.identity);
         numero.GetComponentInChildren <TextMesh>().text = (y + 1).ToString();
         listeNumeros.Add(numero);
     }
     for (int x = 0; x < grille.nbColonnes; x++)
     {
         GameObject numero = Object.Instantiate(greySpace, new Vector3((float)x, 1.0f, 0.0f), Quaternion.identity);
         numero.GetComponentInChildren <TextMesh>().text = (x + 1).ToString();
         listeNumeros.Add(numero);
     }
     bd = new Bd(fichiersDicos, tailleGrille);
     Selecteur.Instance.Initialiser();
 }
 private void mostrarDatos()
 {
     using (var db = new Bd())
     {
         DatMostarDatos.DataSource = db.Categorias.ToList();
     }
 }
        public async Task <Provedor> Save(Provedor provedor)
        {
            var retorno = await Bd.QueryAsync <int>("INSERT INTO Provedor (nomeProvedor) VALUES (@nomeProvedor); SELECT SCOPE_IDENTITY();", provedor);

            provedor.SetId(retorno.Single().ToString());

            return(provedor);
        }
Beispiel #12
0
        public IActionResult Post([FromBody] Bd Bd)
        {
            DataContext db = new DataContext();

            db.Bd.Add(Bd);
            db.SaveChanges();
            return(Ok(new { BdId = Bd.Id }));
        }
 /// <summary>
 /// Retourne vrai si le dictionnaire contient au moins un mot pouvant s'inscrire dans les mots qui contiennent la lettre courante
 /// </summary>
 /// <param name="horizontal"></param>
 /// <param name="bd"></param>
 /// <returns></returns>
 public bool ExistentMots(bool horizontal, Bd bd)
 {
     if (ObtenirMotDansDirection(horizontal) == null || ObtenirMotDansDirection(horizontal).Rempli || bd.ExistentMotsPossibles(ObtenirMotDansDirection(horizontal).Contenu))
     {
         return(true);
     }
     return(false);
 }
        public override bool[,] PossibleMoves()
        {
            bool[,] mat = new bool[Bd.Linhas, Bd.Colunas];
            Position pos = new Position(0, 0);

            // up
            pos.DefineValue(Position.Linha - 1, Position.Coluna - 2);
            if (Bd.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Linha, pos.Coluna] = true;
            }
            // ne
            pos.DefineValue(Position.Linha - 2, Position.Coluna - 1);
            if (Bd.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Linha, pos.Coluna] = true;
            }

            pos.DefineValue(Position.Linha - 2, Position.Coluna + 1);
            if (Bd.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Linha, pos.Coluna] = true;
            }


            pos.DefineValue(Position.Linha - 1, Position.Coluna + 2);
            if (Bd.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Linha, pos.Coluna] = true;
            }


            pos.DefineValue(Position.Linha + 1, Position.Coluna + 2);
            if (Bd.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Linha, pos.Coluna] = true;
            }

            pos.DefineValue(Position.Linha + 2, Position.Coluna + 1);
            if (Bd.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Linha, pos.Coluna] = true;
            }

            pos.DefineValue(Position.Linha + 2, Position.Coluna - 1);
            if (Bd.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Linha, pos.Coluna] = true;
            }

            pos.DefineValue(Position.Linha + 1, Position.Coluna - 2);
            if (Bd.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Linha, pos.Coluna] = true;
            }

            return(mat);
        }
Beispiel #15
0
 /// <summary>
 /// Efface le mot courant
 /// </summary>
 /// <param name="bd"></param>
 public void EffacerMot(Bd bd)
 {
     contenusPrecedents.Add(Contenu);
     foreach (Lettre lettre in listeLettres)
     {
         lettre.EffacerLettre(horizontal);
     }
     MarquerCommeRempli(motDico, bd, false);
 }
 private void Eliminar(Categorias categorias)
 {
     using (var db = new Bd())
     {
         db.Entry <Categorias>(categorias).State = EntityState.Deleted;
         db.SaveChanges();
     }
     mostrarDatos();
 }
    /// <summary>
    /// Marque le mots utilisant la lettre courante dans la direction spécifiée comme rempli
    /// </summary>
    /// <param name="direction"></param>
    /// <param name="bd"></param>
    public void MarquerMotRempliDansDirection(bool direction, Bd bd)
    {
        Mot motAMarquer = ObtenirMotDansDirection(direction);

        if (motAMarquer != null)
        {
            motAMarquer.MarquerCommeRempli(bd.RechercherMotParContenu(motAMarquer.Contenu), bd, false);
        }
    }
 private void TxtBuscar_TextChanged(object sender, EventArgs e)
 {
     using (var db = new Bd())
     {                                                   /*Codigo Descripcion landa p => p.Descripcion.ToLower().Contains(TxtBuscar.Text.ToLower())
                                                         || p.Id.ToString().Contains(TxtBuscar.Text)).ToList();me devolvera en una lista en buscar*/
         DatMostarDatos.DataSource = db.Categorias.Where(p => p.Descripcion.ToLower().Contains(TxtBuscar.Text.ToLower()) ||
                                                         p.Id.ToString().Contains(TxtBuscar.Text)).ToList();
     }
 }
Beispiel #19
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (RegistrationData != null ? RegistrationData.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Bd != null ? Bd.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (SessionId != null ? SessionId.GetHashCode() : 0);
         return(hashCode);
     }
 }
 /// <summary>
 /// Efface tous les mots de la grille
 /// </summary>
 /// <param name="bd"></param>
 public void EffacerTout(Bd bd)
 {
     foreach (Mot mot in listeMots)
     {
         if (mot.Rempli)
         {
             mot.EffacerMot(bd);
         }
     }
 }
        public override bool[,] PossibleMoves()
        {
            bool[,] mat = new bool[Bd.Linhas, Bd.Colunas];

            Position pos = new Position(0, 0);

            // no
            pos.DefineValue(Position.Linha - 1, Position.Coluna - 1);
            while (Bd.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Linha, pos.Coluna] = true;
                if (Bd.Piece(pos) != null && Bd.Piece(pos).Color != Color)
                {
                    break;
                }
                pos.DefineValue(pos.Linha - 1, pos.Coluna - 1);
            }

            // ne
            pos.DefineValue(Position.Linha - 1, Position.Coluna + 1);
            while (Bd.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Linha, pos.Coluna] = true;
                if (Bd.Piece(pos) != null && Bd.Piece(pos).Color != Color)
                {
                    break;
                }
                pos.DefineValue(pos.Linha - 1, pos.Coluna + 1);;
            }

            // se
            pos.DefineValue(Position.Linha + 1, Position.Coluna + 1);
            while (Bd.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Linha, pos.Coluna] = true;
                if (Bd.Piece(pos) != null && Bd.Piece(pos).Color != Color)
                {
                    break;
                }
                pos.DefineValue(pos.Linha + 1, pos.Coluna + 1);
            }

            // so
            pos.DefineValue(Position.Linha + 1, Position.Coluna - 1);
            while (Bd.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Linha, pos.Coluna] = true;
                if (Bd.Piece(pos) != null && Bd.Piece(pos).Color != Color)
                {
                    break;
                }
                pos.DefineValue(pos.Linha + 1, pos.Coluna - 1);
            }
            return(mat);
        }
Beispiel #22
0
 /// <summary>
 /// Retourne vrai si le dictionnaire contient des mots pouvant s'insérer transversalement au mot courant
 /// </summary>
 /// <param name="bd"></param>
 /// <returns></returns>
 public bool ExistentMotsTransversaux(Bd bd)
 {
     foreach (Lettre lettre in listeLettres)
     {
         if (!lettre.ExistentMots(!horizontal, bd))
         {
             return(false);
         }
     }
     return(true);
 }
Beispiel #23
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Bd != null ? Bd.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Sign != null ? Sign.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Challenge != null ? Challenge.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (SessionId != null ? SessionId.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AppId != null ? AppId.GetHashCode() : 0);
         return(hashCode);
     }
 }
    /// <summary>
    /// Remplir la grille
    /// </summary>
    /// <param name="bd"></param>
    /// <param name="listeMots"></param>
    /// <param name="nbEssaisMaxGlobal"></param>
    /// <param name="nbEssaisMaxPourMot"></param>
    /// <param name="afficher"></param>
    public void RemplirGrille(Bd bd, Grille grille, int nbEssaisMaxGlobal, int nbEssaisMaxPourMot, bool afficher)
    {
        int  nbEssaisGlobal = 0;
        bool trier          = false;

        CalculerScoresDesMots(grille.listeMotsARemplir);
        Mot motARemplir = ObtenirProchainMotARemplir(grille, true);

        while (motARemplir != null && nbEssaisGlobal < nbEssaisMaxGlobal)
        {
            //Debug.Log((motARemplir.Horizontal ? "Horizontal " : "Vertical ") + motARemplir.PositionPrimaire + ":" + motARemplir.PositionSecondaire);
            if (motARemplir.nbTentativesDeRemplissage == 10)
            {
                RetirerMotAleatoire(grille, motARemplir, bd, afficher);
                RetirerMotAleatoire(grille, motARemplir, bd, afficher);
            }
            else if (motARemplir.nbTentativesDeRemplissage == 20)
            {
                RetirerMotAleatoire(grille, motARemplir, bd, afficher);
                RetirerMotAleatoire(grille, motARemplir, bd, afficher);
            }
            else if (motARemplir.nbTentativesDeRemplissage == 30)
            {
                RetirerMotAleatoire(grille, motARemplir, bd, afficher);
                RetirerMotAleatoire(grille, motARemplir, bd, afficher);
            }
            else if (motARemplir.nbTentativesDeRemplissage == 40)
            {
                RetirerMotsTransversaux(grille, motARemplir, bd, afficher);
                motARemplir.nbTentativesDeRemplissage = 0;
            }
            //RemplirMotSelonScore(motARemplir, bd, nbEssaisMaxPourMot, afficher);
            RemplirMot(motARemplir, bd, nbEssaisMaxPourMot, afficher);
            motARemplir.nbTentativesDeRemplissage++;
            if (!motARemplir.Rempli)
            {
                RetirerMotAleatoire(grille, motARemplir, bd, afficher);
            }
            else
            {
                motARemplir.CalculerScoreDesMotsTransversaux();
                grille.listeMotsARemplir.Remove(motARemplir);
                trier = true;
            }
            nbEssaisGlobal++;
            motARemplir = ObtenirProchainMotARemplir(grille, trier);
        }
        if (nbEssaisGlobal == 0)
        {
            Debug.Log("Grille déjà remplie");
        }
    }
        public void MakeMove(Position origin, Position destination)
        {
            Piece catchedPiece = ExecuteMove(origin, destination);

            if (InCheck(currentPlayer))
            {
                undoMove(origin, destination, catchedPiece);
                throw new BoardException("Você não pode se colocar em Xeque");
            }
            Piece p = Bd.Piece(destination);

            //# Jogada especial promoção
            if (p is Pawn)
            {
                if ((p.Color == Color.White && destination.Linha == 0) || (p.Color == Color.Black && destination.Linha == 7))
                {
                    p = Bd.GetPiece(destination);
                    pieces.Remove(p);
                    Piece queen = new Queen(Bd, p.Color);
                    Bd.PutPiece(queen, destination);
                    pieces.Add(queen);
                }
            }
            if (InCheck(adversaryColor(currentPlayer)))
            {
                Check = true;
            }
            else
            {
                Check = false;
            }
            if (TestMate(adversaryColor(currentPlayer)))
            {
                Finished = true;
            }
            else
            {
                shift++;
                ChangePlayer();
            }


            //#Jogada especial enPassant
            if (p is Pawn && (destination.Linha == origin.Linha - 2 || destination.Linha == origin.Linha + 2))
            {
                vulnerableEnPassant = p;
            }
            else
            {
                vulnerableEnPassant = null;
            }
        }
        public Piece ExecuteMove(Position origin, Position destination)
        {
            Piece p = Bd.GetPiece(origin);

            p.AddQtMovies();
            Piece catchedPiece = Bd.GetPiece(destination);

            Bd.PutPiece(p, destination);
            if (catchedPiece != null)
            {
                catched.Add(catchedPiece);
            }

            //#Jogada especial Roque pequeno
            if (p is King && destination.Coluna == origin.Coluna + 2)
            {
                Position tOrigin      = new Position(origin.Linha, origin.Coluna + 3);
                Position tDestination = new Position(origin.Linha, origin.Coluna + 1);
                Piece    T            = Bd.GetPiece(tOrigin);
                T.AddQtMovies();
                Bd.PutPiece(T, tDestination);
            }
            //#Jogada especial Roque Grande
            if (p is King && destination.Coluna == origin.Coluna - 2)
            {
                Position tOrigin      = new Position(origin.Linha, origin.Coluna - 4);
                Position tDestination = new Position(origin.Linha, origin.Coluna - 1);
                Piece    T            = Bd.GetPiece(tOrigin);
                T.AddQtMovies();
                Bd.PutPiece(T, tDestination);
            }
            //#Jogada especial enPassant
            if (p is Pawn)
            {
                if (origin.Coluna != destination.Coluna && catchedPiece == null)
                {
                    Position posP;
                    if (p.Color == Color.White)
                    {
                        posP = new Position(destination.Linha + 1, destination.Coluna);
                    }
                    else
                    {
                        posP = new Position(destination.Linha - 1, destination.Coluna);
                    }
                    catchedPiece = Bd.GetPiece(posP);
                    catched.Add(catchedPiece);
                }
            }
            return(catchedPiece);
        }
 /// <summary>
 /// Retire un mot spécifié de la grille
 /// </summary>
 /// <param name="motARetirer"></param>
 /// <param name="grille"></param>
 /// <param name="bd"></param>
 /// <param name="afficher"></param>
 public void RetirerMot(Mot motARetirer, Grille grille, Bd bd, bool afficher)
 {
     if (motARetirer != null)
     {
         motARetirer.EffacerMot(bd);
         if (afficher)
         {
             motARetirer.AfficherMot();
         }
         grille.listeMotsARemplir.Add(motARetirer);
         motARetirer.CalculerScore();
         motARetirer.CalculerScoreDesMotsTransversaux();
     }
 }
Beispiel #28
0
    /// <summary>
    /// Retourne les définitions du mot courant
    /// </summary>
    /// <param name="bd"></param>
    /// <returns></returns>
    public string[] ObtenirDefinitions(Bd bd)
    {
        MotDico motDef = bd.RechercherMotParContenuPourDefinitions(this.Contenu);

        if (motDef != null && motDef.definitions.Length > 0)
        {
            return(motDef.definitions);
        }
        else
        {
            //Debug.Log("Le mot " + this.Contenu + " n'a pas été trouvé dans le dictionnaire de définitions.");
            return(new string[] { "Définition indéterminée" });
        }
    }
        private void undoMove(Position origin, Position destination, Piece catchedPiece)
        {
            Piece p = Bd.GetPiece(destination);

            p.DecrementQtMovies();
            if (catchedPiece != null)
            {
                Bd.PutPiece(catchedPiece, destination);
                catched.Remove(catchedPiece);
            }
            Bd.PutPiece(p, origin);

            //#Jogada especial Roque pequeno
            if (p is King && destination.Coluna == origin.Coluna + 2)
            {
                Position tOrigin      = new Position(origin.Linha, origin.Coluna + 3);
                Position tDestination = new Position(origin.Linha, origin.Coluna + 1);
                Piece    T            = Bd.GetPiece(tOrigin);
                T.DecrementQtMovies();
                Bd.PutPiece(T, tDestination);
            }
            //#Jogada especial Roque grande
            if (p is King && destination.Coluna == origin.Coluna - 2)
            {
                Position tOrigin      = new Position(origin.Linha, origin.Coluna - 4);
                Position tDestination = new Position(origin.Linha, origin.Coluna - 1);
                Piece    T            = Bd.GetPiece(tOrigin);
                T.DecrementQtMovies();
                Bd.PutPiece(T, tDestination);
            }
            //#Jogada especial En Passant
            if (p is Pawn)
            {
                if (origin.Coluna != destination.Coluna && catchedPiece == vulnerableEnPassant)
                {
                    Piece    pawn = Bd.GetPiece(destination);
                    Position posP;
                    if (p.Color == Color.White)
                    {
                        posP = new Position(3, destination.Coluna);
                    }
                    else
                    {
                        posP = new Position(4, destination.Coluna);
                    }
                    Bd.PutPiece(pawn, posP);
                }
            }
        }
 public void ValidateOriginPosition(Position pos)
 {
     if (Bd.Piece(pos) == null)
     {
         throw new BoardException("Não existe uma peça na posição de origem escolhida!");
     }
     if (currentPlayer != Bd.Piece(pos).Color)
     {
         throw new BoardException("A peça de origem escolhida não é sua!");
     }
     if (!Bd.Piece(pos).ExistPossibleMoves())
     {
         throw new BoardException("Não há movimentos possíveis para a peça de origem escolhida!");
     }
 }