游戏7(推箱子)

· · 个人记录

头文件myfile

#include<myfile>
using namespace stc;

const int 
GAME_SUM=42,
EXTRA_GAME_SUM=14,
MP_X_SIZE=25,
MP_Y_SIZE=49,
GAME_X_SIZE=25,
GAME_Y_SIZE=49;

struct PLAYING_SIZE{
    int x,y;
};

struct POS{
    int game,x,y;
};

bool operator<(POS x,POS y)
{
    return x.game<y.game||x.game==y.game&&(x.x<y.x||x.x==y.x&&x.y<y.y);
}

vector<POS>mp_transmit_point,game_transmit_point[GAME_SUM],extra_game_transmit_point[EXTRA_GAME_SUM];
map<POS,int>portal;

bool operator==(POS x,POS y)
{
    return x.game==y.game&&x.x==y.x&&x.y==y.y;
}

char mp[MP_X_SIZE][MP_Y_SIZE+1]=
{
    "#################################################",
    "#_  #   #_*     *   ### _ #_#_#_#               #",
    "# ### # # # ### ##      #*# # # # ############# #",
    "#_    # #   #_   *  ###   #       #             #",
    "####### # #########  _# ### ####### #############",
    "#     # #  _   _  # ### #_# #######             #",
    "# ### # # ####### # o   #   ################### #",
    "#  _#   # #     # # # ### # #####_              #",
    "### ##### # ### # #     # # ####### #############",
    "#     # #   #   # # ##### ######### #          _#",
    "# # # # ### # # # #    _#   ############# ### ###",
    "# # #     # # * # ### ##### ###########+# # #  _#",
    "### ### # #*### # #_  ###   ########### #*# # ###",
    "#     #*#_# #_  # ###  _# # ###########   # *  _#",
    "# ### # ### ### # #_  ### # ########### ### #####",
    "#  _# #  _#  _# # ### #   # ########### #      _#",
    "####### ### ### # #   # # o ########### #####*###",
    "#_      #_      # # # # ###   #########        _#",
    "### ##### ####### #       # #*############### ###",
    "#_  #_#   #_* #   ### # #*# #_ ##############   #",
    "###*# # # # # # ###     # # ## ################*#",
    "#_  #   # # *_  ### # ### *    ################ #",
    "### # ##### ####### #*      ## ################ #",
    "#_  *  _   _#######   #####    _###############_#",
    "#################################################"
};

int mp_state[MP_X_SIZE][MP_Y_SIZE]=
{
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,4,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,4,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,4,0,1,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
};

char game[GAME_SUM][GAME_X_SIZE][GAME_Y_SIZE+1]=
{
    {
        "#####",
        "#   #",
        "### #",
        "#=  #",
        "#####"
    },
    {
        "###########",
        "#   #     #",
        "### # ### #",
        "#   # #   #",
        "# ### # ###",
        "# #   # #=#",
        "# # ### # #",
        "# # #   # #",
        "# # # ### #",
        "#   #     #",
        "###########"
    },
    {
        "#######",
        "#   # #",
        "### # #",
        "#     #",
        "# ### #",
        "# #=  #",
        "#######"
    },
    {
        "#######",
        "# *   #",
        "### ###",
        "###=###",
        "#######"
    },
    {
        "#######",
        "# * -=#",
        "#######"
    },
    {
        "#########",
        "#   #   #",
        "### # # #",
        "#     # #",
        "# ### # #",
        "# #   # #",
        "# ##### #",
        "# *-#=  #",
        "#########" 
    },
    {
        "###########",
        "# * -   * #",
        "# # # # # #",
        "#   #=#   #",
        "###########"
    },
    {
        "#######",
        "# * =-#",
        "# # # #",
        "#   # #",
        "# ###*#",
        "#     #",
        "#######"
    },
    {
        "#######",
        "#=#  -#",
        "# **  #",
        "# #-# #",
        "#     #",
        "#######"
    },
    {
        "##########",
        "####  ####",
        "# *      #",
        "#### ### #",
        "###-  #  #",
        "#   =   *#",
        "# #  -## #",
        "# ## ### #",
        "# *    # #",
        "####   #-#",
        "##########" 
    },
    {
        "#####",
        "#  =#",
        "# # #",
        "#   #",
        "#####"
    },
    {
        "#######",
        "# *  =#",
        "#######"
    },
    {
        "#######",
        "#    =#",
        "#######"
    },
    {
        "#######",
        "#=#-# #",
        "# # # #",
        "#   # #",
        "### # #",
        "# *   #",
        "# # # #",
        "#   * #",
        "#######"
    },
    {
        "###########",
        "###-#-#   #",
        "#     * # #",
        "# #*#*# # #",
        "#         #",
        "#####=#####",
        "###########"
    },
    {
        "#######",
        "# o   #",
        "### ###",
        "###=###",
        "#######"
    },
    {
        "#######",
        "#### ##",
        "#-    #",
        "####  #",
        "# *  ##",
        "# o  ##",
        "###  =#",
        "#######"
    },
    {
        "#######",
        "###   #",
        "### # #",
        "#     #",
        "### ###",
        "###=###",
        "#######"
    },
    {
        "#######",
        "# *  -#",
        "##### #",
        "#=    #",
        "#######"
    },
    {
        "#######",
        "#   * #",
        "# ##* #",
        "#     #",
        "### ###",
        "###=###",
        "#######"
    },
    {
        "##########",
        "#   #### #",
        "# #      #",
        "# # ###  #",
        "# #  #  ##",
        "#    #   #",
        "#### # * #",
        "#    #   #",
        "# ## # o #",
        "# =#     #",
        "##########"
    },
    {
        "#######",
        "#  _ =#",
        "#######"
    },
    {
        "#######",
        "#    =#",
        "#######"
    },
    {
        "#######",
        "###-###",
        "### ###",
        "###*###",
        "#_   =#",
        "### ###",
        "#######"
    },
    {
        "#######",
        "###-###",
        "### ###",
        "###*###",
        "#    =#",
        "### ###",
        "#######"
    },
    {
        "#####",
        "#  _#",
        "## ##",
        "#= _#",
        "#####"
    },
    {
        "#######",
        "####_##",
        "# *   #",
        "### # #",
        "#= *  #",
        "###_###",
        "#######"
    },
    {
        "#######",
        "#   #=#",
        "### # #",
        "#     #",
        "# #####",
        "# *  -#",
        "#######"
    },
    {
        "###########",
        "#####  ####",
        "#   *     #",
        "#   # #   #",
        "##### #####",
        "#=#-      #",
        "# ### # # #",
        "#       # #",
        "###########"
    },
    {
        "#########",
        "#=#     #",
        "# ##### #",
        "#       #",
        "# #*#####",
        "#   -####",
        "#########",
        "#########",
        "#########"
    },
    {
        "#######",
        "#  _ =#",
        "#######"
    },
    {
        "#######",
        "#_#=#-#",
        "# #   #",
        "#   # #",
        "# ### #",
        "# *  *#",
        "#   # #",
        "# #   #",
        "#######"
    },
    {
        "#########",
        "# #_    #",
        "# ### # #",
        "#   #   #",
        "# # # ###",
        "#   *   #",
        "# ### # #",
        "#-#=    #",
        "#########" 
    },
    {
        "###########",
        "#  o o   _#",
        "# # # # # #",
        "#o o o o o#",
        "# # # # # #",
        "#o o o o o#",
        "# # # # # #",
        "#  o o o o#",
        "# # # # # #",
        "#= o   o -#",
        "###########"
    },
    {
        "#######",
        "# #_  #",
        "# ### #",
        "#   # #",
        "### # #",
        "#=    #",
        "#######"
    },
    {
        "#####",
        "#   #",
        "#####",
        "#  =#",
        "#####"
    },
    {
        "#########",
        "## # # ##",
        "## # # ##",
        "#- *   =#",
        "#########"
    },
    {
        "#######",
        "### ###",
        "### ###",
        "#   -=#",
        "###*###",
        "### ###",
        "#######"
    },
    {
        "#####",
        "#  =#",
        "#####",
        "#-* #",
        "#####"
    },
    {
        "###########",
        "####-######",
        "#### ##  ##",
        "###  *   ##",
        "#   o### ##",
        "#  #   # ##",
        "## # ### ##",
        "#  # #=  ##",
        "# o# ###  #",
        "#  #      #",
        "###########"
    },
    {
        "#####",
        "#  +#",
        "#####",
        "#_ =#",
        "#####"
    },
    {
        "#####",
        "#  =#",
        "#####"
    }
};

