Attack and Defend Bases

Prerequisites

  • List/array
  • Dictionary (Python)
  • If/else
  • For loop

Rules

Each player is randomly assigned to one of the two teams: red and blue. Each tile on the map is a base that can be taken by anyone. A player can occupy or attack a base by installing one or more gems on it.

Gems

There are 4 types of gems: Diamond, Emerald, Ruby and Sapphire. Each gem also has a power attribute. Gems are acquired by running the command dig. A gem is created and added to user's gems list. The power of the gem is a random number determined by user's current level.

Occupy a base

If you walk into a base that doesn't belong to any team, you can occupy it by deploying one gem. If the base belongs to opponent's team, you can take it over by deploying a gem that has higher power than the current gems combined.

Advanced

If you are a beginner then you just need to know how to process the two cases above. If you are an advanced coder, then you can deploy multiple gems, as long as the power values of all gems on the same base form a pattern. The values should either be a sequence, or multiple sequences. For example, the following combinations are all valid: [1], [3,4], [8,9,10], [3,3,3,4,4,4], [6,6,7,7,8,8]. When you deploy to an unoccupied base, you have to deploy gems that form such a pattern. If you deploy to a base that belongs to your own team and already has gems in it, you need to deploy gems so that the combined gems form a pattern. For example, the base already has [3,4], then you can add any of the following: [2], [5], [2,5], [3,4], [3,3,4,4], [2,2,3,4]. If you are deploying to an enemy base (attacking), then your own gems form the pattern, and the combined power value has to be greater than the existing ones.

Combined gem power

For a group of gems of mixed types, the combined power is just the sum of all gems. But if all gems are of the same type (e.g. all rubies), then the total power is multiplied by the number of gems. For example, 3 diamonds with power values of [3,4,5] has a combined power of 36, instead of 12.

Bombs

When you run dig command, there is a chance that you will get a bomb instead of a gem. You can use the bomb on opponent's base and all gems will have their power values decreased by the power value of the bomb. This weakens the opponent's base and make it easier for you to take over. For example, after using a bomb with power 2 on a base with gems [5,5,6,6], the gems are weakened to [3,3,4,4].

results matching ""

    No results matching ""