Giter Site home page Giter Site logo

php-test-gol's Introduction

PHP Test

Consider a representation of a world as an n by n matrix. Each element in the matrix may contain 1 organism. Each organism lives, dies and reproduces according to the following set of rules:

  • If there are two or three organisms of the same type living in the elements surrounding an organism of the same, type then it may survive.

  • If there are less than two organisms of one type surrounding one of the same type then it will die due to isolation.

  • If there are four or more organisms of one type surrounding one of the same type then it will die due to overcrowding.

  • If there are exactly three organisms of one type surrounding one element, they may give birth into that cell. The new organism is the same type as its parents. If this condition is true for more then one species on the same element then species type for the new element is chosen randomly.

  • If two organisms occupy one element, one of them must die (chosen randomly) (only to resolve initial conflicts).

The world and initial distribution of organisms within it is defined by an XML file of the following format:

<?xml version="1.0" encoding="UTF­8"?>
<life>
    <world>
        <cells>n</cells> <!-- Dimension of the square "world" -->
        <species>m</species> <!-- Number of distinct species -->
        <iterations>4000000</iterations> <!-- Number of iterations to be calculated -->
    </world>
    <organisms>
        <organism>
            <x_pos>x</x_pos> <!-- x position -->
            <y_pos>y</y_pos> <!-- y position -->
            <species>t</species> <!-- Species type -->
        </organism>
    </organisms>
</life>

After iterations, the state of the world is to be saved in an XML file, out.xml, of the same format as the initial definition file.

php-test-gol's People

Contributors

tharos avatar miroslavhajek 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.