game-of-life-modern-java

用现代工具和语言构造以 Java 实现的《人生游戏》。「Game Of Life implemented in Java with modern tools and language constructs」

  • 所有者: giorgiosironi/game-of-life-java-2016
  • 平台: BSD, Cross-platform, Linux, Mac, Solaris, Unix-like, Windows
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

Pure Java Game Of Life

This is an implementation of Conway's Game Of Life, a zero-player game featuring an infinite plane of square cells which evolve their state as alive or dead according to a finite set of rules:

  • Any live cell with fewer than two live neighbours dies, as if caused by under-population.
  • Any live cell with two or three live neighbours lives on to the next generation.
  • Any live cell with more than three live neighbours dies, as if by over-population.
  • Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

Sample screen from this application

(Game Of Life on Wikipedia)

The Game Of Life is a common kata to exercise in a code retreat, or to get your feet wet with a different technology. Keep the problem the same and change the conditions around it to cover new ground.

Technologies used

This project tries to take a modern approach to Java software development, producing a self-contained application which embeds everything needed to run on any JVM in a development, CI or production environment.

  • Java 8 with lambdas support
  • Gradle for build automation and dependency resolution (substitutes both Ant and Maven)
  • Jetty as an embedded server to respond to HTTP requests
  • Jersey for building the RESTful web service calculating new generations of a plane, using JAX-RS
  • Freemarker templating engine to build HTML
  • Log4j 2 for logging, encapsulated behind the interface slf4j.

On the testing side of things:

How to run

Clone the project, then run:

./gradlew

The Gradle Wrapper will install itself.

Run

./gradlew test

to run unit, property-based and Selenium tests.

Standalone

Then run

./gradlew installDist
cd build/install/game-of-life
bin/game-of-life

to install an instance in the build/ subfolder. Load [http://localhost:8080/planes/a-block-and-bar] in your browser to see the evolution of a test plane. The patterns featured in the sample are a stable block and a rotating bar, along with a lone cell vanishing after the first generation.

The plane shown is a configurable window of 10x10 cells having the plane origin as the top corner, but the underlying engine is capable of extending the plane dimensions automatically to use all available memory.

Inside a server

./gradlew war

will generate a WAR file at build/libs/game-of-life-*.war. This WAR file can be deployed inside a servlet container.

To check how the WAR file is working, run:

./gradlew jettyRunWar -i

which will spin up a temporary Jetty 6.x (very old) container and deploy the WAR inside it.

主要指标

概览
名称与所有者giorgiosironi/game-of-life-java-2016
主编程语言Java
编程语言Java (语言数: 3)
平台BSD, Cross-platform, Linux, Mac, Solaris, Unix-like, Windows
许可证MIT License
所有者活动
创建于2015-12-20 10:13:44
推送于2016-01-26 13:22:57
最后一次提交2016-01-25 14:35:12
发布数0
用户参与
星数57
关注者数10
派生数23
提交数109
已启用问题?
问题数0
打开的问题数0
拉请求数1
打开的拉请求数0
关闭的拉请求数1
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?