char extra_game[EXTRA_GAME_SUM][GAME_X_SIZE][GAME_Y_SIZE+1]=
{
    {
        "#############",
        "#       #   #",
        "### ### # ###",
        "#   # #     #",
        "# ### ##### #",
        "# #         #",
        "# # # ##### #",
        "# # # #     #",
        "# ### # #####",
        "#   # # #=  #",
        "# ### ##### #",
        "# #         #",
        "#############"
    },
    {
        "##########",
        "####  ####",
        "####     #",
        "#=## ##  #",
        "#-## ##*##",
        "#-##  # ##",
        "#      *-#",
        "# # ###*##",
        "# * -## ##",
        "### ###  #",
        "## *-    #",
        "##   #####",
        "##########"
    },
    {
        "##################",
        "#######   ########",
        "#       # ########",
        "# ******  ------=#",
        "## #   # #########",
        "######   #########",
        "##################"
    },
    {
        "###############",
        "#         *   #",
        "# #########*# #",
        "#   #######   #",
        "# #*####### ###",
        "# *         -=#",
        "### #*# # #####",
        "###   #     * #",
        "######### #*# #",
        "# *         # #",
        "# # #*# # ### #",
        "#   #   #     #",
        "###############"
    },
    {
        "#######",
        "#   #=#",
        "# # # #",
        "# *   #",
        "### # #",
        "#     #",
        "# # ###",
        "#  * -#",
        "#######"
    },
    {
        "#############",
        "#=#-# #     #",
        "# # # #*# # #",
        "#   # #   # #",
        "### # # #*# #",
        "# *   # #   #",
        "# # # # #*# #",
        "#           #",
        "#############"
    },
    {
        "###########",
        "# #-#=    #",
        "# # ##### #",
        "# # ##### #",
        "#       # #",
        "#       # #",
        "# #     # #",
        "#       # #",
        "#  #    # #",
        "#       # #",
        "#       # #",
        "#       o #",
        "##* ##### #",
        "##        #",
        "###########"
    },
    {
        "###########",
        "#=#-#  #  #",
        "# # #     #",
        "#   o   o #",
        "#        ##",
        "#    #    #",
        "#  #      #",
        "##      # #",
        "#     #   #",
        "###########"
    },
    {
        "#################",
        "#-              #",
        "##### ##### ### #",
        "#-      #     # #",
        "##### # # # # # #",
        "#     # # # # # #",
        "# # # # # # # # #",
        "# #       # #   #",
        "# # ####### ### #",
        "# #         #   #",
        "# #*# # ###o### #",
        "# #   # o #   # #",
        "# ##### # ### # #",
        "#         #=    #",
        "#################"
    },
    {
        "################",
        "##_  #  #####-##",
        "###    o  * # ##",
        "### ### ### # ##",
        "# * ### #_# # ##",
        "# # ### # # # ##",
        "#              #",
        "# ###*#*# # # ##",
        "#  _  #   #   =#",
        "################" 
    },
    {
        "#####",
        "#  =#",
        "#####"
    },
    {
        "#####",
        "#  =#",
        "#####"
    },
    {
        "#####",
        "#  =#",
        "#####"
    },
    {
        "###########",
        "### # # ###",
        "### # # ###",
        "#     #*  #",
        "###*# # ###",
        "### # #   #",
        "##### # # #",
        "#-      #=#",
        "###########"
    }
};

