Tabletop Simulator

Tabletop Simulator

Dark Tower
Gazoxtahagen  [developer] Mar 5, 2017 @ 10:45am
The Algorithm
So here's a little bit about the research:

First, I'm the same person who programmed the Flash version of Dark Tower that exists on the Well of Souls website, which I wrote around 2002-2003. Back then, I had a working Tower. I'd found a paper written by a statistics professor (which I wish I'd kept) that had the algorithm all written out in a .txt file. My real-world tests proved them to be fairly accurate, and once I'd published my Flash version, there were only minor tweaks necessary based on feedback. I myself felt that maybe the Brigand count was a little off, but it turns out that anything less than an initial numerical superiority for Brigands, because of the one-for-me half-for-you system, results in a loss for Brigands almost always at 10 Warriors. In fact, I believe with the current algorithm that anything more than 24 Warriors in a non-Dark Tower battle is a guaranteed win; I wonder if the entire reason behind the starvation mechanic is to discourage carrying that many around.

I've also examined the code in the Java version that Michael Bommer wrote, and also the code in the Android version, DroidTower. It seems everyone's algorithm is slightly different, and I wonder (short of some drooling madman sitting in the corner spamming a $300 Tower ten thousand times... which may be what this professor did) if we'll ever know the actual board game's algorithm.

This is why it was a priority of mine to make the algorithm as accessible to you as possible. Hitting the Scripting button will bring up the code that runs the game (and are you people getting a bug like I am where the script is white type on a white screen?). All of the RNG functions are right at the top, under the section called USER SERVICEABLE PARTS. These odds are:

moveResult()
When the Move button is pressed:
10% Plague, 10% Lost, 10% Dragon, 20% Battle, 50% safe move

tombruinResult()
When the Tomb/Ruin button is pressed:
10% treasure, 20% empty, 70% battle

startingBrigands()
When the battle begins, the starting Brigand count is:
your Warriors plus 0 to 5 more

oddsOfVictory()
This is the most complicated formula. This basically takes the proportional delta between the Warriors and Brigands, and scales them up and down from a 50% victory with the same number, to a best-case Warrior percentage of 75% and a worst-case of 25%.

anyTreasure()
There's a 5% chance after a battle that you get jack squat...

goldAward()
...but if you do get some treasure, you start out with 10-20 bags of gold...

itemAward()
...and then perhaps a second item, if you don't already have it:
30% Key, 20% Sword, 10% Pegasus, 10% Wizard, and 30% nothing else

haggle()
The rulebook states "approximately a 50/50 chance of lowering the stated price..."
48% haggle success, 52% bazaar closed

finalScore()
Final score is 128 minus:
the sum of the moves it took to finish plus the warriors left alive at the end
Last edited by Gazoxtahagen; Mar 5, 2017 @ 11:55am
< >
Showing 1-2 of 2 comments
Gazoxtahagen  [developer] Mar 5, 2017 @ 2:50pm 
About the final score: I decided to factor the Scouts and the Pegasus out of the highest score scenario. If you were insanely lucky, you could finish Dark Tower in ten moves:

Move 1: MOVE, battle, win, get PEGASUS
2: BAZAAR, buy SCOUT
3: Use PEGASUS to FRONTIER
4: MOVE, LOST + SCOUT, TOMB, battle, win BRASS KEY
5: MOVE, LOST + SCOUT, LOST + SCOUT, LOST + SCOUT, LOST + SCOUT, FRONTIER
6: MOVE, LOST + SCOUT, TOMB, battle, win SILVER KEY
7: MOVE, LOST + SCOUT, LOST + SCOUT, LOST + SCOUT, LOST + SCOUT, FRONTIER
8: MOVE, LOST + SCOUT, TOMB, battle, win GOLD KEY
9: MOVE, LOST + SCOUT, LOST + SCOUT, LOST + SCOUT, LOST + SCOUT, FRONTIER
10: DARK TOWER, solve riddle, battle, VICTORY

You would even have 10 food left!

Since the odds of being LOST are 1 in 10, the odds of getting 16 LOSTs in a row are something like 1:1 quadrillion. And that's not factoring in the odds of winning all of the battles, scoring every key on the first TOMB try (approx. 1:16 of that happening)...

Let's just say solving in the theoretically-possible 10 move minimum is extremely unlikely! :tableflip:
Bishop Of Battle Nov 4, 2017 @ 9:56pm 
Hi Gazoxtahagen,

I have seen your youtube video on the dark tower which brought me here. Excellent work! I've been working in embedded software for over 17 years. It's possible although usually not easy to reverse engineer the math behind the algorithms by stepping through the program in simulation (given fair knowledge of the machine instructions of the processor involved). What would help in this situation is back when dark tower was released code optimization was probably not done. It was maybe all developed in assembly (most likely) which means a logical human constructed the assembly which would make reversing out the algorithms more likely (assuming they were a good software developer - functionalized the assembly). Has anyone tried to contact the inventor about this? Might be easier. Inventor got burned (from reading history on the game) ... but given that a great deal of time has passed. I wonder if he might see how much fan effort is going into his dream and possibly just give us the true algorithm. Why not...? I would. I would be impressed with all the fan work on a old project of mine.

Ah looked this subject on wikipedia the original inventors did not create Dark Tower... Hmm so we would be asking algorithm from Milton Bradley the bad actor. Hrm...

I guess the other thing would be the RNG method behind the dark tower.

After seeing this sordid history. I think you have done your best effort and things are probably good enough for this type of project. In fact I think you would be justified modifying the algorithm to better suit the spirit of the game given the history. Why duplicate the algorithm of the milton bradley inventor idea stealing dark tower machine? Heck contact the original guys and ask what they would use as the algorithm!

This is a very interesting project you picked - it sparked my interest - nice work!
Cheers ;)
< >
Showing 1-2 of 2 comments
Per page: 15 30 50