<commit_before>package dk.itu.mario.level;

import java.util.Random;

import dk.itu.mario.MarioInterface.Constraints;
import dk.itu.mario.MarioInterface.GamePlay;
import dk.itu.mario.MarioInterface.LevelInterface;
import dk.itu.mario.engine.sprites.SpriteTemplate;
import dk.itu.mario.engine.sprites.Enemy;


public class MyLevel extends Level{
	//Store information about the level
	 public   int ENEMIES = 0; //the number of enemies the level contains
	 public   int BLOCKS_EMPTY = 0; // the number of empty blocks
	 public   int BLOCKS_COINS = 0; // the number of coin blocks
	 public   int BLOCKS_POWER = 0; // the number of power blocks
	 public   int COINS = 0; //These are the coins in boxes that Mario collect


	 	private static Random levelSeedRandom = new Random();
	    public static long lastSeed;

	    Random random;

        private GenerationValues values;
	    private int difficulty;
	    private int type;
		private int gaps;
		
		private int[][] heightmap;
		private int[] highestlevel;
		
		public MyLevel(int width, int height)
	    {
			super(width, height);
			heightmap = new int[width][2];
			highestlevel = new int[width];
	    }


		public MyLevel(int width, int height, long seed, int difficulty, int type, GamePlay playerMetrics, GenerationValues values)
	    {
	        this(width, height);
            this.values = values;
	        creat(seed, difficulty, type);
	    }

