This is a simple zombie survival game, i need to have finished by tomorrow, and I am having multiple problems with vectors being out of range. I also need to change some stuff into classes and make inheritances. I have tried fixing the problems but no success so far and I don't know how to deal with vectors as well as I thought I would be able to, and also since I made the mistake of not making classes from the start it kind of makes things harder now.
this is the code.

#include <cstdio>
#include <ctime>
#include <iostream>
#include <windows.h>
#include <fstream>
#include <vector>
using namespace std;

bool zmbexist(vector<vector<int> >& sqarep, int posx, int posy);
int nrzombies(vector<vector<int> >& plain);
void display(vector<vector<int> >& terain);
bool movezombies(vector<vector<int> >& plain);
bool smartmovezombies(vector<vector<int> >& plain);
bool play(int nrz, int nrholes, vector<vector <int> >& plain);

int main()
{
    srand(time(NULL));
    vector<vector<int> > vectx;
    //initialise the vector
    vectx.resize(10);
    for (int i = 0; i < 10; i++)
    {
        vectx[i].resize(10, 0);
    }

    //convention : hole number is 3 , zombie number is 2, and human number is 1;
    //ask for nr of houls
    int nrholes;
    cout << "number of holes(0 for random) : ";
    cin >> nrholes;
    //if type 0 , then the nr of houls is generated automaticaly
    if (!nrholes)
    {
        nrholes = (rand() % 9) + 1;
    }

    //place the houls

    for (int i = 0; i < nrholes;)
    {
        int xhol = rand() % 10;
        int yhol = rand() % 10;
        if (vectx.at(xhol).at(yhol) == 0)
        {
            vectx.at(xhol).at(yhol) = 3;
            i++;
        }

    }

    //ask for nr of zombies
    int nrzombies;
    cout << "number of zombies(0 for random) : ";
    cin >> nrzombies;
    //if nr is 0, then is generated automaticaly
    if (!nrzombies)
    {
        nrzombies = (rand() % 9) + 1;
    }
    for (int i = 0; i < nrzombies;)
    {
        int xhol = rand() % 10;
        int yhol = rand() % 10;
        if (vectx.at(xhol).at(yhol) == 0)
        {
            vectx.at(xhol).at(yhol) = 2;
            i++;
        }
    }

    cout << "now we place the man";
    for (;;)
    {
        int xhol = rand() % 10;
        int yhol = rand() % 10;
        if (vectx.at(xhol).at(yhol) == 0)
        {
            vectx.at(xhol).at(yhol) = 1;
            break;
        }
    }
    display(vectx);
    play(nrzombies, nrholes, vectx);
    cin.ignore(255, '\n');
    return 0;
}