int game_state[GAME_SUM][GAME_X_SIZE][GAME_Y_SIZE]=
{
    {
        {0,0,0,0,0},
        {0,0,0,0,0},
        {0,0,0,0,0},
        {0,0,0,0,0},
        {0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0},
        {0,0,1,0,0},
        {0,0,0,0,0},
        {0,0,0,0,0},
        {0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,1,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,2,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,2,0,2,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,2,0,2,0,0,0,0,0,0},
        {0,0,0,2,0,2,0,2,0,2,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,2,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,3,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,3,3,0,0},
        {0,0,0,0,0,0,0},
        {0,0,3,3,3,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,1,3,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,3,3,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,2,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,3,0,0,0,0,0},
        {0,0,0,0,3,0,0,0,0,0},
        {0,0,0,0,3,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0},
        {0,0,0,0,0},
        {0,0,0,0,0},
        {0,0,0,0,0},
        {0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,1,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,1,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,1,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0},
        {0,0,0,4,0},
        {0,0,0,0,0},
        {0,4,0,0,0},
        {0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,4,0,4,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,0,4,0,0,0},
        {0,0,0,0,0,0,0},
        {0,4,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0},
        {0,0,4,0,0},
        {0,0,0,0,0},
        {0,0,4,0,0},
        {0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,4,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,4,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0},
        {0,0,0,0,0},
        {0,0,0,0,0},
        {0,0,0,0,0},
        {0,0,0,0,0}
    },
    {
        {0,0,0,0,0},
        {0,0,0,0,0},
        {0,0,0,0,0}
    }
};

int extra_game_state[EXTRA_GAME_SUM][GAME_X_SIZE][GAME_Y_SIZE+1]=
{
    {
        {0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,1,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,1,0,1,0,0,0,1,0,1,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,1,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0},
        {0,0,2,2,0,0,0},
        {0,0,0,2,0,0,0},
        {0,0,2,0,2,0,0},
        {0,0,0,2,0,0,0},
        {0,2,2,2,2,0,0},
        {0,2,0,2,0,0,0},
        {0,2,2,0,0,0,0},
        {0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,1,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,2,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,2,0,0},
        {0,2,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,2,0,2,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,2,0,0,0,0,0,0,0},
        {0,0,1,0,0,0,0,0,0,0,0},
        {0,0,0,0,1,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,1,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,1,0,0,1,0,0,0},
        {0,1,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,3,0},
        {0,0,0,2,3,3,3,0,0,0,3,3,3,0,0,3,0},
        {0,0,0,0,0,3,0,0,0,0,0,3,0,0,0,3,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0},
        {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0},
        {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
    },
    {
        {0,0,0,0,0},
        {0,0,0,0,0},
        {0,0,0,0,0}
    },
    {
        {0,0,0,0,0},
        {0,0,0,0,0},
        {0,0,0,0,0}
    },
    {
        {0,0,0,0,0},
        {0,0,0,0,0},
        {0,0,0,0,0}
    },
    {
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,4,0,4,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,4,0,0,0,0,0,0,0,4,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0}
    }
};

PLAYING_SIZE game_size[GAME_SUM]=
{
    5,5,
    11,11,
    7,7,
    5,7,
    3,7,
    9,9,
    5,11,
    7,7,
    7,7,
    11,10,
    5,5,
    3,7,
    3,7,
    9,7,
    7,11,
    5,7,
    8,7,
    7,7,
    5,7,
    7,7,
    11,10,
    3,7,
    3,7,
    7,7,
    7,7,
    5,5,
    7,7,
    7,7,
    9,11,
    9,9,
    3,7,
    9,7,
    9,9,
    11,11,
    7,7,
    5,5,
    5,9,
    7,7,
    5,5,
    11,11,
    5,5,
    3,5
};

PLAYING_SIZE extra_game_size[EXTRA_GAME_SUM]=
{
    13,13,
    13,10,
    7,18,
    13,15,
    9,7,
    9,13,
    15,11,
    10,11,
    15,17,
    10,16,
    3,5,
    3,5,
    3,5,
    9,11
};

POS game_pos[GAME_SUM]=
{
    0,1,1,
    0,3,1,
    0,7,3,
    0,13,9,
    0,15,9,
    0,17,1,
    0,19,1,
    0,21,1,
    0,23,1,
    0,19,5,
    0,17,9,
    0,15,13,
    0,5,11,
    0,5,15,
    0,1,9,
    0,3,13,
    0,4,21,
    0,10,23,
    0,12,19,
    0,14,19,
    0,23,31,
    0,5,25,
    22,1,3,
    0,1,27,
    24,4,1,
    0,1,29,
    26,1,3,
    27,1,4,
    27,5,3,
    26,3,3,
    0,1,31,
    31,1,3,
    32,1,1,
    33,1,3,
    34,1,9,
    0,7,33,
    0,9,47,
    0,11,47,
    0,13,47,
    0,17,47,
    0,23,47,
    41,3,1
};

POS extra_game_pos[EXTRA_GAME_SUM]=
{
    0,15,3,
    0,23,7,
    0,23,11,
    0,13,13,
    0,21,13,
    0,19,11,
    0,1,24,
    0,13,23,
    0,19,29,
    35,1,3,
    -10,1,2,
    -10,4,9,
    -10,8,3,
    0,15,47
};

