public static int jiangli = 6;
public static int gao = 5;
public static int kuan = 7;
public static int[,] map = new int[gao, kuan];
public static Random random = new Random();
public static int[] jianglix = new int[jiangli];
public static int[] jiangliy = new int[jiangli];
public static int px = 0;
public static int py = 0;
public static int opx = 0;
public static int opy = 0;
public static int ey = gao - 1;
public static int ex = kuan - 1;
public static int huifu = 1;
public static int yanchip = 0;
public static bool yes = true;
public static bool bunengchi = false;
public static void Main()
public static void chushihua()
for (int i = 0; i < gao; i++)
for (int j = 0; j < kuan; j++)
for (int u = 0; u < jiangli; u++)
int randoma = random.Next(0, gao);
int randomb = random.Next(0, kuan);
if (map[randoma, randomb] == 1)
{ map[randoma, randomb] = 2; }
public static void huizhi()
for (int i = 0; i < gao; i++)
for (int j = 0; j < kuan; j++)
Console.ForegroundColor = ConsoleColor.Red;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.ForegroundColor = ConsoleColor.Cyan;
Console.ForegroundColor = ConsoleColor.Blue;
public static void kongzhi()
var fangxiang = Console.ReadKey(true);
case ConsoleKey.D: pyidong(0, 1); break;
case ConsoleKey.A: pyidong(0, -1); break;
case ConsoleKey.W: pyidong(-1, 0); break;
case ConsoleKey.S: pyidong(1, 0); break;
case ConsoleKey.O: yes = false; break;
public static void pyidong(int y, int x)
if (newy >= 0 && newy < gao && newx >= 0 && newx < kuan && map[newy, newx] != 0)
Console.WriteLine($"{newy},{newx} ok");
map[newy, newx] = map[py, px];
Console.WriteLine($"{py},{px} ");