package task;
import java.util.Scanner;
public class Taskmigong {
public static void main(String[] args) {
String [][] map={{"#","#","#","#","#","#","#","#","#","#","#","#"},
{"#","O","#"," "," "," ","#"," "," ","#","#","#"},
{ "#"," ","#"," ","#"," "," "," ","#","#"," "," "},
{ "#"," ","#"," ","#"," ","#","#","#","#"," ","#"},
{"#"," "," "," ","#"," "," ","#","#"," "," ","#"},
{"#"," ","#","#","#"," "," "," ","#"," ","#","#"},
{ "#"," ","#","#","#","#","#"," ","#"," ","#","#"},
{"#"," ","#"," "," "," ","#"," ","#"," ","#","#"},
{"#"," ","#"," ","#","#"," "," ","#"," ","#","#"},
{"#"," ","#"," ","#","#"," ","#","#"," ","#","#"},
{ "#"," "," "," ","#","#"," "," "," "," "," ","#"},
{ "#","#","#","#","#","#","#","#","#","#","#","#"}
};
// int y=1,x=1;
// Scanner sc=new Scanner(System.in);
//
// while(true) {
// System.out.println("----------------------------------------");
//
// /* 打印地图 */
//
// for(int i=0;i<map.length;i++) {
// for(int j=0;j<map[i].length;j++) {
// System.out.print(map[i][j]);
// }System.out.println();
// }
//
// String input=sc.nextLine();
//
// if(input.equalsIgnoreCase("w")){
//// 上移一个位置,判断是否有墙
// if(map[y-1][x]=="#"){
// System.out.println("撞墙了");
////
// }else {
// //没有墙就把当前位置里面的值和上面一个位置的元素互换
// map[y][x]=" ";
// y--;
// map[y][x]="O";
////
// }
// }
// if(input.equalsIgnoreCase("s")){
//// 下移一个位置,判断是否有墙
// if(map[y+1][x]=="#"){
// System.out.println("撞墙了");
// }else {
// //没有墙就把当前位置里面的值和下面一个位置的元素互换
// map[y][x]=" ";
// y++;
// map[y][x]="O";
// }
// }
// if(input.equalsIgnoreCase("a")) {
//// 左移一个位置,判断是否有墙
// if(map[y][x-1]=="#"){
// System.out.println("撞墙了");
// }else {
// //没有墙就把当前位置里面的值和下面一个位置的元素互换
// map[y][x]=" ";
// x--;
// map[y][x]="O";
// }
// }
// if(input.equalsIgnoreCase("d")) {
//// 右移一个位置,判断是否有墙
// if(map[y][x+1]=="#"){
// System.out.println("撞墙了");
// }else {
// //没有墙就把当前位置里面的值和下面一个位置的元素互换
// map[y][x]=" ";
// x++;
// map[y][x]="O";
// }
// }
// if(y==2&&x==11) {
// System.out.println("通关了");
// break;
//
// }
//
//
// }
//
int x=1;
int y=1;
Scanner sc=new Scanner(System.in);
while(true) {
System.out.println("================");
Tool.printArray(map);
String input=sc.nextLine();
if(input.equalsIgnoreCase("w")) {
if(map[x-1][y]=="#") {
System.out.println("你撞墙了");
}else {
map[x][y]=" ";
x--;
map[x][y]="O";
}
}
if(input.equalsIgnoreCase("s")) {
if(map[x+1][y]=="#") {
System.out.println("你撞墙了");
}else {
map[x][y]=" ";
x++;
map[x][y]="O";
}
}
if(input.equalsIgnoreCase("a")) {
if(map[x][y-1]=="#") {
System.out.println("你撞墙了");
}else {
map[x][y]=" ";
y--;
map[x][y]="O";
}
}
if(input.equalsIgnoreCase("d")) {
if(map[x][y+1]=="#") {
System.out.println("你撞墙了");
}else {
map[x][y]=" ";
y++;
map[x][y]="O";
}
}
if(x==2&&y==11) {
System.out.println("通关了");
break;
}
}
}
}