Class RandomTextMapGenerator

java.lang.Object
randomGenerators.map.MapGenerator
randomGenerators.map.RandomTextMapGenerator

public class RandomTextMapGenerator extends MapGenerator
This class generates random text-based maps based on the RandomMapGenerator class. It provides functionality to generate text-based maps with random content.
  • Constructor Details

    • RandomTextMapGenerator

      public RandomTextMapGenerator(int maxHeight, int maxWidth)
      Constructs a RandomTextMapGenerator with the specified maximum height and width.
      Parameters:
      maxHeight - The maximum height of the generated text-based maps.
      maxWidth - The maximum width of the generated text-based maps.
  • Method Details

    • writeMapAway

      public static String writeMapAway (List<String> lines, String fileName)
      Creates a new .txt document in the actual maps directory with the map name, and stores the file path of that document in a string.
      Parameters:
      fileName - The name of the file that will be created, with extension.
      lines - A list of strings, where each string is a row in the map.
      Returns:
      A string, that is the file path of the newly generated .txt file that has those lines as text.
    • generateRandomMap

      public String generateRandomMap()
      Generates a random text-based map file with ASCII characters.
      Specified by:
      generateRandomMap in class MapGenerator
      Returns:
      The file path of the generated text-based map file.
    • generateCustomTextMapOneLine

      public String generateCustomTextMapOneLine(String mapLine)
      Get a one-line text map, with the characters specified in the string.
      Parameters:
      mapLine - Only line of the text map u want to create
      Returns:
      String FilePath of the created textfile.
    • generateRandomValidCharRandomSizeTextMap

      public String generateRandomValidCharRandomSizeTextMap()
      Create a text file with the valid characters (M, P, W, 0 and F). The number of rows is randomly chosen. The number of columns differs for each row and is randomly chosen for each row as well. The number of times that each valid character occurs in the map is also randomly chosen.
      Returns:
      String Filepath of the generated text file.
    • generateRandomValidCharRectangularTextMap

      public String generateRandomValidCharRectangularTextMap(boolean justOnePlayerCheck, boolean foodPresentCheck, boolean sizeCheck)
      Create a text file with the valid characters (M, P, W, 0 and F). The number of rows is randomly chosen. The number of columns is the same for each row and is randomly chosen. If justOnePlayerCheck is true, the P can only occur in the map once. If foodPresentCheck is true, the F can only occur in the map one or more. Else, the number of times that each valid character occurs in the map is also randomly chosen. This method does not use the checkMap() method because it will alter the map until it passes all checks.
      Parameters:
      justOnePlayerCheck - True if the map can only have one P in it
      foodPresentCheck - True if the map should have at least one F in it
      sizeCheck - True if the map should have at least one row and one column
      Returns:
      Filepath of the generated text file as string.
    • mutateMap

      public List<String> mutateMap (String originalFilePath)
      This method mutates a map and writes the original and all mutated maps away. The mutating is done by taking each separate character in the map and replacing it with other each valid character. Thus, for each character in the map, there are mutated versions of the map where, in that exact position, the map contains any other valid character ('P', 'F', 'W', 'E', 'M') that was not there originally. If the map is still valid, the map is written away.
      Parameters:
      originalFilePath - FilePath of original map file to mutate, relative to the project.
      Returns:
      List of filepaths of original (in original fuzzlessons input directory) and newly created mutated maps (in actual maps directory).