bool zmbexist(vector<vector<int> >& sqarep, int posx, int posy)
{
    if (sqarep[posx][posy] == 2)
        return true;
    else
        return false;

}
int nrzombies(vector<vector<int> >& plain)
{
    int nrzmb = 0;
    for (size_t i = 0; i < plain.size(); i++)
        for (size_t j = 0; j < plain[i].size(); j++)
        {
            if (plain[i][j] == 2)
                nrzmb++;
        }
    return nrzmb;
}
void display(vector<vector<int> >& terain)
{

    system("cls");
    cout << endl;
    for (size_t i = 0; i < terain.size(); i++)
    {
        for (size_t j = 0; j < terain[i].size(); j++)
        {
            switch (terain[i][j])
            {
            case -1:
                cout << " D ";
                break;
            case 0:
                cout << " * ";
                break;
            case 1:
                cout << " M ";
                break;
            case 2:
                cout << " Z ";
                break;
            case 3:
                cout << " G ";
                break;
            default:
                cout << " E ";
                break;
            }
        }
        cout << endl;
    }

    // Sleep(5000);
}
bool movezombies(vector<vector<int> >& plain)
{
    bool dead, zombiemove;
    for (size_t i = 0; i < plain.size(); i++)
    {
        for (size_t j = 0; j < plain[i].size(); j++)
        {
            //make sure that all the zombie moves

            if (plain[i][j] == 2)
            {
                zombiemove = false;
                while (!zombiemove)
                {
                    int rndmove = rand() % 4 + 1;
                    cout << rndmove << "\n";
                    // Sleep(1000);
                    cout << "now move zombie \n";
                    //move up if is possible

                    if (rndmove == 1)
                    {
                        cout << "move up \n";
                        if (i > 1)
                        {
                            if (plain[i - 1][j] == 3)
                            {
                                plain[i][j] = 0;
                                zombiemove = true;
                                //  break;
                            }
                            else if (plain[i - 1][j] == 1)
                            {
                                dead = true;
                                //return true;
                                zombiemove = true;

                            }
                            else if (plain[i - 1][j] == 0)
                            {
                                plain[i][j] = 0;
                                plain[i - 1][j] = 5;
                                zombiemove = true;
                                //break;

                            }
                        }
                    }
                    //move down if is possible
                    if (rndmove == 2)
                    {
                        cout << "move down \n";
                        if (i < 9)
                        {
                            if (plain[i + 1][j] == 3)
                            {
                                plain[i][j] = 0;
                                zombiemove = true;
                                //break;
                            }
                            else if (plain[i + 1][j] == 1)
                            {
                                dead = true;
                                //return true;
                                zombiemove = true;
                                //break;
                            }
                            else if (plain[i + 1][j] == 0)
                            {
                                plain[i][j] = 0;
                                plain[i + 1][j] = 5;
                                zombiemove = true;
                                //break;

                            }
                        }
                    }
                    //move left if is possible
                    if (rndmove == 3)
                    {
                        cout << "move left \n";
                        if (j > 1)
                        {
                            if (plain[i][j - 1] == 3)
                            {
                                plain[i][j] = 0;
                                zombiemove = true;
                                //break;
                            }
                            else if (plain[i][j - 1] == 1)
                            {
                                dead = true;
                                zombiemove = true;
                                //return true;
                            }
                            else if (plain[i][j - 1] == 0)
                            {
                                plain[i][j] = 0;
                                plain[i][j - 1] = 5;
                                zombiemove = true;
                                //  break;
                            }
                        }
                    }
                    //move left if is possible
                    if (rndmove == 4)
                    {
                        cout << "move right \n";
                        if (j < 9)
                        {
                            if (plain[i][j + 1] == 3)
                            {
                                plain[i][j] = 0;
                                zombiemove = true;
                                //break;
                            }

                            else if (plain[i][j + 1] == 1)
                            {
                                dead = true;
                                //  return true;
                                zombiemove = true;
                            }
                            else if (plain[i][j + 1] == 0)
                            {
                                plain[i][j] = 0;
                                plain[i][j + 1] = 5;
                                zombiemove = true;
                                //  break;
                            }
                        }
                    }
                }//end while
            }
        }
    }
    //}
    for (size_t i = 0; i < plain.size(); i++)
    {
        for (size_t j = 0; j < plain[i].size(); j++)
        {
            if (plain[i][j] == 5)
                plain[i][j] = 2;
        }
    }
    return false;
}
bool movehuman(vector<vector<int> >& plain)
{
    char move;
    bool dead;
    bool pmove = false;
    int x = 0, y = 0;
    for (size_t i = 0; i < plain.size(); i++)
        for (size_t j = 0; j < plain[i].size(); j++)
        {
            if ((plain[i][j]) == 1)
            {
                x == i;
                y == j;
            }

        }

    while (!pmove)
    {
        system("cls");
        display(plain);
        cout << "move human (2=down,8=up,4=left,6=right): ";
        cin >> move;
        cout << move;
        if (move == 52)
        {
            if (y > 0)
            {
                if ((plain[x][y - 1] == 3) || (plain[x][y - 1] == 2))
                {
                    cout << "is mort acuma2";
                    Sleep(2000);
                    dead = true;
                    //  return dead;
                }
                plain[x][y] = 0;
                plain[x][y - 1] = 1;
                y--;
                pmove = true;
            }

        }

        if (move == 54)
        {
            if (y < 9)
            {
                if ((plain[x][y + 1] == 3) || (plain[x][y + 1] == 2))
                {
                    return true;
                }
                plain[x][y] = 0;
                plain[x][y + 1] = 1;
                y++;
                pmove = true; 
            }

        }
        if (move == 56)
        {
            if (x > 0)
            {
                if ((plain[x - 1][y] == 3) || (plain[x - 1][y] == 2))
                {
                    return true;
                }
                plain[x][y] = 0;
                plain[x - 1][y] = 1;
                x--;
                pmove = true;
            }

        }

        if (move == 50)
        {
            if (x < 9)
            {
                if ((plain[x + 1][y] == 3) || (plain[x + 1][y] == 2))
                {
                    return true;
                }
                plain[x][y] = 0;
                plain[x + 1][y] = 1;
                x++;
                pmove = true;
            }

        }
    }
    return dead;
}
bool smartmovezombies(vector<vector<int> >& plain)
{

    size_t x = 0;
    size_t y = 0;

    //get human position

    for (size_t i = 0; i < plain.size(); i++)
    {
        for (size_t j = 0; j < plain[i].size(); j++)
        {
            if (plain[i][j] == 1)
            {
                x = i;
                y = j;
                break;
            }
        }
    }
    //for everyzombie possition calculate how to get closer to human quickly
    for (size_t i = 0; i < plain.size(); i++)
        for (size_t j = 0; j < plain[i].size(); j++)
        {
            if (plain[i][j] == 2)
            {

                if ((i > x) && (j > y))
                {
                    if (i - x > j - y)
                        if (plain[i - 1][j] == 2)
                            plain[i][j] = 0;
                        else
                        {
                            if (i > 1)
                            {
                                plain[i][j] = 0;
                                plain[i - 1][j] = 5;
                            }
                        }

                    else
                    {
                        if (plain[i][j - 1] == 2)
                            plain[i][j] = 0;
                        else
                        {
                            if (j > 1)
                            {
                                plain[i][j] = 0;
                                plain[i][j - 1] = 5;
                            }
                        }

                    }

                }

                if ((i < x) && (j < y))
                {
                    if (i - x > j - y)
                        if (plain[i + 1][j] == 2)
                            plain[i][j] = 0;
                        else
                        {
                            if (i < 10)
                            {
                                plain[i][j] = 0;
                                plain[i + 1][j] = 5;
                            }
                        }

                    else
                    {
                        if (plain[i][j + 1] == 2)
                            plain[i][j] = 0;
                        else
                        {
                            if (j < 10)
                            {
                                plain[i][j] = 0;
                                plain[i][j + 1] = 5;
                            }
                        }

                    }

                }

                if ((i < x) && (j > y))
                {
                    if (i - x > j - y)
                        if (plain[i + 1][j] == 2)
                            plain[i][j] = 0;
                        else
                        {
                            if (i < 10)
                            {
                                plain[i][j] = 0;
                                plain[i + 1][j] = 5;
                            }
                        }

                    else
                    {
                        if (plain[i][j - 1] == 2)
                            plain[i][j] = 0;
                        else
                        {
                            if (j > 1)
                            {
                                plain[i][j] = 0;
                                plain[i][j - 1] = 5;
                            }
                        }

                    }

                }

                if ((i > x) && (j < y))
                {
                    if (i - x > j - y)
                        if (plain[i - 1][j] == 2)
                            plain[i][j] = 0;
                        else
                        {
                            if (i > 1)
                            {
                                plain[i][j] = 0;
                                plain[i - 1][j] = 5;
                            }
                        }

                    else
                    {
                        if (plain[i][j + 1] == 2)
                            plain[i][j] = 0;
                        else
                        {
                            if (j > 1)
                            {
                                plain[i][j] = 0;
                                plain[i][j + 1] = 5;
                            }
                        }

                    }

                }

                if ((plain[i - 1][j] == 1) || (plain[i + 1][j] == 1) || (plain[i][j + 1] == 1) || (plain[i][j - 1] == 1))
                {
                    return true;
                }
            }

        }
    for (size_t i = 0; i < plain.size(); i++)
        for (size_t j = 0; j < plain[i].size(); j++)
        {
            if (plain[i][j] == 5)
                plain[i][j] = 2;

        }
    return false;

}
bool play(int nrz, int nrholes, vector<vector<int> >& plain)
{
    bool dead, endgame;
    endgame = false;
    dead = false;
    while (true)
    {
        endgame = smartmovezombies(plain);
        dead = movehuman(plain);
        nrz = nrzombies(plain);
        if (dead = true)
        {
            cout << "human dead";
            exit(1);
        }
        if (nrz == 0)
        {
            cout << "human win";
            exit(1);
        }
    }
    return true;
}