POS game_begin[GAME_SUM]=
{
    1,1,1,
    2,1,1,
    3,1,1,
    4,1,1,
    5,1,1,
    6,1,1,
    7,1,3,
    8,1,3,
    9,2,1,
    10,2,1,
    11,1,1,
    12,1,1,
    13,1,1,
    14,1,5,
    15,2,1,
    16,1,1,
    17,4,1,
    18,3,1,
    19,1,1,
    20,1,1,
    21,1,8,
    22,1,1,
    23,1,1,
    24,2,3,
    25,4,1,
    26,1,1,
    27,2,1,
    28,1,1,
    29,7,9,
    30,1,3,
    31,1,1,
    32,7,1,
    33,1,1,
    34,1,1,
    35,1,1,
    36,1,1,
    37,1,2,
    38,5,3,
    39,1,1,
    40,2,4,
    41,1,1,
    42,1,1
};

POS extra_game_begin[EXTRA_GAME_SUM]=
{
    -1,1,1,
    -2,5,7,
    -3,4,2,
    -4,5,1,
    -5,1,1,
    -6,1,5,
    -7,1,1,
    -8,8,1,
    -9,9,13,
    -10,2,8,
    -11,1,1,
    -12,1,1,
    -13,1,1,
    -14,5,3
};

string game_name[GAME_SUM]=
{
    "Beginning",
    "Big map",
    "Easy maze",
    "Metal box",
    "New target",
    "Finish in order",
    "You can`t go through",
    "The boxes can`t push through",
    "You don`t have enough strength",
    "A little difficult",
    "Collapsed floor",
    "Fill",
    "Broken floor",
    "Collapse and fill",
    "Push the boxes reasonably",
    "Ice",
    "Ice and metal box",
    "Icy floor",
    "Slide",
    "Stop",
    "Ice and icy floor",
    "Level in level(1)",
    "Level in level(2)",
    "Reset(1)",
    "Reset(2)",
    "Branch(1)",
    "Branch(2)",
    "Branch(3)",
    "Branch(4)",
    "Branch(5)",
    "Depth(1)",
    "Depth(2)",
    "Depth(3)",
    "Depth(4)",
    "Depth(5)",
    "Transmit",
    "Come and back",
    "Cross",
    "On",
    "Ice and transmit",
    "Portal(1)",
    "Portal(2)"
};

string extra_game_name[EXTRA_GAME_SUM]=
{
    "Big maze",
    "Hard",
    "Very hard",
    "Fill and fill",
    "Collapsed maze",
    "Fill hard",
    "Help each other",
    "Two pieces of ice",
    "Icy maze",
    "More and more boxes(1)",
    "More and more boxes(2)",
    "More and more boxes(3)",
    "More and more boxes(4)",
    "Crazy cross"
};

string game_mind[GAME_SUM]=
{
    "@:You\n#:Wall\n\033[31m=\033[0m:The target of you\nPress WASD to move.\n",
    "Press Q to quit the level.\n",
    "",
    "*:Metal box\nYou can push the boxes.\n",
    "\033[31m-\033[0m:The target of the boxes\n",
    "You must finish the target of the boxes before finishing the target of you.\n",
    "You can`t go through the target of boxes.\n",
    "The boxes can`t push through the target of you.\n",
    "You can only push one box at once.\n",
    "This level is a little difficult.\n",
    "\033[47m \033[0m:Collapsed floor\nIf you fall into the collapsed floor,you will die.\n",
    "The boxes can fill the collapsed floor.\n",
    "\033[43m \033[0m:Broken floor\nThe broken floor will collapse when you walk through it.\n",
    "How can you change the broken floor into the normal floor?\n",
    "",
    "\033[94m*\033[0m:Ice\nYou can push the ice like a metal box.\nIce can slide.\n",
    "You can use the ice to finish the target of boxes.\n",
    "\033[104m \033[0m:Icy floor\nYou will slide when you are on the ice floor.\n",
    "The boxes on the icy floor can slide too.\n",
    "",
    "",
    "There is a level in this level.\n",
    "This level is in a level.\n",
    "When you Quit a level,the level which it is in will reset.\n",
    "Quit or finish this level,the level which this level is in will reset.\n",
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    "\033[42m \033[0m:Transmit point\nIf you are on the transmit point,you will be transmitting.\nPress space to quit transmitting.\nPress W or S to choose transmit point.\n",
    "",
    "",
    "Bug?No,feature!\n",
    "",
    "\033[33m_\033[0m:Portal\nA portal can bring you into a level.\n",
    ""
};

string extra_game_mind[EXTRA_GAME_SUM]=
{
    "Welcome to your first extra game.\nUsually,an extra game will be more difficult than a normal game.\n",
    "Come on!\n",
    "",
    "Fill!\n",
    "",
    "",
    "",
    "",
    "This maze is icy!\n",
    "",
    "",
    "",
    "",
    ""
};

char playing[MP_X_SIZE][MP_Y_SIZE+1];
int playing_state[MP_X_SIZE][MP_Y_SIZE+1];

void loading()
{
    mp_transmit_point.push_back({0,1,3});
    mp_transmit_point.push_back({0,21,9});
    mp_transmit_point.push_back({0,8,23});
    mp_transmit_point.push_back({0,8,27});
    mp_transmit_point.push_back({0,9,35});
    mp_transmit_point.push_back({0,9,37});
    mp_transmit_point.push_back({0,11,43});
    mp_transmit_point.push_back({0,15,41});

    game_transmit_point[35].push_back({36,1,3});
    game_transmit_point[35].push_back({36,3,1});
    game_transmit_point[36].push_back({37,1,4});
    game_transmit_point[36].push_back({37,1,6});
    game_transmit_point[37].push_back({38,1,3});
    game_transmit_point[37].push_back({38,3,1});
    game_transmit_point[38].push_back({39,1,2});
    game_transmit_point[38].push_back({39,3,2});
    game_transmit_point[39].push_back({40,5,6});
    game_transmit_point[39].push_back({40,8,4});

    extra_game_transmit_point[13].push_back({-14,3,1});
    extra_game_transmit_point[13].push_back({-14,1,3});
    extra_game_transmit_point[13].push_back({-14,1,5});
    extra_game_transmit_point[13].push_back({-14,3,9});

    portal[{0,11,39}]=41;

    portal[{41,1,3}]=42;
}

