GithubHelp home page GithubHelp logo

stochastic-tribes's Introduction

stochastic-tribes

Background

I started this as my first real non-script python project. After learning in biology about Hardy-Weinberg equillibria, I was interested in exploring the circumstances in which these ideal conditions aren't met.

Description

The board is initialized with a random set of entities (referred to as hamsters in the code). Each entity has an age (visually size), a position, a bearing, and a single genetic constant (float between 0 and 1, visually color). For fun, I also gave them names popular in the early 20th century.

For each tick, each hamster moves, with components of movement determined by the bearing, nearby neighbors, and a random factor. Currently, all members are of the subclass "RacistHam," which are influenced more by neighbors of similar color. This produces rudimentary flocking.

Hamsters can also breed with nearby hamsters with a cooldown period, preferring those similar to their own color. The offspring will be the average color of the two parents. There is a local carrying capacity though, and if there are too many neighbors, or a parent is too old, it won't breed.

Over time, you can see "tribes" of one color form, and if two tribes collide, if their colors are close, they may mix, or if they are far, they may just cohabitate.

Status

The simulation isn't well balanced, and eventually the hamsters usually die out. Also, unlike more developed flocking algorithms, hamsters don't mind being highly compact.

The simulation is also very innefficient, and when a lot of hamsters are on the board, it will visibly slow down. The first thing to try to improve performance is to change the python lists holding the objects to sets. Because of the iterative nature, this should improve performance. There are also several places in the code where I'm sure there are unnecessary reads and searches made (object-orientation is dangerous for the unwary). I was considering reimplementing in C, and still may do so in the future.

Requirements

  • tkinter
  • Python 3 standard library

stochastic-tribes's People

Contributors

jer-irl avatar

Watchers

 avatar

Forkers

mettys

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.