I wish I could help you but unfortunately I haven't looked at C++ code in two decades.

One thing that I would recommend you do moving forward is comment your code. At a minimum, each function should have a comment that says what it does. You should also comment each block of code to explain why you're doing what you're doing. For example, what does nrzombies() do? Why do you have if y < 9, set pmove = true? What happens when move is set to 56? All of these things might make perfect sense to you, the code author, but they're not understandable from the perspective of someone else seeing this for the first time. You probably, as well, wouldn't understand what's going on if you looked at this code in 6 months from now.

As well as creating classes and objects, IK would do something like this:

A human class with class methods of moveRight(), moveLeft(), moveUp(), moveDown(), draw(), etc..
A zombie class with class methods of moveCloserToHuman() and draw().

Then you can have something like a play() function that has pseudocode like:

human = new Human();
zombie1 = new Zombie();
zombie2 = new Zombie();
zombie3 = new Zombie();

human.draw();
zombie1.draw();
zombie2.draw();
zombie3.draw();

while (true)
{
    human.move();

    randomZombie = pickAZombie(); // pickAZombie() returns a random one of the three zombie objects
    randomZombie.moveCloserToHuman();
}

Because you have a human character moving around, and you have zombie characters moving around, it makes sense to me they should each be classes, and the x-y coordinates should be class properties. As I said, I don't know C++, but here's how I would do it in PHP, the language I do have experience with:

class Human {

    // Coordinates
    int $x;
    int $y;

    // Increment or decrement the object's x or y coordinates
    public function moveLeft() { $x--; }
    public function moveRight() { $x++; }
    public function moveUp() { $y++; }
    public function moveDown() { $y--; }

    public function move($keyPress)
    {
        // Do something depending on the value of $keypress
        switch ($keypress) {
            case 0: $this->moveUp(); break;
            case 1: $this->moveDown(); break;
            case 2: $this->moveRight(); break;
            case 3: $this->moveLeft(); break;
        }

    }
}
commented: Absolutely right. Even better call it pickARandomZombie and there’s no need for the comment. +15

A few things here. Move and capture all (Z)ombies (on the left).
Check your if statement against size_t.
Change your variables x, y from int to size_t, as well as change them from comparison operator to assignment operator.
Check your (Z)ombies, (H)ouls inputs to be within bounds.
Use display(plain); to debug your functions, by displaying your updated position (M).
"E" doesn't do anything, but will appear under certain conditions.
The logic of why you are dead, and when you move needs to be changed.
How to win is only being able to capture (Z) from right to left (2).
Suggest to not exit(1); while you debug and test your functions before continue. Works

#include <cstdio>
#include <ctime>
#include <iostream>
#include <windows.h>
#include <fstream>
#include <vector>
using namespace std;

bool zmbexist(vector<vector<int> >& sqarep, int posx, int posy);
int nrzombies(vector<vector<int> >& plain);
void display(vector<vector<int> >& terain);
bool movezombies(vector<vector<int> >& plain);
bool smartmovezombies(vector<vector<int> >& plain);
bool play(int nrz, int nrholes, vector<vector <int> >& plain);
int map();

int main()
{
    map(); // set new game parameters
    return 0;
}

