版本比较
Pyramid
正文
增加 9 行删除 8 行
252 行未改动全部展开25325425525625725725825926026126239 行未改动30230330430530530630730830931051 行未改动3623633643653653663673683693702 行未改动3733743753763763773783793803812 行未改动3843853863873873883893903913922 行未改动39539639739839839940040140240320 行未改动42442542642742742842943043143243343443543643743743843944044144210 行未改动252 行未改动全部展开 //debug(); //=== generate obstacles to add difficulty === //=== random map pick_up === int mp_pos_x=rnd()%20+1,mp_pos_y=rnd()%20+1; while(maze[mp_pos_x][mp_pos_y]==0){ int surprisingly_hahaha=rnd()%2; while(maze[mp_pos_x][mp_pos_y]==0 || abs(mp_pos_x-edx)+abs(mp_pos_y-edy)<=10 || maze[mp_pos_x][mp_pos_y]==surprisingly_hahaha){ mp_pos_x=rnd()%20+1; mp_pos_y=rnd()%20+1; } maze[mp_pos_x][mp_pos_y]=666;39 行未改动 Sleep(1000); cout<<"What's even worse, the pyramid will change its map completely every 20s. "<<endl; cout<<"You'd better find the treasure in 20s or you will be sent to the entrance and you have to explore again. "<<endl; Sleep(1000); cout<<"Luckily, there's a map in the pyramid. You can pick up the map and see the whole pyramid for 5s. "<<endl; cout<<"Luckily, there's a map in the pyramid. You can pick up the map and see the whole pyramid for 3s. "<<endl; Sleep(1000); cout<<"Use up/down/left/right to move. '#' stands for wall and '.' stands for land. "<<endl; cout<<"o is yourself. ! stands for treasure. "<<endl; Sleep(1000);51 行未改动 if(op==1){//up if(is_valid(x-1,y) && maze[x-1][y]!=3 && maze[x-1][y]!=0){ x--; cnt++; if(maze[x][y]==666){ if(maze[x][y]==666 && !bonus){ mp_start=chrono::high_resolution_clock::now(); have_map=true; bonus=true; }2 行未改动 else if(op==2){//down if(is_valid(x+1,y) && maze[x+1][y]!=3 && maze[x+1][y]!=0){ x++; cnt++; if(maze[x][y]==666){ if(maze[x][y]==666 && !bonus){ mp_start=chrono::high_resolution_clock::now(); have_map=true; bonus=true; }2 行未改动 else if(op==3){//left if(is_valid(x,y-1) && maze[x][y-1]!=3 && maze[x][y-1]!=0){ y--; cnt++; if(maze[x][y]==666){ if(maze[x][y]==666 && !bonus){ mp_start=chrono::high_resolution_clock::now(); have_map=true; bonus=true; }2 行未改动 else{//right if(is_valid(x,y+1) && maze[x][y+1]!=3 && maze[x][y+1]!=0){ y++; cnt++; if(maze[x][y]==666){ if(maze[x][y]==666 && !bonus){ mp_start=chrono::high_resolution_clock::now(); have_map=true; bonus=true; }20 行未改动 start=chrono::high_resolution_clock::now(); } auto mp_end=chrono::high_resolution_clock::now(); auto mp_duration=chrono::duration_cast<std::chrono::microseconds>(mp_end-mp_start); if(mp_duration.count()>50000000.0) if(mp_duration.count()>3000000.0) have_map=false; } auto end=chrono::high_resolution_clock::now(); auto duration=chrono::duration_cast<std::chrono::microseconds>(end-start); cout<<"WoW! You find the treasure! Congratulations!"<<endl; cout<<"Your time: "<<duration.count()/1000000.0<<"s"<<endl; cout<<"Your total step: "<<cnt<<endl; double mn_time=0.0; if(bonus) mn_time=(double)cnt/4.0; mn_time=(double)dis[edx][edy]/3.5; else mn_time=(double)dis[edx][edy]/3.0; double pts=((mn_time/(duration.count()/1000000.0))*100.0+((double)dis[edx][edy]/2.0)/((double)cnt/2.0)*100.0)/2; if(bonus)10 行未改动