我们正在尝试构建一个机器人,为了让机器人了解他现在在哪里,我们将使用矩阵。
所以我在呼唤矩阵。java 没有任何主要内容。然后尝试使用 initMatrix,它只是给了我一个错误。
public class Matrix {
// Matrix creation
public String[][] maturix = new String[10][10];
// Recorded Position of the Robot
public int x=0;
public int y=10;
public int Ox;
public int Oy;
public String Orientation = "East"; //Initializing the robot East-oriented to help place Obstacles (either Walls or Sheep) and walking
public void initMatrix()
{
// Summary: E = Empty; G = Sheep; W = Wall; C = current position; F = Finishing Line; X = Null; U = Unknown
maturix[10][0] = "S"; //Starting Position
maturix[10][1] = "U";
maturix[10][2] = "U";
maturix[10][3] = "U";
maturix[10][4] = "U";
maturix[10][5] = "U";
maturix[10][6] = "U";
maturix[10][7] = "U";
maturix[10][8]= "U";
maturix[10][9] = "U";
maturix[10][10] = "U";
maturix[9][1] = "X";
maturix[9][2] = "U";
maturix[9][3] = "X";
maturix[9][4] = "U";
maturix[9][5] = "X";
maturix[9][6] = "U";
maturix[9][7] = "X";
maturix[9][8] = "U";
maturix[9][9] = "X";
maturix[9][10] = "U";
maturix[8][0] = "U";
maturix[8][1] = "U";
maturix[8][2] = "U";
maturix[8][3] = "U";
maturix[8][4] = "U";
maturix[8][5] = "U";
maturix[8][6] = "U";
maturix[8][7] = "U";
maturix[8][8] = "U";
maturix[8][9] = "U";
maturix[8][10] = "U";
maturix[7][0] = "U";
maturix[7][1] = "X";
maturix[7][2] = "U";
maturix[7][3] = "X";
maturix[7][4] = "U";
maturix[7][5] = "X";
maturix[7][6] = "U";
maturix[7][7] = "X";
maturix[7][8] = "U";
maturix[7][9] = "X";
maturix[7][10] = "U";
maturix[6][0] = "U";
maturix[6][1] = "U";
maturix[6][2] = "U";
maturix[6][3] = "U";
maturix[6][4] = "U";
maturix[6][5] = "U";
maturix[6][6] = "U";
maturix[6][7] = "U";
maturix[6][8] = "U";
maturix[6][9] = "U";
maturix[6][10] = "U";
maturix[5][0] = "U";
maturix[5][1] = "X";
maturix[5][2] = "U";
maturix[5][3] = "X";
maturix[5][4] = "U";
maturix[5][5] = "X";
maturix[5][6] = "U";
maturix[5][7] = "X";
maturix[5][8] = "U";
maturix[5][9] = "X";
maturix[5][10] = "U";
maturix[4][0] = "U";
maturix[4][1] = "U";
maturix[4][2] = "U";
maturix[4][3] = "U";
maturix[4][4] = "U";
maturix[4][5] = "U";
maturix[4][6] = "U";
maturix[4][7] = "U";
maturix[4][8] = "U";
maturix[4][9] = "U";
maturix[4][10] = "U";
maturix[3][0] = "U";
maturix[3][1] = "X";
maturix[3][2] = "U";
maturix[3][3] = "X";
maturix[3][4] = "U";
maturix[3][5] = "X";
maturix[3][6] = "U";
maturix[3][7] = "X";
maturix[3][8] = "U";
maturix[3][9] = "X";
maturix[3][10] = "U";
maturix[2][0] = "U";
maturix[2][1] = "U";
maturix[2][2] = "U";
maturix[2][4] = "U";
maturix[2][5] = "U";
maturix[2][6] = "U";
maturix[2][7] = "U";
maturix[2][8] = "U";
maturix[2][9] = "U";
maturix[2][10] = "U";
maturix[1][0] = "U";
maturix[1][1] = "X";
maturix[1][2] = "U";
maturix[1][3] = "X";
maturix[1][4] = "U";
maturix[1][5] = "X";
maturix[1][6] = "U";
maturix[1][7] = "X";
maturix[1][8] = "U";
maturix[1][9] = "X";
maturix[1][10] = "U";
maturix[0][0] = "U";
maturix[0][1] = "U";
maturix[0][2] = "U";
maturix[0][3] = "U";
maturix[0][4] = "U";
maturix[0][5] = "U";
maturix[0][6] = "U";
maturix[0][7] = "U";
maturix[0][8] = "U";
maturix[0][9] = "U";
maturix[0][10] = "5";
}
}
有任何想法吗?