int map()
{
    srand((unsigned int)time(NULL));
    vector<vector<int> > vectx;
    //initialise the vector
    vectx.resize(10);
    for (int i = 0; i < 10; i++)
    {
        vectx[i].resize(10, 0);
    }

    //convention : hole number is 3 , zombie number is 2, and human number is 1;
    //ask for nr of houls
    int nrholes;
    cout << "number of houls(0 for random) : ";
    cin >> nrholes;
    //if type 0 , then the nr of houls is generated automaticaly
    if (!nrholes)
    {
        nrholes = (rand() % 9) + 1;
    }

    //place the houls

    for (int i = 0; i < nrholes;)
    {
        int xhol = rand() % 9;
        int yhol = rand() % 9;
        if (vectx.at(xhol).at(yhol) == 0)
        {
            vectx.at(xhol).at(yhol) = 3;
            i++;
        }
    }
    //ask for nr of zombies
    int nrzombies;
    cout << "number of zombies(0 for random) : ";
    cin >> nrzombies;
    //if nr is 0, then is generated automaticaly
    if (!nrzombies)
    {
        nrzombies = (rand() %  9) + 1;
    }
    for (int i = 0; i < nrzombies;)
    {
        int xhol = rand() %  9;
        int yhol = rand() %  9;
        if (vectx.at(xhol).at(yhol) == 0)
        {
            vectx.at(xhol).at(yhol) = 2;
            i++;
        }
    }

    cout << "now we place the man";
    for (;;)
    {
        int xhol = rand() %  9;
        int yhol = rand() %  9;
        if (vectx.at(xhol).at(yhol) == 0)
        {
            vectx.at(xhol).at(yhol) = 1;
            break;
        }
    }
    display(vectx);
    play(nrzombies, nrholes, vectx);
    cin.ignore(255, '\n');
    return 0;
}

