26 public class Mine implements TextRepresentable { |
26 public class Mine implements TextRepresentable { |
27 |
27 |
28 protected Cell[][] cells; |
28 protected Cell[][] cells; |
29 protected int sizeX; |
29 protected int sizeX; |
30 protected int sizeY; |
30 protected int sizeY; |
31 protected int waterLevel = 0; |
31 protected int waterLevel = 0; |
32 protected int flooding = 0; |
32 protected int flooding = 0; |
33 protected int robotWaterproof = 10; |
33 protected int robotWaterproof = 10; |
34 protected int growth = 25; |
34 protected int growth = 25; |
35 protected int razorsCount = 0; |
35 protected int razorsCount = 0; |
36 protected static Pattern minePattern = Pattern |
36 protected int lambdasAndHighOrderRocksStartCount = 0; |
37 .compile("(?s)(.*?)(\n\n(Water.*|Flooding.*|Waterproof.*|Trampoline.*|Growth.*|Razors.*)|$)"); |
37 protected static Pattern minePattern = Pattern |
38 protected static Pattern waterPattern = Pattern.compile("(?s).*(?<=.*Water )(\\d+).*"); |
38 .compile("(?s)(.*?)(\n\n(Water.*|Flooding.*|Waterproof.*|Trampoline.*|Growth.*|Razors.*)|$)"); |
39 protected static Pattern floodingPattern = Pattern.compile("(?s).*(?<=.*Flooding )(\\d+).*"); |
39 protected static Pattern waterPattern = Pattern.compile("(?s).*(?<=.*Water )(\\d+).*"); |
40 protected static Pattern waterproofPattern = Pattern.compile("(?s).*(?<=.*Waterproof )(\\d+).*"); |
40 protected static Pattern floodingPattern = Pattern.compile("(?s).*(?<=.*Flooding )(\\d+).*"); |
41 protected static Pattern growthPattern = Pattern.compile("(?s).*(?<=.*Growth )(\\d+).*"); |
41 protected static Pattern waterproofPattern = Pattern |
42 protected static Pattern razorsPattern = Pattern.compile("(?s).*(?<=.*Razors )(\\d+).*"); |
42 .compile("(?s).*(?<=.*Waterproof )(\\d+).*"); |
43 protected static Pattern trampolinePattern = Pattern |
43 protected static Pattern growthPattern = Pattern.compile("(?s).*(?<=.*Growth )(\\d+).*"); |
44 .compile("(?s).*?Trampoline ([A-I]) targets ([1-9]).*"); |
44 protected static Pattern razorsPattern = Pattern.compile("(?s).*(?<=.*Razors )(\\d+).*"); |
45 protected static String firstTrampolineRegexp = "(?s).*?Trampoline ([A-I]) targets ([1-9])"; |
45 protected static Pattern trampolinePattern = Pattern |
|
46 .compile("(?s).*?Trampoline ([A-I]) targets ([1-9]).*"); |
|
47 protected static String firstTrampolineRegexp = "(?s).*?Trampoline ([A-I]) targets ([1-9])"; |
46 |
48 |
47 public Mine(String text) { |
49 public Mine(String text) { |
48 fromText(text); |
50 fromText(text); |
49 if (findCells(OpenLambdaLift).size() != 0) |
51 if (findCells(OpenLambdaLift).size() != 0) |
50 throw new RuntimeException("Detected OpenLambdaLift in new map!"); |
52 throw new RuntimeException("Detected OpenLambdaLift in new map!"); |
51 if (findCells(MiningRobot).size() != 1) |
53 if (findCells(MiningRobot).size() != 1) |
52 throw new RuntimeException("New map does not contain a robot!"); |
54 throw new RuntimeException("New map does not contain a robot!"); |
53 if (findCells(ClosedLambdaLift).size() != 1) |
55 if (findCells(ClosedLambdaLift).size() != 1) |
54 throw new RuntimeException("New map does not contain a ClosedLambdaLift!"); |
56 throw new RuntimeException("New map does not contain a ClosedLambdaLift!"); |
|
57 lambdasAndHighOrderRocksStartCount = findCells(Lambda).size() + findCells(CellContent.HighOrderRock).size(); |
55 } |
58 } |
56 |
59 |
57 @Override |
60 @Override |
58 public String toText() { |
61 public String toText() { |
59 String text = ""; |
62 String text = ""; |