private void gewonnenVerloren() {//calculates if the game is over
        for (int index = 0; index < 4; index++) {
            for (int i = 0; i < 4; i++) {
                if (grid[index][i] >= 2048) {//if one of the numbers reached 2048, you won
                    ende = true;
                    JOptionPane.showMessageDialog(null, "Bravo sie haben gewonnen", "2048", JOptionPane.INFORMATION_MESSAGE);
                }
            }
        }
        int scoreBefore = score;//if you can't make any more moves and you haven't yet reached 2048, you lost
        if (!gridChanged(grid, up()) && !gridChanged(grid, down()) && !gridChanged(grid, right()) && !gridChanged(grid, left())) {
            ende = true;
            score = scoreBefore;
            JOptionPane.showMessageDialog(null, "Sie haben verloren", "2048", JOptionPane.INFORMATION_MESSAGE);
        }
        score = scoreBefore;
    }