World Conquest Chronicles

World Conquest Chronicles

biohazardcore, v1.0

The library that implements the business logic of the puzzle game inspired by Conway's Game of Life and various block games.

Major version.

Features

  • models:
    • field settings:
      • storing:
        • size;
        • initial offset;
        • filling;
        • minimal count;
        • maximal count;
      • supporting of default values for some settings;
    • game settings:
      • storing:
        • primary field settings;
        • movable field part settings;
  • creating a field by its settings:
    • random filling of the generated field;
  • game business logic:
    • generating of random fields:
      • primary field;
      • movable field part;
    • operations with the movable field part:
      • moving;
      • rotating;
      • unioning with the primary field.

Installation

Clone this repository:

$ git clone https://github.com/thewizardplusplus/biohazardcore.git
$ cd biohazardcore

Install the library with the LuaRocks tool:

$ luarocks make

Examples

biohazardcore.Game:

local Size = require("lualife.models.size")
local Point = require("lualife.models.point")
local FieldSettings = require("biohazardcore.models.fieldsettings")
local GameSettings = require("biohazardcore.models.gamesettings")
local Game = require("biohazardcore.game")

math.randomseed(os.time())

local game = Game:new(GameSettings:new(
  FieldSettings:new(Size:new(11, 11), Point:new(0, 0), 0.4),
  FieldSettings:new(Size:new(3, 3), Point:new(4, 4), 0.5, 5, 5)
))
local counter = 0
repeat
  local action = math.floor(5 * math.random())
  local action_description
  if action == 0 then
    action_description = "move left"
    game:move(Point:new(-1, 0))
  elseif action == 1 then
    action_description = "move right"
    game:move(Point:new(1, 0))
  elseif action == 2 then
    action_description = "move top"
    game:move(Point:new(0, -1))
  elseif action == 3 then
    action_description = "move bottom"
    game:move(Point:new(0, 1))
  else
    action_description = "rotate"
    game:rotate()
  end
  print(string.format("step #%d: " .. action_description, counter + 1))

  local previous_field_part = game._field_part
  game:union()

  counter = counter + 1
until game._field_part ~= previous_field_part

Repository

Link: https://github.com/thewizardplusplus/biohazardcore/tree/v1.0.

Content: code.

License: MIT.