title: How to update a string that represents a map/level; trying to write a sokoban game
body: <p>So I am having all types of trouble trying to design/think about how this can be done. To display the idea better, I have something like this: </p>
  
  <pre><code>private String level =
        "#########\n"
      + "#     ..#\n"
      + "#       #\n"
      + "#       #\n"
      + "#   $ $ #\n"
      + "#       #\n"
      + "#  @    #\n"
      + "#########\n";
  </code></pre>
  
  <p>And I want to, for example, move the @ up.</p>
  
  <p>I want to keep it as simple as possible as it seems Im not able to do this, I thought about several ideas:</p>
  
  <ol>
  <li>If I know the dimension of the String I can treat it as an matrix or vector and simply do math (a 4x4 matrix I can add simply add 6 to the original position (2,2) to be 1 row below)</li>
  <li>I can make every line a string so it's somehow easier to move up and down</li>
  <li>This would be completly innefficient I think but I could make a single for loop where everything is printed everytime, so everything is "built" every time anything changes.</li>
  </ol>
  
  <p>The thing is that I just don't see how to update the string. I can think of the operations to know what should be moved and where, but I am either missing a concept or knowledge or is the wrong approach because I can't think of a way of translating the concept of: now delete this character in this position, and write this character in this other position.</p>
  
  <p>Worst part is I found 2 (I think) very good examples of code, but still can't see where they are updating the image:</p>
  
  <p><a href="http://zetcode.com/tutorials/javagamestutorial/sokoban/" rel="nofollow noreferrer">http://zetcode.com/tutorials/javagamestutorial/sokoban/</a></p>
  
  <p><a href="https://stackoverflow.com/questions/16319492/my-2d-game-sokoban-is-working-but-i-want-to-know-if-i-improve-the-design">my 2D game, Sokoban, is working, but I want to know if I improve the design</a></p>