	    public void creat(long seed, int difficulty, int type)
	    {
	        this.type = type;
	        this.difficulty = difficulty;

	        lastSeed = seed;
	        random = new Random(seed);

	        //create the start location
	        int length = 0;
	        length += setFloor(0, width, true);

	        //create all of the medium sections
	        while (length < width - 64)
	        {
	            //length += buildZone(length, width - length);
//				length += buildStraight(length, width-length, false);
//				length += buildStraight(length, width-length, false);
//				length += buildHillStraight(length, width-length);
//				length += buildJump(length, width-length);
//				length += buildTubes(length, width-length);
//				length += buildCannons(length, width-length);
	        	
//	        	double hill = random.nextDouble() * values.getHillCoeff();
//	        	double straight = random.nextDouble() * (1 - values.getHillCoeff());
//	        	double hole = random.nextDouble() * values.getHoleCoeff();
//	        	
//	        	if (hill > straight && hill > hole)
//	        	{
//        			length += buildHillStraight(length, width-length);
//	        	}
//	        	else if (straight > hill && straight > hole)
//	        	{
//	        		int choice = random.nextInt(3);
//	        		switch(choice)
//	        		{
//	        		case 0:
//	        			length += buildStraight(length, width - length, false);
//        				break;
//        			case 1:
//        				length += buildCannons(length, width - length);
//        				break;
//        			case 2:
//        				length += buildTubes(length, width - length);
//        				break;
//        			}
//	        	}
//	        	else //if (hole > hill && hole > straight)
//	        	{
//	        		length += buildJump(length, width-length);
//	        	}
	        	
	        	length += setFloor(length, width - length, false);
	        }
        	
	        //set the end piece
	        int floor = height - 1 - random.nextInt(4);

	        xExit = length + 8;
	        yExit = floor;

	        // fills the end piece
	        for (int x = length; x < width; x++)
	        {
	            heightmap[x][0] = floor;
	            heightmap[x][1] = -1;
	            highestlevel[x] = floor;
	        }
	        
	        //Set hills
    		int nclusters = (int)(width / values.getHillClusterSize() * values.getHillCoeff());
	        for (int i = 0; i < nclusters; i++)
	        {
        		int xo = random.nextInt(xExit - 32) + 4;
        		int nhills = (int)(random.nextGaussian() * values.getAvgHillsInCluster()/2) + values.getAvgHillsInCluster();
        		for (int j = 0; j < nhills; j++)
        		{
        			//Pick an unused x as a starting point.
        			int x;
        			do {
        				x = (int)(random.nextGaussian() * values.getHillClusterSize()) + xo;
        			} while (heightmap[x][1] != -1);
        			//Pick an unused length l where x+l isn't used.
        			int l;
        			do {
        				l = random.nextInt(5) + 3;
        			} while (heightmap[x+l][1] != -1);
        			//Pick a height
        			int lev = highestlevel[x];
        			for (int k = 0; k < l; k++)
        			{
        				if (highestlevel[x+k] < lev) //silly counting downwards...
        					lev = highestlevel[x+k];
        			}
        			int h = lev - random.nextInt(3) - 2;
        			//Set the heights
        			heightmap[x][1] = h;
        			heightmap[x+l][1] = h;
        			for (int k = 0; k < l; k++)
        			{
        				highestlevel[x+k] = heightmap[x][1];
        			}
        		}
	        }
	        
	        //Set holes
	        for (int x = 10; x < xExit - 8; x++)
	        {
	        	
	        }
	        
	        fillMap();

	        if (type == LevelInterface.TYPE_CASTLE || type == LevelInterface.TYPE_UNDERGROUND)
	        {
	            int ceiling = 0;<commit_msg>fixed too many hills errors<commit_after>package dk.itu.mario.level;

import java.util.Random;

import dk.itu.mario.MarioInterface.Constraints;
import dk.itu.mario.MarioInterface.GamePlay;
import dk.itu.mario.MarioInterface.LevelInterface;
import dk.itu.mario.engine.sprites.SpriteTemplate;
import dk.itu.mario.engine.sprites.Enemy;


public class MyLevel extends Level{
	//Store information about the level
	 public   int ENEMIES = 0; //the number of enemies the level contains
	 public   int BLOCKS_EMPTY = 0; // the number of empty blocks
	 public   int BLOCKS_COINS = 0; // the number of coin blocks
	 public   int BLOCKS_POWER = 0; // the number of power blocks
	 public   int COINS = 0; //These are the coins in boxes that Mario collect


	 	private static Random levelSeedRandom = new Random();
	    public static long lastSeed;

	    Random random;

        private GenerationValues values;
	    private int difficulty;
	    private int type;
		private int gaps;
		
		private int[][] heightmap;
		private int[] highestlevel;
		
		public MyLevel(int width, int height)
	    {
			super(width, height);
			heightmap = new int[width][2];
			highestlevel = new int[width];
	    }


		public MyLevel(int width, int height, long seed, int difficulty, int type, GamePlay playerMetrics, GenerationValues values)
	    {
	        this(width, height);
            this.values = values;
	        creat(seed, difficulty, type);
	    }

	    public void creat(long seed, int difficulty, int type)
	    {
	        this.type = type;
	        this.difficulty = difficulty;

	        lastSeed = seed;
	        random = new Random(seed);

	        //create the start location
	        int length = 0;
	        length += setFloor(0, width, true);

	        //create all of the medium sections
	        while (length < width - 64)
	        {
	            //length += buildZone(length, width - length);
//				length += buildStraight(length, width-length, false);
//				length += buildStraight(length, width-length, false);
//				length += buildHillStraight(length, width-length);
//				length += buildJump(length, width-length);
//				length += buildTubes(length, width-length);
//				length += buildCannons(length, width-length);
	        	
//	        	double hill = random.nextDouble() * values.getHillCoeff();
//	        	double straight = random.nextDouble() * (1 - values.getHillCoeff());
//	        	double hole = random.nextDouble() * values.getHoleCoeff();
//	        	
//	        	if (hill > straight && hill > hole)
//	        	{
//        			length += buildHillStraight(length, width-length);
//	        	}
//	        	else if (straight > hill && straight > hole)
//	        	{
//	        		int choice = random.nextInt(3);
//	        		switch(choice)
//	        		{
//	        		case 0:
//	        			length += buildStraight(length, width - length, false);
//        				break;
//        			case 1:
//        				length += buildCannons(length, width - length);
//        				break;
//        			case 2:
//        				length += buildTubes(length, width - length);
//        				break;
//        			}
//	        	}
//	        	else //if (hole > hill && hole > straight)
//	        	{
//	        		length += buildJump(length, width-length);
//	        	}
	        	
	        	length += setFloor(length, width - length, false);
	        }
        	
	        //set the end piece
	        int floor = height - 1 - random.nextInt(4);

	        xExit = length + 8;
	        yExit = floor;

	        // fills the end piece
	        for (int x = length; x < width; x++)
	        {
	            heightmap[x][0] = floor;
	            heightmap[x][1] = -1;
	            highestlevel[x] = floor;
	        }
	        
	        //Set hills
    		int nclusters = (int)(width / values.getHillClusterSize() * values.getHillCoeff());
	        for (int i = 0; i < nclusters; i++)
	        {
        		int xo = random.nextInt(xExit - 64) + 4;
        		int nhills = (int)(random.nextGaussian() * values.getAvgHillsInCluster()/2) + values.getAvgHillsInCluster();
        		for (int j = 0; j < nhills; j++)
        		{
        			//Pick an unused x as a starting point.
        			int x;
                    int t = 0;
                    boolean toContinue = false;
        			do {
                        do{
        				    x = (int)(random.nextGaussian() * values.getHillClusterSize()) + xo;
                        }while (x < 0);
                        t++;
                        if(t > 50){
                            toContinue = true;
                        }

        			} while (heightmap[x][1] != -1 && !toContinue);
        			//Pick an unused length l where x+l isn't used.
        			int l;
                    t = 0;
        			do {
        				l = random.nextInt(5) + 3;
                        t++;
                        if(t > 50){
                            toContinue = true;
                        }
        			} while (heightmap[x+l][1] != -1 && ! toContinue);
        			//Pick a height
                    if(toContinue){
                        continue;
                    }
        			int lev = highestlevel[x];
        			for (int k = 0; k < l; k++)
        			{
        				if (highestlevel[x+k] < lev) //silly counting downwards...
        					lev = highestlevel[x+k];
        			}
        			int h = lev - random.nextInt(3) - 2;
        			//Set the heights
        			heightmap[x][1] = h;
        			heightmap[x+l][1] = h;
        			for (int k = 0; k < l; k++)
        			{
        				highestlevel[x+k] = heightmap[x][1];
        			}
        		}
	        }
	        
	        //Set holes
	        for (int x = 10; x < xExit - 8; x++)
	        {
	        	
	        }
	        
	        fillMap();

	        if (type == LevelInterface.TYPE_CASTLE || type == LevelInterface.TYPE_UNDERGROUND)
	        {
	            int ceiling = 0;
{'fraction_non_alphanumeric': 0.12128579146407348, 'fraction_numerical': 0.008553934810012606, 'mean_word_length': 1.5254661209640745, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4651414', 'n_tokens_mistral': 3830, 'n_tokens_neox': 3397, 'n_words': 885}