Git Product home page Git Product logo

galactic-war-cdll's Introduction

Galactic War

Galactic War is a C program made by me in the 1st year of university that simulates a war between planets in a galaxy. The program uses a personal implementation of a circular doubly linked list to store the planets in the galaxy, and each planet has its own doubly linked list of shields. The program allows the user to add new planets to the galaxy at a specified index, delete existing planets from the galaxy, and attack other planets with a specified number of units. The program also provides a command to print the current state of the galaxy, including the name, number of shields, and number of destroyed planets for each planet. The purpose of this project was to get familiar with advanced data structures and implement them with no memory leaks.

Usage

Compile the program with "make" and run the resulting executable (./main). The program will prompt you to enter commands to manipulate the galaxy. Firstly, enter the number of commands you are going to run.

The following commands are supported:

  • ADD <planet_name> <planet_index> <number_of_shields>: adds a planet with the specified name and number of shields at the specified index in the galaxy.
  • BLH : deletes the planet at the specified index from the galaxy.
  • UPG <planet_index> <shield_index> <upgrade_value>: increases the value of the shield at the specified index for the planet at the specified index by the specified amount.
  • ATK <attacking_planet_index> <attacked_planet_index> <attack_units>: attacks the planet at the second specified index with the specified number of units from the planet at the first specified index. If the attack is successful (i.e. the target planet's shields are reduced to zero), the attacking planet will gain one destroyed planet.
  • PRT: prints the current state of the galaxy, including the name, number of shields, and number of destroyed planets for each planet.

Examples

Here are some examples of how to use the program:

9
ADD Earth 0 3
The planet Earth has joined the galaxy.
ADD Mars 1 2
The planet Mars has joined the galaxy.
ATK 0 1 2
PRT
0: Earth (3 shields, 0 destroyed planets)
1: Mars (0 shields, 1 destroyed planets)
ADD Earth 0 3
The planet Earth has joined the galaxy.
ADD Mars 1 2
The planet Mars has joined the galaxy.
ADD Venus 2 3
The planet Venus has joined the galaxy.
BLH 1
The planet Mars has been eaten by the vortex.
PRT
0: Earth (3 shields, 0 destroyed planets)
1: Venus (3 shields, 0 destroyed planets)

galactic-war-cdll's People

Contributors

eduardspirache 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.