title: Making a player move on 2D array game grid
body: <p>I am creating a game using a 10x10 2D array. The player starts at the top left hand corner indicated as "P" and the objective is to get the player to avoid obstacles to get to the treasure indicated as "T" located in the lower right corner.</p>
  
  <p>How would I go about making the player move about the grid using commands Up/Down/Left/Right? </p>
  
  <p>Would I use a for loop to count through the elements in the array to designate the move? </p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>import java.util.Scanner;
  import java.util.Random;
  
  public class Adventure {
  
  public static void main(String[] args) {
      char grid[][]= new char[10][10];
      Scanner move = new Scanner(System.in);
      System.out.println("Here is the current game board:");
      System.out.println("-------------------------------");
  
      for(int i=0; i&lt;grid.length; i++) {          
          for(int j=0; j&lt;grid.length; j++) {
              double random = Math.random();
              if(random &lt;=.05) {
                  grid[i][j]='*';
              }
              else if(random &gt; .06 &amp;&amp; random &lt;= .15) {
                  grid[i][j]='X';
              }
              else {
                  grid[i][j]='.';
              }
              grid[0][0]='P';
              grid[9][9]='T';
              System.out.print(grid[i][j]);
          }
          System.out.println("");         
      }           
          System.out.print("Enter your move (U/D/L/R)&gt;");
  }
  }
  </code></pre>