void init(int game_num)
{
    if(game_num==0)
        for(int i=0;i<MP_X_SIZE;i++)
            for(int j=0;j<MP_Y_SIZE;j++)
            {
                playing[i][j]=mp[i][j];
                playing_state[i][j]=mp_state[i][j];
            }
    else if(game_num>0)
        for(int i=0;i<game_size[game_num-1].x;i++)
            for(int j=0;j<game_size[game_num-1].y;j++)
            {
                playing[i][j]=game[game_num-1][i][j];
                playing_state[i][j]=game_state[game_num-1][i][j];
            }
    else
        for(int i=0;i<extra_game_size[-game_num-1].x;i++)
            for(int j=0;j<extra_game_size[-game_num-1].y;j++)
            {
                playing[i][j]=extra_game[-game_num-1][i][j];
                playing_state[i][j]=extra_game_state[-game_num-1][i][j];
            }
}

int find_game(POS pos)
{
    for(int i=0;i<GAME_SUM;i++)
        if(game_pos[i]==pos)
            return i+1;
    for(int i=0;i<EXTRA_GAME_SUM;i++)
        if(extra_game_pos[i]==pos)
            return -i-1;
}

int find_transmit_point(POS pos)
{
    if(pos.game==0)
        for(int i=0;i<mp_transmit_point.size();i++)
        {
            if(mp_transmit_point[i]==pos)
                return i;
        }
    else if(pos.game>0)
        for(int i=0;i<game_transmit_point[pos.game-1].size();i++)
        {
            if(game_transmit_point[pos.game-1][i]==pos)
                return i;
        }
    else
        for(int i=0;i<extra_game_transmit_point[-pos.game-1].size();i++)
            if(extra_game_transmit_point[-pos.game-1][i]==pos)
                return i;
}

bool check(PLAYING_SIZE t)
{
    for(int i=0;i<t.x;i++)
        for(int j=0;j<t.y;j++)
            if(playing[i][j]=='-')
                return false;
    return true;
}

