Commit 8e7966a4 authored by Martin Lange's avatar Martin Lange
Browse files

changed image to openjdk:15, use gradlew

parent 1bc4bc28
Pipeline #12314 passed with stage
in 31 seconds
/code
/docs
/code
/docs
image: gradle:6.7.1-jdk15
variables:
YARNER_VERSION: 0.1.4
before_script:
- wget -O- https://github.com/mlange-42/yarner/releases/download/${YARNER_VERSION}/yarner-${YARNER_VERSION}-linux.tar.gz | tar xz
- export PATH="$PWD/yarner:$PATH"
build:
script:
- yarner
- cd code
- gradle build
- mv build/distributions/*.zip ..
- rm -rf .gradle build
artifacts:
paths:
- docs/
- code/
- "*.zip"
image: openjdk:15-jdk
variables:
YARNER_VERSION: 0.1.4
before_script:
- curl -L -o- https://github.com/mlange-42/yarner/releases/download/0.1.4/yarner-0.1.4-linux.tar.gz | tar xz
- export PATH="$PWD/yarner:$PATH"
build:
script:
- yarner
- cd code
- ./gradlew build
- mv build/distributions/*.zip ..
- rm -rf .gradle build
artifacts:
paths:
- docs/
- code/
- "*.zip"
SOFTWARE LICENSE
This tutorial and example demonstrates the use of
Entity-Component-Systems for the development of
individual-based models.
Copyright (c) 2020 Helmholtz-Zentrum f眉r Umweltforschung GmbH 鈥 UFZ
The code is a property of:
Helmholtz-Zentrum f眉r Umweltforschung GmbH 鈥 UFZ
Registered Office: Leipzig
Registration Office: Amtsgericht Leipzig
Trade Register Nr. B 4703
Chairman of the Supervisory Board: MinDirig'in Oda Keppler
Scientific Director: Prof. Dr. Georg Teutsch
Administrative Director: Dr. Sabine K枚nig
Authors and contact:
Martin Lange (martin.lange@ufz.de)
Adam Reichold
Henning Nolzen
Permoserstra脽e 15, D-04318 Leipzig, Germany
MIT License
Copyright (c) 2020 Helmholtz-Zentrum f眉r Umweltforschung GmbH 鈥 UFZ
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE LICENSE
This tutorial and example demonstrates the use of
Entity-Component-Systems for the development of
individual-based models.
Copyright (c) 2020 Helmholtz-Zentrum f眉r Umweltforschung GmbH 鈥 UFZ
The code is a property of:
Helmholtz-Zentrum f眉r Umweltforschung GmbH 鈥 UFZ
Registered Office: Leipzig
Registration Office: Amtsgericht Leipzig
Trade Register Nr. B 4703
Chairman of the Supervisory Board: MinDirig'in Oda Keppler
Scientific Director: Prof. Dr. Georg Teutsch
Administrative Director: Dr. Sabine K枚nig
Authors and contact:
Martin Lange (martin.lange@ufz.de)
Adam Reichold
Henning Nolzen
Permoserstra脽e 15, D-04318 Leipzig, Germany
MIT License
Copyright (c) 2020 Helmholtz-Zentrum f眉r Umweltforschung GmbH 鈥 UFZ
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This diff is collapsed.
[md]
# The sequence that identifies the start and end of a fenced code block
fence_sequence = "```"
# Alternative sequence that identifies the start and end of a fenced code block.
# Allows for normal Markdown fences in code blocks
fence_sequence_alt = "~~~"
# The sequence that separates the language from the name of the code block after the fence
block_name_start = " - "
# Parsed comments are stripped from the code and written to an `<aside></aside>` block after the code when printing.
# If false, the comments are just written back into the code.
comments_as_aside = false
# The sequence to identify a comment which should be omitted from the compiled code,
# and may be rendered as an `<aside>` if `comments_as_aside` is set.
comment_start = "///"
# The sequence to identify the start of a meta variable interpolation.
interpolation_start = "@{"
# The sequence to identify the end of a meta variable interpolation.
interpolation_end = "}"
# The sequence to identify the start of a macro invocation.
macro_start = "// ==> "
# The sequence to identify the end of a macro invocation.
macro_end = "."
# The sequence to identify the start of a transclusion.
transclusion_start = "@{{"
# The sequence to identify the end of a transclusion.
transclusion_end = "}}"
# The sequence to split variables into name and value.
variable_sep = ":"
# Prefix for file-specific entry points.
file_prefix = "file:"
# Name prefix for code blocks not shown in the docs.
hidden_prefix = "hidden:"
## The language to set if there was no automatically detected language. Optional.
# default_language = "java"
[paths]
# Code output path.
code = "code/"
# Docs output path.
docs = "docs/"
# The input source file(s) as glob pattern(s).
files = ["README.md"]
# File(s) to include in code output (unprocessed), as glob pattern(s).
code_files = ["gradle/**/*"]
# Allows to modify paths of copied code files. Replaces path components. Optional.
code_paths = ["-"]
## File(s) to include in docs output (unprocessed), as glob pattern(s).
# doc_files = ["**/*.png", "**/*.jpg"]
## Entrypoint block name. Optional. If not supplied, unnamed code blocks are used.
entrypoint = "Main"
## Language-sprcific settings. Optional. Required for reverse mode.
## The language is determined by the extension of code output files.
## Example language settings for Rust:
# [language.java]
## Start of comments. Can be start of line or block comments.
# comment_start = "//"
### End of comments. Optional, only for block comments
## comment_end = "*/"
## Start of block labels.
# block_start = "<@"
## End of block labels.
# block_end = "@>"
## Replaces lines containing only whitespaces by blank lines, in code output. Defaults to true.
# clear_blank_lines = true
## Enforces code files to always end with a blank line. Defaults to true.
# eof_newline = true
[md]
# The sequence that identifies the start and end of a fenced code block
fence_sequence = "```"
# Alternative sequence that identifies the start and end of a fenced code block.
# Allows for normal Markdown fences in code blocks
fence_sequence_alt = "~~~"
# The sequence that separates the language from the name of the code block after the fence
block_name_start = " - "
# Parsed comments are stripped from the code and written to an `<aside></aside>` block after the code when printing.
# If false, the comments are just written back into the code.
comments_as_aside = false
# The sequence to identify a comment which should be omitted from the compiled code,
# and may be rendered as an `<aside>` if `comments_as_aside` is set.
comment_start = "///"
# The sequence to identify the start of a meta variable interpolation.
interpolation_start = "@{"
# The sequence to identify the end of a meta variable interpolation.
interpolation_end = "}"
# The sequence to identify the start of a macro invocation.
macro_start = "// ==> "
# The sequence to identify the end of a macro invocation.
macro_end = "."
# The sequence to identify the start of a transclusion.
transclusion_start = "@{{"
# The sequence to identify the end of a transclusion.
transclusion_end = "}}"
# The sequence to split variables into name and value.
variable_sep = ":"
# Prefix for file-specific entry points.
file_prefix = "file:"
# Name prefix for code blocks not shown in the docs.
hidden_prefix = "hidden:"
## The language to set if there was no automatically detected language. Optional.
# default_language = "java"
[paths]
# Code output path.
code = "code/"
# Docs output path.
docs = "docs/"
# The input source file(s) as glob pattern(s).
files = ["README.md"]
# File(s) to include in code output (unprocessed), as glob pattern(s).
code_files = ["gradle/**/*"]
# Allows to modify paths of copied code files. Replaces path components. Optional.
code_paths = ["-"]
## File(s) to include in docs output (unprocessed), as glob pattern(s).
# doc_files = ["**/*.png", "**/*.jpg"]
## Entrypoint block name. Optional. If not supplied, unnamed code blocks are used.
entrypoint = "Main"
## Language-sprcific settings. Optional. Required for reverse mode.
## The language is determined by the extension of code output files.
## Example language settings for Rust:
# [language.java]
## Start of comments. Can be start of line or block comments.
# comment_start = "//"
### End of comments. Optional, only for block comments
## comment_end = "*/"
## Start of block labels.
# block_start = "<@"
## End of block labels.
# block_end = "@>"
## Replaces lines containing only whitespaces by blank lines, in code output. Defaults to true.
# clear_blank_lines = true
## Enforces code files to always end with a blank line. Defaults to true.
# eof_newline = true
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
File mode changed from 100644 to 100755
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
# Appendix
This section describes code that is not vital for understanding the model or the ECS concept.
**Contents**
- [Graphics](#graphics)
- [Utilities](#utilities)
- [Gradle files](#gradle-files)
- [Git ignore file](#git-ignore-file)
## Graphics
The graphics system draws the amount of grass per cell by shades of green. Further, it draws searching grassers as orange triangles pointing in the direction of their heading, and grassing grassers as white rectangles.
```java
/// file:src/main/java/grassing/sys/Graphics.java
package grassing.sys;
import com.artemis.BaseEntitySystem;
import com.artemis.ComponentMapper;
import com.artemis.annotations.All;
import com.artemis.annotations.One;
import com.artemis.annotations.Wire;
import com.artemis.utils.IntBag;
import grassing.comp.*;
import grassing.res.Grass;
import grassing.util.FloatGrid;
import grassing.util.MathUtil;
import javax.swing.*;
import java.awt.*;
@All(Position.class)
public class Graphics extends BaseEntitySystem {
protected ComponentMapper<Position> position;
protected ComponentMapper<Movement> movement;
@Wire Grass grass;
private JPanel canvas;
final private int CELL_SIZE = 6;
public Graphics() {
super();
}
@Override
protected void initialize() {
var frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
canvas = new JPanel() {
@Override
public void paint(java.awt.Graphics g) {
Graphics.this.paint((Graphics2D)g);
}
};
var dim = new Dimension(grass.grass.width * CELL_SIZE, grass.grass.height * CELL_SIZE);
canvas.setPreferredSize( dim );
frame.add(canvas);
frame.pack();
frame.setVisible(true);
}
@Override
protected void processSystem() {
canvas.paintImmediately(0, 0, grass.grass.width * CELL_SIZE, grass.grass.height * CELL_SIZE);
}
void paint(Graphics2D g2d) {
FloatGrid grass = this.grass.grass;
int s = CELL_SIZE;
g2d.setBackground(Color.BLACK);
for(int y=0; y<grass.height; y++) {
for(int x=0; x<grass.width; x++) {
g2d.setPaint(new Color(0f, 0.7f * grass.get(x, y), 0f));
g2d.fillRect(x*s, y*s, s, s);
}
}
int[] x = new int[3];
int[] y = new int[3];
IntBag grassers = subscription.getEntities();
for (int i = 0; i < grassers.size(); i++) {
int entity = grassers.get(i);
var pos = position.get(entity);
var mov = movement.get(entity);
if(mov == null) {
g2d.setPaint(Color.WHITE);
g2d.fillRect((int) ((pos.x - 0.3f) * s), (int) ((pos.y - 0.3f) * s), (int) (0.6f * s), (int) (0.6f * s));
} else {
g2d.setPaint(Color.ORANGE);
var f = MathUtil.heading(mov.direction);
var r = MathUtil.heading(mov.direction + 0.5f * (float) Math.PI);
x[0] = (int) ((pos.x + f.x) * s);
y[0] = (int) ((pos.y + f.y) * s);
x[1] = (int) ((pos.x + 0.4f * r.x) * s);
y[1] = (int) ((pos.y + 0.4f * r.y) * s);
x[2] = (int) ((pos.x - 0.4f * r.x) * s);
y[2] = (int) ((pos.y - 0.4f * r.y) * s);
g2d.fillPolygon(x, y, 3);
}
}