예제 #1
0
        static void updateMatriceCost(Marcaj m, Punct p)
        {
            miAtacuriComputer[p.x, p.y] = 1;

            switch (m)
            {
            case Marcaj.aer:    //A
            {
                miTablaCost[p.x, p.y] = 0;
                updateCeluleAdiacente(-10, p);
            } break;

            case Marcaj.avion:    // /
            {
                miTablaCost[p.x, p.y] = 0;
                updateCeluleAdiacente(100, p);
            } break;

            case Marcaj.cabina:    // *
            {
                miTablaCost[p.x, p.y] = 200;
                updateCeluleAdiacente(200, p);
            } break;
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: oliparvu/avioane
        static void Main(string[] args)
        {
            TablaMea     tablaMea     = new TablaMea();
            TablaJucator tablaJucator = new TablaJucator();

            tablaMea.initializare();
            tablaJucator.initializare();
            tablaMea.afisare();
            tablaJucator.afisare();
            Punct pctTempVariable;

            initTablaCost();
            pctTempVariable = cautaLovitura(true);

            while ((tablaMea.getLovituri() < 3) && (tablaJucator.getLovituri() < 3))
            {
                //asteapta sa atace jucatorul
                tablaMea.urmMutare();

                //ataca cu valoarea calculata anterior
                Marcaj mRezultatAtac = tablaJucator.urmMutare(pctTempVariable.x, pctTempVariable.y);
                //update la matrice cost cu rezultatul atacului
                updateMatriceCost(mRezultatAtac, pctTempVariable);

                //cauta next best shot
                pctTempVariable = cautaLovitura(false);


                Console.Clear();
                tablaMea.afisare();
                tablaJucator.afisare();
            }
            Console.WriteLine("Game over");
            Console.Read();
        }
예제 #3
0
        static void Main(string[] args)
        {
            TablaJucator tablaJucator = new TablaJucator();

            tablaMea.initializare();
            tablaJucator.initializare();
            tablaMea.afisare();
            tablaJucator.afisare();
            Punct pctTempVariable;

            initTablaCost();
            pctTempVariable = cautaLovitura();

            while ((tablaMea.getLovituri() < 3) && (tablaJucator.getLovituri() < 3))
            {
                //asteapta sa atace jucatorul
                tablaMea.urmMutare();

                //ataca cu valoarea calculata anterior
                Marcaj mRezultatAtac = tablaJucator.urmMutare(pctTempVariable.x, pctTempVariable.y);

                //update la matrice cost cu rezultatul atacului
                updateMatriceCost(mRezultatAtac, pctTempVariable);

                if ((mRezultatAtac == Marcaj.aer))
                {
                    if (bPlaneHit == true)
                    {
                        pctTempVariable = cautaLovituraMica(lastHits[lastHits.Count - 1], 0);
                    }
                    else
                    {
                        pctTempVariable = cautaLovitura();
                    }
                }

                if ((mRezultatAtac == Marcaj.avion))
                {
                    //lastHit = pctTempVariable;
                    lastHits.Add(pctTempVariable);
                    bPlaneHit       = true;
                    pctTempVariable = cautaLovituraMica(lastHits[lastHits.Count - 1], 0);;
                }

                if ((mRezultatAtac == Marcaj.cabina))
                {
                    bPlaneHit       = false;
                    pctTempVariable = cautaLovitura();
                }



                Console.Clear();
                tablaMea.afisare();
                tablaJucator.afisare();
            }
            Console.WriteLine("Game over");
            Console.Read();
        }
예제 #4
0
파일: Class1.cs 프로젝트: oliparvu/avioane
        public char marcajToChar(Marcaj val)
        {
            switch (val)
            {
            case Marcaj.aer: return('A');

            case Marcaj.avion: return('/');

            case Marcaj.cabina: return('*');

            case Marcaj.necunoscut: return('N');

            default: break;
            }
            return('H');
        }
예제 #5
0
파일: Program.cs 프로젝트: oliparvu/avioane
        static void updateMatriceCost(Marcaj m, Punct p)
        {
            switch (m)
            {
            case Marcaj.aer:    //A
            {
                TablaCost[p.x, p.y] = 0;
                updateCeluleAdiacente(-10, p);
            } break;

            case Marcaj.avion:    // /
            {
                TablaCost[p.x, p.y] = 100;
            } break;

            case Marcaj.cabina:    // *
            {
                TablaCost[p.x, p.y] = 200;
            } break;
            }
        }
예제 #6
0
        static void updateMatriceCost(Marcaj m, Punct p)
        {
            miAtacuriComputer[p.x, p.y] = 1;

            switch (m)
            {
            case Marcaj.aer:    //A
            {
                miTablaCost[p.x, p.y] = 0;
            } break;

            case Marcaj.avion:    // /
            {
                miTablaCost[p.x, p.y] = 1;
            } break;

            case Marcaj.cabina:    // *
            {
                miTablaCost[p.x, p.y] = 2;
            } break;
            }
        }
예제 #7
0
        public static Punct cautaLovitura(bool bPrimaLovitura, Marcaj bLastShootValue)
        {
            Punct        pctBestShot;
            int          max             = -10000;
            bool         bValidShotFound = false;
            List <Punct> possibleShots   = new List <Punct>();
            int          maxSum          = 0;

            int[]  randomValueArray = { -1, 0, 1 };
            Random rndPoz = new Random();
            int    incrementX, incrementY;

            pctBestShot.x = 9;
            pctBestShot.y = 9;

            if (bPrimaLovitura)
            {//prima lovitura so dont care
                pctBestShot.x = rndPoz.Next(2, 8);
                pctBestShot.y = rndPoz.Next(2, 8);
            }
            else
            {
                if (bLastShootValue == Marcaj.avion)
                {
                }

                if (bLastShootValue == Marcaj.cabina)
                {
                }


                // while (bValidShotFound == false)
                {//cauta valorile maxime din matrice
                    possibleShots = findMaxValues(miTablaCost, 0);

                    do
                    {
                        pctBestShot = possibleShots[rndPoz.Next(0, possibleShots.Count)];
                    }while (isValidShot(pctBestShot) == false);


                    //foreach (Punct pct in possibleShots)
                    //{
                    //    //extrage matrice mica
                    //    if (maxSum < smallMatrixSum(pct))
                    //    {
                    //        if (isValidShot(pct))
                    //        {
                    //            maxSum = smallMatrixSum(pct);
                    //            pctBestShot = pct;
                    //        }
                    //        else
                    //        {
                    //            incrementX = 0;
                    //            incrementY = 0;
                    //            bValidShotFound = false;
                    //            do
                    //            {
                    //                incrementX = randomValueArray[rndPoz.Next(0, 3)];
                    //                incrementY = randomValueArray[rndPoz.Next(0, 3)];


                    //                pctBestShot.x = pct.x + incrementX;
                    //                pctBestShot.y = pct.y + incrementY;
                    //                if (isValidShot(pctBestShot)) bValidShotFound = true;
                    //            }
                    //            while (((incrementX == 0) && (incrementY == 0)) || (bValidShotFound == false));
                    //        }

                    //    }
                    //}
                }
            }
            return(pctBestShot);
        }
예제 #8
0
        static void Main(string[] args)
        {
            TablaMea     tablaMea     = new TablaMea();
            TablaJucator tablaJucator = new TablaJucator();
            Punct        pctTempVariable;


            tablaMea.initializare();
            tablaJucator.initializare();
            initMatrice();
            tablaMea.afisare();
            tablaJucator.afisare();


            //genereaza prima lovitura.
            pctTempVariable = cautaLovituraRandom();

            while ((tablaMea.getLovituri() < 3) && (tablaJucator.getLovituri() < 3))
            {
                //asteapta sa atace jucatorul
                tablaMea.urmMutare();

                //ataca cu valoarea calculata anterior
                Marcaj mRezultatAtac = tablaJucator.urmMutare(pctTempVariable.x, pctTempVariable.y);

                //update la matricea cu pozitiile atacate anterior
                updateMatriceAtacuri(pctTempVariable);

                if ((mRezultatAtac == Marcaj.aer))
                {     //atacul curent a nimerit aer
                    if (bPlaneHit == true)
                    { //in zona a fost descoperit un avion
                        pctTempVariable = cautaLovituraInZonaRestransa(lsLlastHits[lsLlastHits.Count - 1], 0);
                    }
                    else
                    {//in zona NU a fost descoperit un avion
                        pctTempVariable = cautaLovituraRandom();
                    }
                }

                if ((mRezultatAtac == Marcaj.avion))
                {                                                                                          //atacul precedent a lovit un avion
                    lsLlastHits.Add(pctTempVariable);                                                      //adaug in lista atacul care a nimerit un avion
                    bPlaneHit       = true;
                    pctTempVariable = cautaLovituraInZonaRestransa(lsLlastHits[lsLlastHits.Count - 1], 0); //cauta urmatoarea lovitura intr`o zona restransa in jurul ultimului atac sucessfull
                }

                if ((mRezultatAtac == Marcaj.cabina))
                {//nimerit cabina. Avion mort
                    bPlaneHit       = false;
                    pctTempVariable = cautaLovituraRandom();
                }



                Console.Clear();
                tablaMea.afisare();
                tablaJucator.afisare();
            }
            Console.WriteLine("Game over");
            Console.Read();
        }