void play()
{
    int temp,last_game,transmit_point_number;
    bool transmit,off_transmit,q;
    char ch;
    POS player;
    player.game=0;
    player.x=1;
    player.y=1;
    transmit=false;
    off_transmit=false;
    last_game=1;
    loading();
    init(0);
    while(1)
    {
        system("cls");
        if(!off_transmit&&playing_state[player.x][player.y]==4)
        {
            transmit=true;
            transmit_point_number=find_transmit_point(player);
        }
        off_transmit=false;

        if(playing_state[player.x][player.y]==1)
        {
            cout<<"You die!";
            Sleep(2000);
            system("cls");
            if(player.game==0)
                if(last_game>0)
                    player=game_pos[last_game-1];
                else
                    player=extra_game_pos[-last_game-1];
            else if(player.game>0)
                player=game_begin[player.game-1];
            else
                player=extra_game_begin[-player.game-1];
            init(player.game);
        }

        if(playing[player.x][player.y]=='=')
        {
            last_game=player.game;
            if(player.game>0)
                cout<<"Level "<<player.game<<":Win!";
            else
                cout<<"Extra level "<<-player.game<<":Win!";
            Sleep(2000);
            system("cls");
            if(player.game>0)
                player=game_pos[player.game-1];
            else
                player=extra_game_pos[-player.game-1];
            init(player.game);
        }

        if(player.game>=0)
            cout<<"Level:"<<player.game<<endl;
        else
            cout<<"Extra level:"<<-player.game<<endl;
        if(player.game==0)
            cout<<"Welcome to the world!\nPress space to enter the games.\n";
        else if(player.game>0)
            cout<<game_mind[player.game-1];
        else
            cout<<extra_game_mind[-player.game-1];
        for(int i=0;i<(player.game==0?MP_X_SIZE:(player.game>0?game_size[player.game-1].x:extra_game_size[-player.game-1].x));i++)
        {
            for(int j=0;j<(player.game==0?MP_Y_SIZE:(player.game>0?game_size[player.game-1].y:extra_game_size[-player.game-1].y));j++)
            {
                if(playing_state[i][j]==1)
                    cout<<"\033[47m";
                if(playing_state[i][j]==2)
                    cout<<"\033[43m";
                if(playing_state[i][j]==3)
                    cout<<"\033[104m";
                if(playing_state[i][j]==4)
                    cout<<"\033[42m";
                if(player.x==i&&player.y==j)
                    if(playing[player.x][player.y]=='_')
                        cout<<"\033[31m@";
                    else if(playing[player.x][player.y]=='+')
                        cout<<"\033[33m@";
                    else
                        cout<<"@";
                else
                    if(playing[i][j]=='_'||playing[i][j]=='='||playing[i][j]=='-')
                        cout<<"\033[31m"<<playing[i][j];
                    else if(playing[i][j]=='o')
                        if(playing_state[i][j]==3)
                            cout<<"\033[34m*";
                        else
                            cout<<"\033[94m*";
                    else if(playing[i][j]=='+')
                        cout<<"\033[33m_";
                    else
                        cout<<playing[i][j];
                cout<<"\033[0m";
            }
            cout<<endl;
        }
        if(playing[player.x][player.y]=='_')
        {
            temp=find_game(player);
            if(temp>0)
                cout<<"Level "<<temp<<":"<<game_name[temp-1]<<endl;
            else
                cout<<"Extra level "<<-temp<<":"<<extra_game_name[-temp-1]<<endl;
        }
        if(playing[player.x][player.y]=='+')
        {
            temp=portal[player];
            if(temp>0)
                cout<<"Level "<<temp<<":"<<game_name[temp-1]<<endl;
            else
                cout<<"Extra level "<<-temp<<":"<<extra_game_name[-temp-1]<<endl;
        }
        if(transmit)
            cout<<"Transmitting..."<<endl;

        while(1)
        {
            ch=find_key_down();
            if(ch!='\0')
                break;
        }

        switch(ch)
        {
            case ' ':
                if(transmit)
                {
                    transmit=false;
                    off_transmit=true;
                }
                else if(playing[player.x][player.y]=='_')
                {
                    player.game=find_game(player);
                    if(player.game>0)
                        player=game_begin[player.game-1];
                    else
                        player=extra_game_begin[-player.game-1];
                    init(player.game);
                }
                else if(playing[player.x][player.y]=='+')
                {
                    player.game=portal[player];
                    if(player.game>0)
                        player=game_begin[player.game-1];
                    else
                        player=extra_game_begin[-player.game-1];
                    init(player.game);
                }
                break;

            case 'W':
                if(transmit)
                {
                    if(transmit_point_number>0)
                        transmit_point_number--;
                    if(player.game==0)
                        player=mp_transmit_point[transmit_point_number];
                    else if(player.game>0)
                        player=game_transmit_point[player.game-1][transmit_point_number];
                    else
                        player=extra_game_transmit_point[-player.game-1][transmit_point_number];
                }
                else
                {
                    q=false;
                    if(playing_state[player.x][player.y]==2)
                        playing_state[player.x][player.y]=1;
                    if(playing[player.x-1][player.y]==' '||playing[player.x-1][player.y]=='_'||playing[player.x-1][player.y]=='+')
                        q=true;
                    else if(playing[player.x-1][player.y]=='='&&check({player.game==0?MP_X_SIZE:(player.game>0?game_size[player.game-1].x:extra_game_size[-player.game-1].x),player.game==0?MP_Y_SIZE:(player.game>0?game_size[player.game-1].y:extra_game_size[-player.game-1].y)}))
                        q=true;
                    else if(playing[player.x-1][player.y]=='*'&&(playing[player.x-2][player.y]==' '||playing[player.x-2][player.y]=='-'))
                    {
                        playing[player.x-1][player.y]=' ';
                        if(playing_state[player.x-2][player.y]==3)
                        {
                            POS t;
                            bool p;
                            t=player;
                            t.x-=2;
                            p=true;
                            while(playing_state[t.x][t.y]==3&&(playing[t.x][t.y]==' '||playing[t.x][t.y]=='-'))
                            {
                                if(playing[t.x][t.y]=='-')
                                {
                                    playing[t.x][t.y]=' ';
                                    p=false;
                                    break;
                                }
                                if(playing_state[t.x][t.y]==1)
                                {
                                    playing_state[t.x][t.y]=0;
                                    p=false;
                                    break;
                                }
                                t.x--;
                            }
                            if(p)
                                if(playing_state[t.x][t.y]==1)
                                    playing_state[t.x][t.y]=0;
                                else if(playing[t.x][t.y]==' ')
                                    playing[t.x][t.y]='*';
                                else if(playing[t.x][t.y]=='-')
                                    playing[t.x][t.y]=' ';
                                else
                                    playing[t.x+1][t.y]='*';
                        }
                        else if(playing[player.x-2][player.y]=='-')
                            playing[player.x-2][player.y]=' ';
                        else if(playing_state[player.x-2][player.y]==1)
                            playing_state[player.x-2][player.y]=0;
                        else
                            playing[player.x-2][player.y]='*';
                        q=true;
                    }
                    else if(playing[player.x-1][player.y]=='o'&&(playing[player.x-2][player.y]==' '||playing[player.x-2][player.y]=='-'))
                    {
                        POS t;
                        bool p;
                        t=player;
                        t.x-=2;
                        p=true;
                        while(playing[t.x][t.y]==' '||playing[t.x][t.y]=='-')
                        {
                            if(playing[t.x][t.y]=='-')
                            {
                                playing[t.x][t.y]=' ';
                                p=false;
                                break;
                            }
                            if(playing_state[t.x][t.y]==1)
                            {
                                playing_state[t.x][t.y]=0;
                                p=false;
                                break;
                            }
                            t.x--;
                        }
                        if(p)
                        {
                            t.x++;
                            playing[t.x][t.y]='o';
                        }
                        playing[player.x-1][player.y]=' ';
                        q=true;
                    }
                    if(q)
                    {
                        player.x--;
                        while(playing_state[player.x][player.y]==3&&(playing[player.x-1][player.y]==' '||playing[player.x-1][player.y]=='_'||playing[player.x-1][player.y]=='='&&check({player.game==0?MP_X_SIZE:(player.game>0?game_size[player.game-1].x:extra_game_size[-player.game-1].x),player.game==0?MP_Y_SIZE:(player.game>0?game_size[player.game-1].y:extra_game_size[-player.game-1].y)})))
                        {
                            player.x--;
                            if(playing[player.x][player.y]=='=')
                                break;
                        }
                    }
                }
                break;

            case 'A':
                if(!transmit)
                {
                    q=false;
                    if(playing_state[player.x][player.y]==2)
                        playing_state[player.x][player.y]=1;
                    if(playing[player.x][player.y-1]==' '||playing[player.x][player.y-1]=='_'||playing[player.x][player.y-1]=='+')
                        q=true;
                    else if(playing[player.x][player.y-1]=='='&&check({player.game==0?MP_X_SIZE:(player.game>0?game_size[player.game-1].x:extra_game_size[-player.game-1].x),player.game==0?MP_Y_SIZE:(player.game>0?game_size[player.game-1].y:extra_game_size[-player.game-1].y)}))
                        q=true;
                    else if(playing[player.x][player.y-1]=='*'&&(playing[player.x][player.y-2]==' '||playing[player.x][player.y-2]=='-'))
                    {
                        playing[player.x][player.y-1]=' ';
                        if(playing_state[player.x][player.y-2]==3)
                        {
                            POS t;
                            bool p;
                            t=player;
                            t.y-=2;
                            p=true;
                            while(playing_state[t.x][t.y]==3&&(playing[t.x][t.y]==' '||playing[t.x][t.y]=='-'))
                            {
                                if(playing[t.x][t.y]=='-')
                                {
                                    playing[t.x][t.y]=' ';
                                    p=false;
                                    break;
                                }
                                if(playing_state[t.x][t.y]==1)
                                {
                                    playing_state[t.x][t.y]=0;
                                    p=false;
                                    break;
                                }
                                t.y--;
                            }
                            if(p)
                                if(playing_state[t.x][t.y]==1)
                                    playing_state[t.x][t.y]=0;
                                else if(playing[t.x][t.y]==' ')
                                    playing[t.x][t.y]='*';
                                else if(playing[t.x][t.y]=='-')
                                    playing[t.x][t.y]=' ';
                                else
                                    playing[t.x][t.y+1]='*';
                        }
                        else if(playing[player.x][player.y-2]=='-')
                            playing[player.x][player.y-2]=' ';
                        else if(playing_state[player.x][player.y-2]==1)
                            playing_state[player.x][player.y-2]=0;
                        else
                            playing[player.x][player.y-2]='*';
                        q=true;
                    }
                    else if(playing[player.x][player.y-1]=='o'&&(playing[player.x][player.y-2]==' '||playing[player.x][player.y-2]=='-'))
                    {
                        POS t;
                        bool p;
                        t=player;
                        t.y-=2;
                        p=true;
                        while(playing[t.x][t.y]==' '||playing[t.x][t.y]=='-')
                        {
                            if(playing[t.x][t.y]=='-')
                            {
                                playing[t.x][t.y]=' ';
                                p=false;
                                break;
                            }
                            if(playing_state[t.x][t.y]==1)
                            {
                                playing_state[t.x][t.y]=0;
                                p=false;
                                break;
                            }
                            t.y--;
                        }
                        if(p)
                        {
                            t.y++;
                            playing[t.x][t.y]='o';
                        }
                        playing[player.x][player.y-1]=' ';
                        q=true;
                    }
                    if(q)
                    {
                        player.y--;
                        while(playing_state[player.x][player.y]==3&&(playing[player.x][player.y-1]==' '||playing[player.x][player.y-1]=='_'||playing[player.x][player.y-1]=='='&&check({player.game==0?MP_X_SIZE:(player.game>0?game_size[player.game-1].x:extra_game_size[-player.game-1].x),player.game==0?MP_Y_SIZE:(player.game>0?game_size[player.game-1].y:extra_game_size[-player.game-1].y)})))
                        {
                            player.y--;
                            if(playing[player.x][player.y]=='=')
                                break;
                        }
                    }
                }   
                break;

            case 'S':
                if(transmit)
                {
                    if(transmit_point_number<(player.game==0?mp_transmit_point.size():(player.game>0?game_transmit_point[player.game-1].size():extra_game_transmit_point[-player.game-1].size()))-1)
                        transmit_point_number++;
                    if(player.game==0)
                        player=mp_transmit_point[transmit_point_number];
                    else if(player.game>0)
                        player=game_transmit_point[player.game-1][transmit_point_number];
                    else
                        player=extra_game_transmit_point[-player.game-1][transmit_point_number];
                }
                else
                {
                    q=false;
                    if(playing_state[player.x][player.y]==2)
                        playing_state[player.x][player.y]=1;
                    if(playing[player.x+1][player.y]==' '||playing[player.x+1][player.y]=='_'||playing[player.x+1][player.y]=='+')
                        q=true;
                    else if(playing[player.x+1][player.y]=='='&&check({player.game==0?MP_X_SIZE:(player.game>0?game_size[player.game-1].x:extra_game_size[-player.game-1].x),player.game==0?MP_Y_SIZE:(player.game>0?game_size[player.game-1].y:extra_game_size[-player.game-1].y)}))
                        q=true;
                    else if(playing[player.x+1][player.y]=='*'&&(playing[player.x+2][player.y]==' '||playing[player.x+2][player.y]=='-'))
                    {
                        playing[player.x+1][player.y]=' ';
                        if(playing_state[player.x+2][player.y]==3)
                        {
                            POS t;
                            bool p;
                            t=player;
                            t.x+=2;
                            p=true;
                            while(playing_state[t.x][t.y]==3&&(playing[t.x][t.y]==' '||playing[t.x][t.y]=='-'))
                            {
                                if(playing[t.x][t.y]=='-')
                                {
                                    playing[t.x][t.y]=' ';
                                    p=false;
                                    break;
                                }
                                if(playing_state[t.x][t.y]==1)
                                {
                                    playing_state[t.x][t.y]=0;
                                    p=false;
                                    break;
                                }
                                t.x++;
                            }
                            if(p)
                                if(playing_state[t.x][t.y]==1)
                                    playing_state[t.x][t.y]=0;
                                else if(playing[t.x][t.y]==' ')
                                    playing[t.x][t.y]='*';
                                else if(playing[t.x][t.y]=='-')
                                    playing[t.x][t.y]=' ';
                                else
                                    playing[t.x-1][t.y]='*';
                        }
                        else if(playing[player.x+2][player.y]=='-')
                            playing[player.x+2][player.y]=' ';
                        else if(playing_state[player.x+2][player.y]==1)
                            playing_state[player.x+2][player.y]=0;
                        else
                            playing[player.x+2][player.y]='*';
                        q=true;
                    }
                    else if(playing[player.x+1][player.y]=='o'&&(playing[player.x+2][player.y]==' '||playing[player.x+2][player.y]=='-'))
                    {
                        POS t;
                        bool p;
                        t=player;
                        t.x+=2;
                        p=true;
                        while(playing[t.x][t.y]==' '||playing[t.x][t.y]=='-')
                        {
                            if(playing[t.x][t.y]=='-')
                            {
                                playing[t.x][t.y]=' ';
                                p=false;
                                break;
                            }
                            if(playing_state[t.x][t.y]==1)
                            {
                                playing_state[t.x][t.y]=0;
                                p=false;
                                break;
                            }
                            t.x++;
                        }
                        if(p)
                        {
                            t.x--;
                            playing[t.x][t.y]='o';
                        }
                        playing[player.x+1][player.y]=' ';
                        q=true;
                    }
                    if(q)
                    {
                        player.x++;
                        while(playing_state[player.x][player.y]==3&&(playing[player.x+1][player.y]==' '||playing[player.x+1][player.y]=='_'||playing[player.x+1][player.y]=='='&&check({player.game==0?MP_X_SIZE:(player.game>0?game_size[player.game-1].x:extra_game_size[-player.game-1].x),player.game==0?MP_Y_SIZE:(player.game>0?game_size[player.game-1].y:extra_game_size[-player.game-1].y)})))
                        {
                            player.x++;
                            if(playing[player.x][player.y]=='=')
                                break;
                        }
                    }
                }
                break;

            case 'D':
                if(!transmit)
                {
                    q=false;
                    if(playing_state[player.x][player.y]==2)
                        playing_state[player.x][player.y]=1;
                    if(playing[player.x][player.y+1]==' '||playing[player.x][player.y+1]=='_'||playing[player.x][player.y+1]=='+')
                        q=true;
                    else if(playing[player.x][player.y+1]=='='&&check({player.game==0?MP_X_SIZE:(player.game>0?game_size[player.game-1].x:extra_game_size[-player.game-1].x),player.game==0?MP_Y_SIZE:(player.game>0?game_size[player.game-1].y:extra_game_size[-player.game-1].y)}))
                        q=true;
                    else if(playing[player.x][player.y+1]=='*'&&(playing[player.x][player.y+2]==' '||playing[player.x][player.y+2]=='-'))
                    {
                        playing[player.x][player.y+1]=' ';
                        if(playing_state[player.x][player.y+2]==3)
                        {
                            POS t;
                            bool p;
                            t=player;
                            t.y+=2;
                            p=true;
                            while(playing_state[t.x][t.y]==3&&(playing[t.x][t.y]==' '||playing[t.x][t.y]=='-'))
                            {
                                if(playing[t.x][t.y]=='-')
                                {
                                    playing[t.x][t.y]=' ';
                                    p=false;
                                    break;
                                }
                                if(playing_state[t.x][t.y]==1)
                                {
                                    playing_state[t.x][t.y]=0;
                                    p=false;
                                    break;
                                }
                                t.y++;
                            }
                            if(p)
                                if(playing_state[t.x][t.y]==1)
                                    playing_state[t.x][t.y]=0;
                                else if(playing[t.x][t.y]==' ')
                                    playing[t.x][t.y]='*';
                                else if(playing[t.x][t.y]=='-')
                                    playing[t.x][t.y]=' ';
                                else
                                    playing[t.x][t.y-1]='*';
                        }
                        else if(playing[player.x][player.y+2]=='-')
                            playing[player.x][player.y+2]=' ';
                        else if(playing_state[player.x][player.y+2]==1)
                            playing_state[player.x][player.y+2]=0;
                        else
                            playing[player.x][player.y+2]='*';
                        q=true;
                    }
                    else if(playing[player.x][player.y+1]=='o'&&(playing[player.x][player.y+2]==' '||playing[player.x][player.y+2]=='-'))
                    {
                        POS t;
                        bool p;
                        t=player;
                        t.y+=2;
                        p=true;
                        while(playing[t.x][t.y]==' '||playing[t.x][t.y]=='-')
                        {
                            if(playing[t.x][t.y]=='-')
                            {
                                playing[t.x][t.y]=' ';
                                p=false;
                                break;
                            }
                            if(playing_state[t.x][t.y]==1)
                            {
                                playing_state[t.x][t.y]=0;
                                p=false;
                                break;
                            }
                            t.y++;
                        }
                        if(p)
                        {
                            t.y--;
                            playing[t.x][t.y]='o';
                        }
                        playing[player.x][player.y+1]=' ';
                        q=true;
                    }
                    if(q)
                    {
                        player.y++;
                        while(playing_state[player.x][player.y]==3&&(playing[player.x][player.y+1]==' '||playing[player.x][player.y+1]=='_'||playing[player.x][player.y+1]=='='&&check({player.game==0?MP_X_SIZE:(player.game>0?game_size[player.game-1].x:extra_game_size[-player.game-1].x),player.game==0?MP_Y_SIZE:(player.game>0?game_size[player.game-1].y:extra_game_size[-player.game-1].y)})))
                        {
                            player.y++;
                            if(playing[player.x][player.y]=='=')
                                break;
                        }
                    }
                }
                break;

            case 'Q':
                if(player.game!=0)
                {
                    transmit=false;
                    last_game=player.game;
                    if(player.game>0)
                        player=game_pos[player.game-1];
                    else
                        player=extra_game_pos[-player.game-1];
                    init(player.game);
                }
                break;
        }

        while(1)
        {
            ch=find_key_down();
            if(ch=='\0')
                break;
        }
    }
}

int main()
{
    play();
    return 0;
}