Giter Site home page Giter Site logo

invasion's Introduction

Invasion

Invasion is a simulation of an alien invasion written in GO.

Aliens have flown to earth as a last-ditch attempt to find a habitable planet because they Destroyed their own fighting over land. Their spceship blows up in the atmosphere and they land scattered across the world in random cities.

Installation

Close this repo to your corresponding GOPATH and run go install .

Usage

invasion [OPTION] [NUM_ALIENS]

To run simulation with six aliens: $ invasion 6

Verbose logging: $ invasion -v 6

Specify a different worlds file: $ invasion -world=world_2.txt 6

  • worlds files must be located in the worlds folder

Run Tests

go test ./...

Simulation Requirements

If two aliens are in the same city they fight, destroy each other, destroy the city, and destroy any adjacent roads.

Runs for a max of 10,000 moves or until all aliens have been Destroyed.

Prints to the console each time aliens fight each other.

Prints what is left of the world at the end.

Assumptions

The aliens fight when first landing.

Aliens will always move in a direction available to them.

City Names do not contain spaces or equal signs (=)

Directions included are only "north", "south", "east" and "west". If you provide directions other than these the simulation will work but the road will only be available in one direction.

The input file could have overlapping streets such as two cities that have the same city "west" of them. Withe the exisitng functionaltiy the import function will just override the the previous street.

It is possible the city file contains no cities and the aliens do not land on any cities to start. In this situation the simulation runs 10,000 times skipping over all aiens and then completes with an empty output listing all the un-Destroyed cities. The program could be halted when no cities are present if that was the desired functionality.

Possible Improvements

Additional error handling for the parsing of the worlds file.

An end-to-end test suite could be added that provides an input file and hooks into the console buffer to examine the output.

invasion's People

Contributors

zarazan avatar

Watchers

 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.