https://github.com/robertograham/rleparser
Parse .rle files (Game of Life)
https://github.com/robertograham/rleparser
gameoflife rle run-length-encoding
Last synced: 4 months ago
JSON representation
Parse .rle files (Game of Life)
- Host: GitHub
- URL: https://github.com/robertograham/rleparser
- Owner: RobertoGraham
- License: mit
- Created: 2018-07-17T18:33:50.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-13T18:03:37.000Z (almost 7 years ago)
- Last Synced: 2023-07-28T10:10:51.171Z (almost 2 years ago)
- Topics: gameoflife, rle, run-length-encoding
- Language: Java
- Size: 40 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://maven-badges.herokuapp.com/maven-central/io.github.robertograham/rle-parser)
# RLEParser
Reads Game of Life .rle files## Install
```xmlio.github.robertograham
rle-parser
1.0.1```
## Usage
glider.rle
```
#C This is a glider.
x = 3, y = 3
bo$2bo$3o!
```
```java
import io.github.robertograham.rleparser.RleParser;
import io.github.robertograham.rleparser.domain.LiveCells;
import io.github.robertograham.rleparser.domain.PatternData;import java.net.URISyntaxException;
import java.util.stream.Collectors;
import java.util.stream.IntStream;public class Main {
public static void main(String[] args) throws URISyntaxException {
PatternData patternData = RleParser.readPatternData(Main.class.getClassLoader().getResource("glider.rle").toURI());System.out.println(IntStream.range(0, patternData.getMetaData().getHeight())
.mapToObj(patternData.getLiveCells()::filteredByY)
.map(filteredByY -> IntStream.range(0, patternData.getMetaData().getWidth())
.mapToObj(filteredByY::filteredByX)
.map(LiveCells::getCoordinates)
.map(coordinates -> coordinates.size() == 0 ? "." : "@")
.collect(Collectors.joining()))
.collect(Collectors.joining("\n")));
}
}
```
Prints:
```
.@.
..@
@@@
```