Giter Site home page Giter Site logo

townsimulator's Introduction

Town Simulator

This was build for a college project to visualize concurrency (using mutexes) on resources.

In order to visualize we created a world where people are trying to build a town.

The thing is, each person has its own thread.

Simple demo

Example video

Details :

  • A* for pathfinding.
  • Dijkstra's algorithm to find the closest job (ex. A lumberjack will look for the closest tree to cut).
  • Mutex to lock resources (Ex. Tree, Building spot...).
  • MonoGame Framework for the Graphical layer.

What is it doing?

There are 3 types of NPCs : Buidlers, Carriers & Woodcutters.

  • The Builders go to a construction site to build.
  • The Carriers go get material from the town center to the construction sites needing it.
  • The Woodcutters go chop down tree and bring it back to the town center.

Each Villager is a thread, so in order to avoid concurrency problems, we use mutex & semaphores.

When something happens (ex. Wood arrived to the town center, a tree is cut, etc...), this is sent to all Villagers and they can either ignore it, or do something about it, depending on their type.

How can you interact?

God mode

  • Place objects using the mouse (as seen in the video)

    • Using left click will place the currently selected object (shown at the top left of the screen)
    • To change the object you press the corresponding keybind.
      • (T) Trees
      • (H) House construction sites
      • (R) Rocks
      • (W) Woodcutters
  • Show a NPC information

    • You can also right click on a NPC to check his state
      • what is his current state (ex. Walking)
      • where is he going (position)
      • what is his current task (ex. GoingToTree)

Created by:

townsimulator's People

Contributors

jpgdev avatar alexnault avatar

Watchers

James Cloos avatar  avatar

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.