bool zmbexist(vector<vector<int> >& sqarep, int posx, int posy)
{
    if (sqarep[posx][posy] == 2)
        return true;
    else
        return false;

}
int nrzombies(vector<vector<int> >& plain)
{
    int nrzmb = 0;
    for (size_t i = 0; i < plain.size(); i++)
        for (size_t j = 0; j < plain[i].size(); j++)
        {
            if (plain[i][j] == 2)
                nrzmb++;
        }
    return nrzmb;
}
void display(vector<vector<int> >& terain)
{

    system("cls");
    cout << endl;
    for (size_t i = 0; i < terain.size(); i++)
    {
        for (size_t j = 0; j < terain[i].size(); j++)
        {
            switch (terain[i][j])
            {
            case -1:
                cout << " D ";
                break;
            case 0:
                cout << " * ";
                break;
            case 1:
                cout << " M ";
                break;
            case 2:
                cout << " Z ";
                break;
            case 3:
                cout << " G ";
                break;
            default:
                cout << " E ";
                break;
            }
        }
        cout << endl;
    }

    // Sleep(5000);
}
bool movezombies(vector<vector<int> >& plain)
{
    bool dead, zombiemove;
    for (size_t i = 0; i < plain.size(); i++)
    {
        for (size_t j = 0; j < plain[i].size(); j++)
        {
            //make sure that all the zombie moves
            if (plain[i][j] == 2)
            {
                zombiemove = false;
                while (!zombiemove)
                {
                    int rndmove = rand() % 4 + 1;
                    cout << rndmove << "\n";
                    // Sleep(1000);
                    cout << "now move zombie \n";
                    //move up if is possible

                    if (rndmove == 1)
                    {
                        cout << "move up \n";
                        if (i > 1)
                        {
                            if (plain[i - 1][j] == 3)
                            {
                                plain[i][j] = 0;
                                zombiemove = true;
                                //  break;
                            }
                            else if (plain[i - 1][j] == 1)
                            {
                                dead = true;
                                //return true;
                                zombiemove = true;

                            }
                            else if (plain[i - 1][j] == 0)
                            {
                                plain[i][j] = 0;
                                plain[i - 1][j] = 5;
                                zombiemove = true;
                                //break;

                            }
                        }
                    }
                    //move down if is possible
                    if (rndmove == 2)
                    {
                        cout << "move down \n";
                        if (i < 9)
                        {
                            if (plain[i + 1][j] == 3)
                            {
                                plain[i][j] = 0;
                                zombiemove = true;
                                //break;
                            }
                            else if (plain[i + 1][j] == 1)
                            {
                                dead = true;
                                //return true;
                                zombiemove = true;
                                //break;
                            }
                            else if (plain[i + 1][j] == 0)
                            {
                                plain[i][j] = 0;
                                plain[i + 1][j] = 5;
                                zombiemove = true;
                                //break;
                            }
                        }
                    }
                    //move left if is possible
                    if (rndmove == 3)
                    {
                        cout << "move left \n";
                        if (j > 1)
                        {
                            if (plain[i][j - 1] == 3)
                            {
                                plain[i][j] = 0;
                                zombiemove = true;
                                //break;
                            }
                            else if (plain[i][j - 1] == 1)
                            {
                                dead = true;
                                zombiemove = true;
                                //return true;
                            }
                            else if (plain[i][j - 1] == 0)
                            {
                                plain[i][j] = 0;
                                plain[i][j - 1] = 5;
                                zombiemove = true;
                                //  break;
                            }
                        }
                    }
                    //move left if is possible
                    if (rndmove == 4)
                    {
                        cout << "move right \n";
                        if (j < 9)
                        {
                            if (plain[i][j + 1] == 3)
                            {
                                plain[i][j] = 0;
                                zombiemove = true;
                                //break;
                            }

                            else if (plain[i][j + 1] == 1)
                            {
                                dead = true;
                                //  return true;
                                zombiemove = true;
                            }
                            else if (plain[i][j + 1] == 0)
                            {
                                plain[i][j] = 0;
                                plain[i][j + 1] = 5;
                                zombiemove = true;
                                //  break;
                            }
                        }
                    }
                }//end while
            }
        }
    }
    //}
    for (size_t i = 0; i < plain.size(); i++)
    {
        for (size_t j = 0; j < plain[i].size(); j++)
        {
            if (plain[i][j] == 5)
                plain[i][j] = 2;
        }
    }
    return false;
}
bool movehuman(vector<vector<int> >& plain)
{
    char move;
    bool dead{};
    bool pmove = false;
    size_t x = 0, y = 0;
    for (size_t i = 0; i < plain.size(); i++)
        for (size_t j = 0; j < plain[i].size(); j++)
        {
            if ((plain[i][j]) == 1)
            {
                x = i;
                y = j;
            }
        }

        while (!pmove)
        {
            system("cls");
            display(plain);
            cout << "move human (2=down,8=up,4=left,6=right): ";
            cin >> move;
            cout << move << ": ";
            if (move == 52)
            {
                if (y > 0)
                {
                    if ((plain[x][y - 1] == 3) || (plain[x][y - 1] == 2))
                    {
                        cout << "killing enemy!";
                        Sleep(2000);
                        dead = true;
                        //  return dead;
                    }
                    plain[x][y] = 0;
                    plain[x][y - 1] = 1;
                    y--;
                    pmove = true;
                }
            }

            if (move == 54)
            {
                if (y < 9)
                {
                    if ((plain[x][y + 1] == 3) || (plain[x][y + 1] == 2))
                    {
                        return true;
                    }
                    plain[x][y] = 0;
                    plain[x][y + 1] = 1;
                    y++;
                    pmove = true;
                }
            }
            if (move == 56)
            {
                if (x > 0)
                {
                    if ((plain[x - 1][y] == 3) || (plain[x - 1][y] == 2))
                    {
                        return true;
                    }
                    plain[x][y] = 0;
                    plain[x - 1][y] = 1;
                    x--;
                    pmove = true;
                }
            }

            if (move == 50)
            {
                if (x < 9)
                {
                    if ((plain[x + 1][y] == 3) || (plain[x + 1][y] == 2))
                    {
                        return true;
                    }
                    plain[x][y] = 0;
                    plain[x + 1][y] = 1;
                    x++;
                    pmove = true;
                }
            }
        }
        return dead; 
}

