Git Product home page Git Product logo

hamurabi's Introduction

Hamurabi

Hamurabi game implemented in C

Dependencies

Tested only on Macos with clang version 11.0 compiler and below dependencies.

  1. CMake >= 3.17 for building.
  2. Check 0.15.1 for running unit tests.

Building

  1. ./build.sh

NOTE: To enable debug builds with asan enabled do:

  1. ./build.sh "-DCMAKE_BUILD_TYPE=asan"

Similar for other sanitizers (check the CMakeLists.txt)

Testing

Note: Testing uses Check so make sure cmake can find it. By default generating hamurabi with Check test is turned off.

To enable it:

  1. rm -rf build/ && ./build.sh "-DDISABLE_TESTS=OFF"

Then run it:

  1. ./build.sh t

Running the Game

  1. ./build.sh r

Running the Game via Docker

  1. docker build -t hamurabi -f Dockerfile .
  2. docker run -it hamurabi

Game details

Original game source - doc/HMRABI.txt

player - ancient babylonian king Hammurabi.
resources - people, acres of land, bushels of grain.
rounds - 10 (unit = year)

A person can

  1. farm a set amount of land and produce grain.
  2. Buy a land from neighbors in exchange for grain.
  3. Die next round if not fed the previous round.

A grain can

  1. used to feed the people current round.
  2. planted next round.

Each round, an advisor mention

  1. current status of the city.
  2. prior years harvest.
  3. change in population.
  4. Series of questions:
    a. how many bushels of grain to spend on land.
    b. seeds.
    c. feeding the people.

The games variation is drive by random number.

For each round, the below are decided by random number. The min and max are enclosed in brackets.

  1. price of land (17 - 26 bushels per acre, bushel is a type of currency).
  2. amount of bushels.
  3. bushels eaten by rats.
  4. new people in city.
  5. possibility of plague reducing the population by half.

The game ends if any of the below condition satisfies:

  1. after 10 rounds
  2. entire population of city dies
  3. atleast 45% of population starve in a round

Development

In your local development, you can run ctags on the project to make it easy to jump around functions:

  1. ctags -R -a .

License

MIT License Copyright (c) 2022, 2023 beyonddream

hamurabi's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

abzwingten

hamurabi's Issues

fix cmake errors on Check on fresh build

from F54280 on r/C_programming - the default build scripts on my OSX machine gives:

-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.29.2")
CMake Error at cmake/FindCheck.cmake:43 (MESSAGE):
Could NOT find CHECK
Call Stack (most recent call first):
CMakeLists.txt:33 (find_package)

use base path syntax for includes

Currently include syntax uses relative path, "../include/hamurabi.h" in hamurabi.c
This change would convert them into base path relative.

Remove gpl'ed code from the repo

There is one file that is cribbed from git (header file to cause compilation error if unsafe c functions are called) which made the entire repo to be GPL'ed. I wanted to release this repo under less restrictive license like MIT or Apache 2, so remove the gpl'ed code so I can do that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.