Historical Background
The shield wall is a tactical war formation that dates back to at least 2500 BC. It consisted of warriors overlapping their shields with those of their companions to form a 'wall'. The appeal of the tactic comes from the fact that even the most unskilled warrior could fight in a wall as long as they had a shield and a weapon. Because of the proximity of the walls, there was little space to move around, and the battle usually became a shoving match fought with sharp weapons.
The Challenge
Your task is to create a program or function that, given two arrays/lists/vectors of warriors as input, decides the outcome of the battle. The lists will represent a single-line wall of shields, and they will follow a specific notation:
Vikings:
The nordic warriors had a fierce drive for battle. During the late 8th through the mid 11th centuries, Danish vikings invaded the kingdoms of Britain looking for riches and farmable land. For the purpose of this challenge, these are the vikings' warriors:
- The
J
arl: Usually found leading his men from the center of the wall, jarls were the leaders of the viking hordes. Takes 15 damage to die, and deals 2 damage per round. - The
B
erserker: Although fantasy has greatly twisted the image of the berserkers, these warriors were known to fight in a trance-like fury without any kind of protection other than their shields. Takes 6 damage to die, and deals 3 damage per round. - The
C
hieftain: Chieftains were rich men who had free men at their service. They'd usually have earned great glory and riches in battle. Takes 10 damage to die, and deals 2 damage per round. - The Free
M
en: Warriors that served a chieftain. They were sworn to fight for their lords until death. Takes 8 damage to die, and deals 1 damage per round. - The
S
kald: Skalds, usually translated as bards, were free men who were hired to write poems, stories or songs about the great deeds of the nordic warriors. Takes 8 damage to die, and gives each adjacent warrior 1 bonus damage. Skalds deal no damage. Warriors cannot gain more than 1 bonus damage this way.
Saxons:
The Saxons came to settle in Britain from continental Europe following the demise of the Roman Empire in the 5th century. For the purposes of this challenge, there are the saxons' warriors:
- The
E
arl: Ealdormen, commonly called Earls, were members of the higher nobility. They usually held great streches of land and had hundreds or even thousands of sworn men. Takes 20 damage to die, and deals 1 damage per round. - The
K
night: For lack of a better term, the knights were minor noblemen who owned some land. In most cases, knights were sworn servants to an Earl. Takes 10 damage to die, and deals 2 damage per round. - The
W
arrior: Common men, usually minor noblemen without land or peasants who served a knight. When adjacent to a Knight or Earl, warriors have a +1 damage bonus. Takes 8 damage to die, and deals 2 damage per round. - The
F
yrd: The Fyrd was a militia-like group of free men, usually poor farmers, who'd bring any weapon (or weapon-like farming implement) they had to fight in the wall. Takes 5 damage to die, and deals 1 damage per round. - The
P
riest: Priests were highly valued in early Saxon culture, being heralds of the words of God. Priests take 15 damage to die, and prevent up to 1 damage each adjacent warrior would be dealt. Priests deal no damage. Priests cannot prevent more than 1 damage to a warrior.
The Wall
Walls meet each other at their centers. Each round, each warrior assigns damage to the warrior directly in front of it or, if there's no living warrior in front of it, the diagonally adjacent living warrior with least health remaining. If there is a tie, choose the warrior closer to the edge of the wall.
Example:
Vikings
[M,M,M,B,B,C,J,C,B,B,M,M,M]
[F,F,F,W,W,K,E,K,W,W,F,F,F]
Saxons
To make matters easier, let's convert these walls into numbers:
Round 0:
M M M B B C J C B B M M M
[8,8,8,6,6,10,15,10,6,6,8,8,8]
[5,5,5,8,8,10,20,10,8,8,5,5,5]
F F F W W K E K W W F F F
Round 1: Notice that 2 of the Saxons' warriors are adjacent to Knights, so they have a +1 damage bonus.
M M M B B C J C B B M M M
[7,7,7,4,3,8,14,8,3,4,7,7,7]
| | | | | | || | | | | | |
[4,4,4,5,5,8,18,8,5,5,4,4,4]
F F F W W K E K W W F F F
Round 2:
M M M B B C J C B B M M M
[6,6,6,2,0,6,13,6,0,2,6,6,6]
| | | | | | || | | | | | |
[3,3,3,2,2,6,16,6,2,2,3,3,3]
F F F W W K E K W W F F F
Round 3: Remember to collapse the arrays to account for dead warriors. Also, notice that the 2 outermost Fyrd are now attacking the diagonally adjacent viking.
M M M B C J C B M M M
[4,5,4,0,4,12,4,0,4,5,4]
/| | | | | || | | | | |\
[2,2,2,1,0,4,14,4,0,1,2,2,2]
F F F W W K E K W W F F F
Round 4: Notice once again the saxon Warriors next to the Knights dealing 3 damage:
M M M C J C M M M
[2,4,1,2,11,2,1,4,2]
/| | | | || | | | |\
[2,1,1,0,2,12,2,0,1,1,2]
F F F W K E K W F F F
Round 5:
M M M C J C M M M
[1,3,0,0,10,0,0,3,1]
| | | | || | | | |
[1,0,0,0,10,0,0,0,1]
F F F K E K F F F
Round 6:
M M J M M
[1,2,9,2,1]
\| | |/
[0,8,0]
F E F
Rounds 7 and 8:
M M J M M M M J M M
[1,2,8,2,1] [1,2,8,2,1]
\|/ \|/
[4] [0]
E E
Output: Viking victory.
Rules:
- Default Loopholes apply.
- You can use any convenient IO method.
- This is code-golf, so shortest code (in bytes, per language) wins.
- You may not assume the lists will have the same length, but they will always be alignable at their centers (there will always be an odd number of warriors in each list if the lists are of different sizes).
- You may output any truthy/falsey value. Please specify in your answer the equivalents of "Viking/Saxon victory".
- The loser is determined when all the warriors of a wall are dead.
If you ever end up with walls that are not alignable during the code execution, align them as centrally as possible, leaving one extra warrior on the longer wall to the right side. E.g.:
[M,M,M,J,M,M,M] [K,E,K,W]; [B,B,B,J] [K,K,W,W,K,E,K,W,W,K,K]
Feel free to try and test your code with any setup of walls, not just the ones in the test cases.
Test Cases:
V: [M,M,B,C,B,C,J,C,B,C,B,M,M]
S: [F,F,W,K,W,K,E,K,W,K,W,F,F]
O: Viking victory.
------------------------------
V: [M,M,M,M,M,M,M,M,M,M]
S: [W,W,W,W,W,W,W,W,W,W]
O: Saxon victory.
------------------------------
V: [B,C,M,B,C,M,M,C,B,M,C,B,M]
S: [W,F,W,F,E,E,E,F,W,F,W]
O: Viking victory.
------------------------------
V: [B,B,B,J,B,B,B]
S: [W,W,W,W,K,K,K,E,K,K,K,W,W,W,W]
O: Saxon victory.
------------------------------
V: [J]
S: [E]
O: Viking victory.
------------------------------
V: [C,C,C,C,B,B,M,M,M,M,J,J,J,M,M,M,M,B,B,C,C,C,C]
S: [K,K,K,K,K,K,K,K,K,K,W,E,W,K,K,K,K,K,K,K,K,K,K]
O: Saxon victory.
------------------------------
V: [M,M,S,C,B,J,B,C,S,M,M]
S: [F,K,P,W,K,E,K,W,P,K,F]
O: Saxon victory.
------------------------------
V: [S,S,S,...,S]
S: [P,P,P,...,P]
O: UNDEFINED (since both priests and skalds deal no damage, you can output anything here.)
------------------------------
There are some historical inaccuracies. Feel free to point them out and I'll do my best to fix them.
(health, damage, damagebonus, protbonus)
) \$\endgroup\$