bool smartmovezombies(vector<vector<int> >& plain)
{

    size_t x = 0;
    size_t y = 0;

    //get human position

    for (size_t i = 0; i < plain.size(); i++)
    {
        for (size_t j = 0; j < plain[i].size(); j++)
        {
            if (plain[i][j] == 1)
            {
                x = i;
                y = j;

                break;
            }
        }
    }
    //for everyzombie possition calculate how to get closer to human quickly
    for (size_t i = 0; i < plain.size(); i++)
        for (size_t j = 0; j < plain[i].size(); j++)
        {
            if (plain[i][j] == 2)
            {

                if ((i > x) && (j > y))
                {
                    if (i - x > j - y)
                        if (plain[i - 1][j] == 2)
                            plain[i][j] = 0;
                        else
                        {
                            if (i > 1)
                            {
                                plain[i][j] = 0;
                                plain[i - 1][j] = 5;
                            }
                        }
                    else
                    {
                        if (plain[i][j - 1] == 2)
                            plain[i][j] = 0;
                        else
                        {
                            if (j > 1)
                            {
                                plain[i][j] = 0;
                                plain[i][j - 1] = 5;
                            }
                        }
                    }
                }

                if ((i < x) && (j < y))
                {
                    if (i - x > j - y)
                        if (plain[i + 1][j] == 2)
                            plain[i][j] = 0;
                        else
                        {
                            if (i < 10)
                            {
                                plain[i][j] = 0;
                                plain[i + 1][j] = 5;
                            }
                        }

                    else
                    {
                        if (plain[i][j + 1] == 2)
                            plain[i][j] = 0;
                        else
                        {
                            if (j < 10)
                            {
                                plain[i][j] = 0;
                                plain[i][j + 1] = 5;
                            }
                        }
                    }
                }

                if ((i < x) && (j > y))
                {
                    if (i - x > j - y)
                        if (plain[i + 1][j] == 2)
                            plain[i][j] = 0;
                        else
                        {
                            if (i < 10)
                            {
                                plain[i][j] = 0;
                                plain[i + 1][j] = 5;
                            }
                        }
                    else
                    {
                        if (plain[i][j - 1] == 2)
                            plain[i][j] = 0;
                        else
                        {
                            if (j > 1)
                            {
                                plain[i][j] = 0;
                                plain[i][j - 1] = 5;
                            }
                        }
                    }
                }

                if ((i > x) && (j < y))
                {
                    if (i - x > j - y)
                        if (plain[i - 1][j] == 2)
                            plain[i][j] = 0;
                        else
                        {
                            if (i > 1)
                            {
                                plain[i][j] = 0;
                                plain[i - 1][j] = 5;
                            }
                        }
                    else
                    {
                        if (plain[i][j + 1] == 2)
                            plain[i][j] = 0;
                        else
                        {
                            if (j > 1)
                            {
                                plain[i][j] = 0;
                                plain[i][j + 1] = 5;
                            }
                        }
                    }
                }
                if (i > 0 && i < plain.size() - 1 && j > 0 && j < plain[i].size() - 1)
                {
        if ((plain[i - 1][j] == 1) || (plain[i + 1][j] == 1) || (plain[i][j + 1] == 1) || (plain[i][j - 1] == 1))
                    {
                        return true;
                    }
                }
            }
        }
    for (size_t i = 0; i < plain.size(); i++)
        for (size_t j = 0; j < plain[i].size(); j++)
        {
            if (plain[i][j] == 5)
                plain[i][j] = 2;
        }
    return false;
}

bool play(int nrz, int nrholes, vector<vector<int> >& plain)
{
    bool dead, endgame;
    endgame = false;
    dead = false;
    while (true)
    {
        display(plain);
        endgame = smartmovezombies(plain);
        dead = movehuman(plain);
        nrz = nrzombies(plain);
        if (dead = true)
        { 
       //   display(plain);          
       //    cout << " - human dead :(";
       //   Sleep(2000);
       //     map();
        }
        if (nrz == 0)
        {
            display(plain);
            std::cout << " - human wins!" << std::endl;
            Sleep(2000);
            map(); // new game parameters
        }
    }
    return true;
}



 *  *  *  *  *  *  *  *  *  *
 *  *  *  *  *  *  *  *  *  *
 *  *  *  *  *  *  *  *  *  *
 *  *  *  *  *  *  *  *  *  *
 *  *  *  G  *  M  *  *  *  *
 *  *  *  *  *  *  *  *  *  *
 *  *  *  *  *  *  *  *  *  *
 *  *  *  *  *  *  *  *  *  *
 *  *  *  *  *  *  *  *  *  *
 *  *  *  *  *  *  *  *  *  *
 - human wins!
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.