public void generateMap(WumpusGraphics wg) {
    if (!mapGenerated) { // ensure we only generate the map once
      // generate exactly one wumpus
      int wX, wY;

      graphics = wg;

      do {
        wX = (int)(Math.random() * 4);
        wY = (int)(Math.random() * 4);
      } while (!validWumpusCoord(wX, wY));
      
      map[wX][wY].addContent(Cell.WUMPUS);
      addAdjacentPercepts(wX, wY, Cell.STENCH);
      
      // generate exactly one gold piece
      map[(int)(Math.random() * 4)][(int)(Math.random() * 4)].addContent(Cell.GLITTER);
      
      // generate a pit on every cell that doesn't contain gold or a wumpus
      // with p = .2
      for (int i = 0; i < map.length; i++) {
        for (int j = 0; j < map[i].length; j++) {
          if (!map[i][j].contains(Cell.WUMPUS) && !map[i][j].contains(Cell.GLITTER)) {
            if (Math.random() <= 0.2 && validPitCoord(i, j)) {
              map[i][j].addContent(Cell.PIT);
              addAdjacentPercepts(i, j, Cell.BREEZE);
            }
          }
        }
      }
      wg.renderMap(map);
      mapGenerated = true;
    }
  }