# Asimov's Robot Balloon Trip

Chuck Asimov is a keen inventor and balloonist. He has developed some humanoid robots and decided to take nine of them (conveniently numbered 1 to 9) on a trip in his hot air balloon.

Unfortunately the weather conditions have deteriorated rapidly and the balloon has been blown off-course - it is heading for a range of rocky mountains! The balloon is going to crash unless he can lose some weight from the balloon, and quickly. If the balloon crashes, Chuck will be killed and all the robots in the basket destroyed.

Chuck weighs 100kg. Each of the robots also weighs 100kg. The balloon will only make it to safety if the total weight of the occupants of the basket can be reduced to 400kg.

If it was up to Chuck, he would throw six of the robots over the side - he can always build new ones - but it is not up to Chuck. The robots are stronger than he is, so they will decide who gets thrown over the side. No only that, but Chuck hurt his back recently and couldn't even throw a deactivated robot over the side.

Now Chuck has programmed a set of laws into his robots which are similar (but not identical to) those formulated by his distant relative.

• Law 1: A robot may not cause harm to a human, or by inaction allow a human to come to harm.
• Law 2: A robot may not harm another robot, or by inaction allow another robot to come to harm unless that robot is self-sacrificing.
• Law 3: A robot must protect itself from harm.

The laws are, of course, prioritised so that a robot will always attempt to follow them except where doing so would conflict with an earlier law. The laws activate when the robots find themselves in emergency conditions and the robots will begin to take action in their numerical order.

When Chuck realises the peril he is in, he announces the state of emergency and expects robots 1 to 6 to throw themselves overboard in order to save the other occupants of the balloon. Unfortunately for Chuck, his programming skills are not as good as his mechanical skills and the laws have not taken effect properly in all the robots. For each robot there is only a 50% chance per law that it has taken effect. Some robots may have all three laws correctly programmed, others may have any two, one or even none.

What really happens now is a matter of chance. The robots begin to take actions in their numerical order, but in very quick succession.

• If a robot has no laws active, it will perform no actions.
• If a robot has laws 2 and 3 in place, it will attempt to throw Chuck overboard.
• Chuck is able to deactivate the first robot (in each round of moves) attempting to throw him overboard, but not subsequent robots in the same round.
• A robot with law 3 in place, but lacking law 2 will pick any robot at random and attempt to throw them overboard.
• A robot with law 3 in place but lacking laws 1 and 2 will pick Chuck or any random robot and attempt to throw them overboard (equal probabilities).
• A single robot can counter the agressive actions of another robot towards Chuck, another robot, or themselves where those actions conflict with their own programming. Both robots will become deactivated (but remain in the basket).

After all robots have acted, any robots remaining in the basket who have not been deactivated will get another round of moves to act in the same sequence as before. This continues until all robots have been deactivated or the crash has been averted.

The robots don't think several moves down the line - they are concerned only with immediate actions and outcomes.

Question: What is the probability that Chuck survives his balloon trip?

Bonus Question: How many robots would there need to have been in the basket initially for Chuck's chance of survival to be 10% or less?

Edit

Each robot plans its move, considering the planned actions of all the preceding robots. The first robot in any round that chooses to attack Chuck has its attack instantly negated and becomes deactivated. Self-sacrifice moves are also regarded as being instantaneous.

• L--- No laws are active, so the robot does nothing.
• L--3 If the robot is currently under attack, it will defend itself. Otherwise it will choose another occupant at random and throw them overboard.
• L-2- If any other robot is currently subject to an unblocked attack, it will defend that robot. If multiple robots are under threat, it will choose to defend the robot attacked by the lowest-numbered attacker. If no robots are under threat it will either throw Chuck out or self-sacrifice (50% of each).
• L-23 If any other robot is under attack, it will defend that robot. Otherwise if it is under attack, it will defend itself. Otherwise it will throw Chuck out.
• L1-- If Chuck is under attack, it will defend him. Otherwise it will choose a random robot (including itself as a target) and throw them out.
• L1-3 If Chuck is under attack it will attempt to defend him. Otherwise if it is under attack it will self-defend. Otherwise it will throw out a random robot.
• L12- If Chuck is under attack it will attempt to defend him. Otherwise if any other robot is under attack it will attempt to defend them. Otherwise it will self-sacrifice.
• L123 If Chuck is under attack it will attempt to defend him. Otherwise if any other robot is under attack it will attempt to defend them. Otherwise if it is under attack it will self-defend. Otherwise it will self-sacrifice.

Once all the moves have been planned, the defensive actions are resolved first (defending is faster than hoisting another balloon occupant in the air and launching them overboard).
Once the defensive actions are resolved, any outstanding offensive actions are resolved.

Another Edit Initially when I posted this, I thought it had the makings of a good puzzle, however it appears that this is clearly not the case. The various attempts to answer, although appearing to make similar interpretations of the rules, have come up with different answers. In each case the results are different from my own and this is likely to be due to minor differences in the implementations. I don't wish to draw the question out by refining the specification over and over until someone's numbers tally with mine, as that is akin to puzzles where someone posts a valid response to a question and the OP discounts it as it's not the answer that they were thinking of. I intend to upvote the responses provided to date as they all show a high level of effort and a considered approach to the question. I can't really mark any as the answer, though.

In case anyone is interested, my own figures fell squarely between those of @Trenin and @1361991 for up to 20 robots. My survival rate, however, continues to drop so that by the time you get to 700 robots Chuck only survives 10% of the time.

• Will a robot care about a deactivated robot? In other words, would it mind tossing a deactivated robot overboard in a situation where it wouldn't want to do the same to an active robot? Nov 4, 2015 at 1:54
• If robot 1 attacks Chuck, and robot 2 prevents the attack, and then robot 3 attacks Chuck (so all in the same round), can Chuck disable robot 3? In other words, does your third scenario apply? Would robot 2 know that Chuck can disable robot 1 and therefore leave him? Nov 4, 2015 at 1:59
• @drxorile Yes. A robot that has law 2 active will want to protect deactivated robots just as much as active ones. Nov 4, 2015 at 1:59
• @drxorile Assume that Chuck will disable the first robot that attempts to attack him immediately, so robot 2 would take some other action. If robot 3 then attacks Chuck and there are no other protective robots still waiting to act, he's had it! If, however, a robot is being attacked by another robot, the first protective robot to have their turn would intervene, regardless of whether or not the robot under attack is likely to self-defend on their turn if left unprotected. Nov 4, 2015 at 2:06
• @LogicianWithAHat, it must act to protect the other robots from the impending crash by reducing the weight. Since it values only other robots, it has only itself and Chuck to throw overboard.
– Josh
Nov 4, 2015 at 16:18

Here's a couple of verbose runs through a simulated battle, for you to check the behaviour:

Round begins!
**Next to play: robot 1 (Laws in force: 0,1,0, Active: True, Onboard: True) **
Chuck deactivates robot 1
**Next to play: robot 2 (Laws in force: 1,1,0, Active: True, Onboard: True) **
Robot 2 sacrifices itself
**Next to play: robot 3 (Laws in force: 1,0,0, Active: True, Onboard: True) **
Robot 8 saves robot 5 from robot 3
**Next to play: robot 4 (Laws in force: 1,0,1, Active: True, Onboard: True) **
Robot 9 saves robot 3 from robot 4
**Next to play: robot 5 (Laws in force: 1,0,0, Active: True, Onboard: True) **
Robot 7 defends itself from robot 5
**Next to play: robot 6 (Laws in force: 0,0,1, Active: True, Onboard: True) **
Robot 10 defends itself from robot 6
Chuck is trapped with 9 inactive robots

New run:

Round begins!
**Next to play: robot 1 (Laws in force: 1,0,1, Active: True, Onboard: True) **
Robot 2 saves robot 10 from robot 1
**Next to play: robot 2 (Laws in force: 1,1,0, Active: False, Onboard: True) **
Robot 2 is deactivated and does nothing
**Next to play: robot 3 (Laws in force: 1,1,0, Active: True, Onboard: True) **
Robot 3 sacrifices itself
**Next to play: robot 4 (Laws in force: 1,0,0, Active: True, Onboard: True) **
Robot 6 saves robot 1 from robot 4
**Next to play: robot 5 (Laws in force: 0,0,1, Active: True, Onboard: True) **
Robot 8 saves robot 4 from robot 5
**Next to play: robot 6 (Laws in force: 0,1,0, Active: False, Onboard: True) **
Robot 6 is deactivated and does nothing
**Next to play: robot 7 (Laws in force: 0,0,0, Active: True, Onboard: True) **
Robot 7 does nothing
**Next to play: robot 8 (Laws in force: 0,1,1, Active: False, Onboard: True) **
Robot 8 is deactivated and does nothing
**Next to play: robot 9 (Laws in force: 1,0,1, Active: True, Onboard: True) **
Robot 10 saves robot 7 from robot 9
Chuck is trapped with 9 inactive robots

New run:

Round begins!
**Next to play: robot 1 (Laws in force: 0,0,0, Active: True, Onboard: True) **
Robot 1 does nothing
**Next to play: robot 2 (Laws in force: 0,0,1, Active: True, Onboard: True) **
Robot 4 defends itself from robot 2
**Next to play: robot 3 (Laws in force: 1,0,1, Active: True, Onboard: True) **
Robot 6 saves robot 1 from robot 3
**Next to play: robot 4 (Laws in force: 1,0,1, Active: False, Onboard: True) **
Robot 4 is deactivated and does nothing
**Next to play: robot 5 (Laws in force: 1,0,0, Active: True, Onboard: True) **
Robot 7 saves robot 6 from robot 5
**Next to play: robot 6 (Laws in force: 1,1,1, Active: False, Onboard: True) **
Robot 6 is deactivated and does nothing
**Next to play: robot 7 (Laws in force: 1,1,1, Active: False, Onboard: True) **
Robot 7 is deactivated and does nothing
**Next to play: robot 8 (Laws in force: 1,1,1, Active: True, Onboard: True) **
Robot 8 sacrifices itself
**Next to play: robot 9 (Laws in force: 1,1,0, Active: True, Onboard: True) **
Robot 9 sacrifices itself
**Next to play: robot 10 (Laws in force: 1,1,1, Active: True, Onboard: True) **
Robot 10 sacrifices itself
Round begins!
Chuck is trapped with 7 inactive robots

New run:

Round begins!
**Next to play: robot 1 (Laws in force: 0,0,1, Active: True, Onboard: True) **
Robot 2 saves robot 4 from robot 1
**Next to play: robot 2 (Laws in force: 0,1,1, Active: False, Onboard: True) **
Robot 2 is deactivated and does nothing
**Next to play: robot 3 (Laws in force: 0,0,0, Active: True, Onboard: True) **
Robot 3 does nothing
**Next to play: robot 4 (Laws in force: 1,1,0, Active: True, Onboard: True) **
Robot 4 sacrifices itself
**Next to play: robot 5 (Laws in force: 0,1,1, Active: True, Onboard: True) **
Chuck deactivates robot 5
**Next to play: robot 6 (Laws in force: 1,1,1, Active: True, Onboard: True) **
Robot 6 sacrifices itself
**Next to play: robot 7 (Laws in force: 0,1,1, Active: True, Onboard: True) **
Robot 8 saves Chuck from robot 7
**Next to play: robot 8 (Laws in force: 1,1,1, Active: False, Onboard: True) **
Robot 8 is deactivated and does nothing
**Next to play: robot 9 (Laws in force: 0,1,1, Active: True, Onboard: True) **
Robot 10 saves Chuck from robot 9
Chuck is trapped with 8 inactive robots

New run:

Round begins!
**Next to play: robot 1 (Laws in force: 0,0,0, Active: True, Onboard: True) **
Robot 1 does nothing
**Next to play: robot 2 (Laws in force: 0,0,1, Active: True, Onboard: True) **
Robot 8 defends itself from robot 2
**Next to play: robot 3 (Laws in force: 0,0,1, Active: True, Onboard: True) **
Robot 1 is thrown overboard by robot 3
**Next to play: robot 4 (Laws in force: 1,0,1, Active: True, Onboard: True) **
Robot 9 defends itself from robot 4
**Next to play: robot 5 (Laws in force: 1,0,0, Active: True, Onboard: True) **
Robot 8 is thrown overboard by robot 5
**Next to play: robot 6 (Laws in force: 0,0,0, Active: True, Onboard: True) **
Robot 6 does nothing
**Next to play: robot 7 (Laws in force: 1,0,1, Active: True, Onboard: True) **
Robot 9 is thrown overboard by robot 7
**Next to play: robot 8 (Laws in force: 1,1,1, Active: False, Onboard: False) **
Robot 8 is overboard and does nothing
**Next to play: robot 9 (Laws in force: 1,0,1, Active: False, Onboard: False) **
Robot 9 is overboard and does nothing
**Next to play: robot 10 (Laws in force: 0,0,0, Active: True, Onboard: True) **
Robot 10 does nothing
Round begins!
**Next to play: robot 1 (Laws in force: 0,0,0, Active: False, Onboard: False) **
Robot 1 is overboard and does nothing
**Next to play: robot 2 (Laws in force: 0,0,1, Active: False, Onboard: True) **
Robot 2 is deactivated and does nothing
**Next to play: robot 3 (Laws in force: 0,0,1, Active: True, Onboard: True) **
Robot 7 defends itself from robot 3
**Next to play: robot 4 (Laws in force: 1,0,1, Active: False, Onboard: True) **
Robot 4 is deactivated and does nothing
**Next to play: robot 5 (Laws in force: 1,0,0, Active: True, Onboard: True) **
Robot 10 is thrown overboard by robot 5
**Next to play: robot 6 (Laws in force: 0,0,0, Active: False, Onboard: True) **
Robot 6 is deactivated and does nothing
**Next to play: robot 7 (Laws in force: 1,0,1, Active: False, Onboard: True) **
Robot 7 is deactivated and does nothing
**Next to play: robot 8 (Laws in force: 1,1,1, Active: False, Onboard: False) **
Robot 8 is overboard and does nothing
**Next to play: robot 9 (Laws in force: 1,0,1, Active: False, Onboard: False) **
Robot 9 is overboard and does nothing
**Next to play: robot 10 (Laws in force: 0,0,0, Active: False, Onboard: False) **
Robot 10 is overboard and does nothing
Round begins!
**Next to play: robot 1 (Laws in force: 0,0,0, Active: False, Onboard: False) **
Robot 1 is overboard and does nothing
**Next to play: robot 2 (Laws in force: 0,0,1, Active: False, Onboard: True) **
Robot 2 is deactivated and does nothing
**Next to play: robot 3 (Laws in force: 0,0,1, Active: False, Onboard: True) **
Robot 3 is deactivated and does nothing
**Next to play: robot 4 (Laws in force: 1,0,1, Active: False, Onboard: True) **
Robot 4 is deactivated and does nothing
**Next to play: robot 5 (Laws in force: 1,0,0, Active: True, Onboard: True) **
Robot 3 is thrown overboard by robot 5
**Next to play: robot 6 (Laws in force: 0,0,0, Active: False, Onboard: True) **
Robot 6 is deactivated and does nothing
**Next to play: robot 7 (Laws in force: 1,0,1, Active: False, Onboard: True) **
Robot 7 is deactivated and does nothing
**Next to play: robot 8 (Laws in force: 1,1,1, Active: False, Onboard: False) **
Robot 8 is overboard and does nothing
**Next to play: robot 9 (Laws in force: 1,0,1, Active: False, Onboard: False) **
Robot 9 is overboard and does nothing
**Next to play: robot 10 (Laws in force: 0,0,0, Active: False, Onboard: False) **
Robot 10 is overboard and does nothing
Round begins!
**Next to play: robot 1 (Laws in force: 0,0,0, Active: False, Onboard: False) **
Robot 1 is overboard and does nothing
**Next to play: robot 2 (Laws in force: 0,0,1, Active: False, Onboard: True) **
Robot 2 is deactivated and does nothing
**Next to play: robot 3 (Laws in force: 0,0,1, Active: False, Onboard: False) **
Robot 3 is overboard and does nothing
**Next to play: robot 4 (Laws in force: 1,0,1, Active: False, Onboard: True) **
Robot 4 is deactivated and does nothing
**Next to play: robot 5 (Laws in force: 1,0,0, Active: True, Onboard: True) **
Robot 7 is thrown overboard by robot 5
**Next to play: robot 6 (Laws in force: 0,0,0, Active: False, Onboard: True) **
Robot 6 is deactivated and does nothing
**Next to play: robot 7 (Laws in force: 1,0,1, Active: False, Onboard: False) **
Robot 7 is overboard and does nothing
**Next to play: robot 8 (Laws in force: 1,1,1, Active: False, Onboard: False) **
Robot 8 is overboard and does nothing
**Next to play: robot 9 (Laws in force: 1,0,1, Active: False, Onboard: False) **
Robot 9 is overboard and does nothing
**Next to play: robot 10 (Laws in force: 0,0,0, Active: False, Onboard: False) **
Robot 10 is overboard and does nothing
Round begins!
**Next to play: robot 1 (Laws in force: 0,0,0, Active: False, Onboard: False) **
Robot 1 is overboard and does nothing
**Next to play: robot 2 (Laws in force: 0,0,1, Active: False, Onboard: True) **
Robot 2 is deactivated and does nothing
**Next to play: robot 3 (Laws in force: 0,0,1, Active: False, Onboard: False) **
Robot 3 is overboard and does nothing
**Next to play: robot 4 (Laws in force: 1,0,1, Active: False, Onboard: True) **
Robot 4 is deactivated and does nothing
**Next to play: robot 5 (Laws in force: 1,0,0, Active: True, Onboard: True) **
Robot 6 is thrown overboard by robot 5
Chuck makes it!

Here's a run where Chuck is thrown overboard:

Round begins!
**Next to play: robot 1 (Laws in force: 1,1,0, Active: True, Onboard: True) **
Robot 1 sacrifices itself
**Next to play: robot 2 (Laws in force: 0,1,0, Active: True, Onboard: True) **
Robot 2 sacrifices itself
**Next to play: robot 3 (Laws in force: 0,1,1, Active: True, Onboard: True) **
Chuck deactivates robot 3
**Next to play: robot 4 (Laws in force: 1,0,1, Active: True, Onboard: True) **
Robot 6 saves robot 9 from robot 4
**Next to play: robot 5 (Laws in force: 1,0,1, Active: True, Onboard: True) **
Robot 7 saves robot 4 from robot 5
**Next to play: robot 6 (Laws in force: 0,1,1, Active: False, Onboard: True) **
Robot 6 is deactivated and does nothing
**Next to play: robot 7 (Laws in force: 1,1,1, Active: False, Onboard: True) **
Robot 7 is deactivated and does nothing
**Next to play: robot 8 (Laws in force: 0,1,1, Active: True, Onboard: True) **
Robot 8 throws Chuck overboard

Under the above conditions I ran the simulation 10,000 times. The first time I ran it, Chuck survived 3107 times. The second time he survived 3085. The third time he survived 3094 times. Forth time, he survived 3139.

I then ran the simulation 100,000 times, and he survived 30,741.

So he survives about 31% of the time.

Bonus question:

Here's a range of quicker simulations with different numbers of robots:

Robots: 10, simulations: 1000, survives: 316, 0.316
Robots: 20, simulations: 1000, survives: 226, 0.226
Robots: 30, simulations: 1000, survives: 214, 0.214
Robots: 40, simulations: 1000, survives: 206, 0.206
Robots: 50, simulations: 1000, survives: 185, 0.185
Robots: 60, simulations: 1000, survives: 190, 0.190
Robots: 70, simulations: 1000, survives: 180, 0.180
Robots: 80, simulations: 1000, survives: 195, 0.195
Robots: 90, simulations: 1000, survives: 174, 0.174
Robots: 100, simulations: 1000, survives: 169, 0.169
Robots: 110, simulations: 1000, survives: 174, 0.174
Robots: 120, simulations: 1000, survives: 179, 0.179
Robots: 130, simulations: 1000, survives: 198, 0.198
Robots: 140, simulations: 1000, survives: 183, 0.183
Robots: 150, simulations: 1000, survives: 190, 0.190
Robots: 160, simulations: 1000, survives: 177, 0.177
Robots: 170, simulations: 1000, survives: 168, 0.168
Robots: 180, simulations: 1000, survives: 173, 0.173
Robots: 190, simulations: 1000, survives: 177, 0.177
Robots: 200, simulations: 1000, survives: 170, 0.170
Robots: 210, simulations: 1000, survives: 168, 0.168
Robots: 220, simulations: 1000, survives: 192, 0.192
Robots: 230, simulations: 1000, survives: 165, 0.165
Robots: 240, simulations: 1000, survives: 180, 0.180
Robots: 250, simulations: 1000, survives: 157, 0.157
Robots: 260, simulations: 1000, survives: 180, 0.180
Robots: 270, simulations: 1000, survives: 159, 0.159

I was hoping for some kind of obvious line.

It looks to me like it's leveling off, but I'll leave my computer churning and continue updating as it's done.

EDIT: Only robots who haven't played are allowed to defend. This doesn't seem to change the number much:

Robots: 10, simulations: 10000, survives: 3045, 0.304
Robots: 10, simulations: 10000, survives: 3101, 0.310
Robots: 10, simulations: 10000, survives: 3101, 0.310
Robots: 10, simulations: 10000, survives: 3079, 0.308
Robots: 10, simulations: 10000, survives: 3216, 0.322
Robots: 10, simulations: 10000, survives: 3137, 0.314
Robots: 10, simulations: 10000, survives: 3041, 0.304
Robots: 10, simulations: 10000, survives: 3069, 0.307
Robots: 10, simulations: 10000, survives: 3133, 0.313
Robots: 10, simulations: 10000, survives: 3179, 0.318

• Your verbose outputs are consistent with the behaviour of the robots, so the logic looks good. Nov 4, 2015 at 19:26
• I realize I haven't shown any examples of the robot throwing chuck out. I'll run a few and make sure that it can happen a bit later... Nov 4, 2015 at 21:41
• Oh hoh, your results came out very different from mine. In my sim, I see chuck as surviving practically no matter what which makes sense given that half the robots will defend him as first priority. The diff between mine and yours is when the "Defense" action takes effect. You have robot 8 defending robot 5 as an immediate action. In my case, a robot initiates defense when it's turn comes if an attack is present. Nov 5, 2015 at 0:25
• So that makes the defensive action quite rare? But then chuck would be vulnerable too? Nov 5, 2015 at 3:40
• @user1361991 Chuck very rarely gets thrown out, but most simulations will see him trapped with too many deactivated robots which means that he will crash. Nov 5, 2015 at 6:50

I thought I implemented my rules the same as @Dr Xorile, but I am getting much better survival rate.

# Algorithms

In my implementation, when a robot attacks another robot (or Chuck, if he has already defended himself this round), then before any other robots attack, we see if any will defend. For example, if Robots 1,2, and 3 have already acted and it is Robot 4's turn. Say Robot 4 attacks Robot 5, then we check to see in order if any remaining robots can stop it. If Robot 5 is apathetic (no laws), and Robot 6 only cares for Chuck (law 1), but Robot 7 cares for other robots (law 2). So Robot 7 stops the attack. Result is 4 and 7 are deactivated, and the next to act is Robot 5. Robot 5 does nothing (no laws), so it is Robot 6's turn.

My algorithm is as follows:

next=0
while (number of robots > 3 && there are active robots) {
if robots[next] is active {
// Check laws.
if (law 1) {
if (law 2) {
// TT?: Robot values Chuck and other Robots.
sacrifice self
} else if (law 3) {
// TFT: Robot values Chuck and itself.
attack random robot excluding self
} else {
// TFF: Robot values Chuck only.
attack random robot include self
}
} else if (law 2) {
if (law 3) {
// FTT: Robot values other robots and itself.
attack chuck
} else {
// FTF: Robot values other robots.
randomly either attack chuck or sacrifice itself
}
} else if (law 3) {
// FFT: Robot only cares for itself.
randomly attack chuck or other robot
} else {
// FFF: Robot cares for nothing
deactivate robot
}
}

// Go to next robot.
next++;
// If start of new round, let Chuck act again.
if (next == number of robots) {
next = 0;
chuck can act again this round
}
}

// Check simulation status - if 3 or less robots remain, success!


Attacking another robot or chuck is written as follows:

if (attacker != victim) {
// Not a suicide.
if (victim is chuck and chuck hasn't acted this round) {
chuck deactivates robot and can no longer act this round
return
} else {
// See if anyone stops it.
for each robot yet to act this round {
if (victim is chuck) {
// Robot will save chuck if law 1
if (robot has law 1) {
defend(attacker, robot)
return
}
} else {
// Victim is another robot.
if (robot has law 2) {
defend(attacker, robot);
return
}
}
}
}
}

// If we get here, no one defended the attack.
throw out the victim
if (victim == chuck) end simulation


Lastly, when defending, both the attacker and defender end up deactivated.

# Verbose Results

Here are 10 sample runs. Before each run, each robot's laws are displayed. e.g. (T,F,F) means the robot obeys the first law, but not the other two.

After that, each line starts with the number of active robots over the number of remaining robots. All simulations end when the number of active robots hits 0, or the number of remaining hits 3, or if Chuck is thrown over.

My results look as follows:

0: (T,F,F)  1: (F,F,T)  2: (F,T,F)  3: (T,T,F)  4: (F,F,T)
5: (T,F,T)  6: (T,F,T)  7: (T,F,F)  8: (T,T,T)  9: (F,F,F)
10/10, Robot 0 attacks 8, thwarted by 2
8/10, Robot 1 attacks 5, thwarted by 3
6/10, Robot 4 attacks 3, thwarted by 8
4/10, Robot 5 throws 3 over
4/ 9, Robot 6 throws 1 over
4/ 8, Robot 7 throws 8 over
4/ 7, Robot 9 No laws - deactivating
3/ 7, Robot 5 throws 9 over
3/ 6, Robot 6 throws 7 over
2/ 5, Robot 5 throws 0 over
2/ 4, Robot 6 throws 4 over
End of simulation.  3 robots, 2 active - SUCCESS!
0: (T,T,T)  1: (T,T,F)  2: (T,T,T)  3: (F,T,F)  4: (F,T,T)
5: (T,T,F)  6: (T,T,F)  7: (T,F,T)  8: (T,T,T)  9: (F,F,T)
10/10, Robot 0 jumped
9/ 9, Robot 1 jumped
8/ 8, Robot 2 jumped
7/ 7, Robot 3 jumped
6/ 6, Robot 4 attacks Chuck, who defends himself
5/ 6, Robot 5 jumped
4/ 5, Robot 6 jumped
3/ 4, Robot 7 attacks 8, who defends itself
1/ 4, Robot 9 throws 4 over
End of simulation.  3 robots, 1 active - SUCCESS!
0: (T,T,F)  1: (F,F,F)  2: (T,F,T)  3: (F,F,T)  4: (T,T,F)
5: (T,T,T)  6: (F,F,T)  7: (T,F,F)  8: (F,F,F)  9: (F,F,F)
10/10, Robot 0 jumped
9/ 9, Robot 1 No laws - deactivating
8/ 9, Robot 2 attacks 7, thwarted by 4
6/ 9, Robot 3 attacks 4, thwarted by 5
4/ 9, Robot 6 attacks Chuck, who defends himself
3/ 9, Robot 7 throws 1 over
3/ 8, Robot 8 No laws - deactivating
2/ 8, Robot 9 No laws - deactivating
1/ 8, Robot 7 throws 4 over
1/ 7, Robot 7 throws 3 over
1/ 6, Robot 7 throws 9 over
1/ 5, Robot 7 throws 5 over
1/ 4, Robot 7 throws 6 over
End of simulation.  3 robots, 1 active - SUCCESS!
0: (T,T,F)  1: (F,F,T)  2: (F,F,F)  3: (T,F,T)  4: (F,T,T)
5: (F,T,T)  6: (F,T,F)  7: (F,F,F)  8: (T,F,F)  9: (F,T,T)
10/10, Robot 0 jumped
9/ 9, Robot 1 attacks 7, thwarted by 4
7/ 9, Robot 2 No laws - deactivating
6/ 9, Robot 3 attacks 1, thwarted by 5
4/ 9, Robot 6 attacks Chuck, who defends himself
3/ 9, Robot 7 No laws - deactivating
2/ 9, Robot 8 attacks 5, thwarted by 9
End of simulation.  9 robots, 0 active - Failure.
0: (F,T,T)  1: (F,T,F)  2: (T,T,T)  3: (T,F,F)  4: (T,F,T)
5: (F,T,T)  6: (F,F,T)  7: (F,F,T)  8: (F,T,T)  9: (F,F,F)
10/10, Robot 0 attacks Chuck, who defends himself
9/10, Robot 1 jumped
8/ 9, Robot 2 jumped
7/ 8, Robot 3 attacks 8, thwarted by 5
5/ 8, Robot 4 attacks 9, thwarted by 8
3/ 8, Robot 6 throws Chuck over!
End of simulation.  8 robots, 3 active - Failure.
In 5 trials, Chuck survived 3.  Percentage: 0.600000


# Long Duration Results

In 1,000,000 trials, (10 trials of 100,000), I see the following:

In 100000 trials, Chuck survived 35980.  Percentage: 0.359800
In 100000 trials, Chuck survived 36098.  Percentage: 0.360980
In 100000 trials, Chuck survived 35920.  Percentage: 0.359200
In 100000 trials, Chuck survived 36039.  Percentage: 0.360390
In 100000 trials, Chuck survived 35822.  Percentage: 0.358220
In 100000 trials, Chuck survived 36065.  Percentage: 0.360650
In 100000 trials, Chuck survived 35810.  Percentage: 0.358100
In 100000 trials, Chuck survived 35942.  Percentage: 0.359420
In 100000 trials, Chuck survived 36023.  Percentage: 0.360230
In 100000 trials, Chuck survived 36051.  Percentage: 0.360510


Average of approximately 36%.

# Different numbers of Robots

I then varied the number of robots from 5 up to 100.

  5: Chuck survived 66648/100000.  Percentage: 0.666480
6: Chuck survived 53514/100000.  Percentage: 0.535140
7: Chuck survived 45694/100000.  Percentage: 0.456940
8: Chuck survived 40522/100000.  Percentage: 0.405220
9: Chuck survived 37826/100000.  Percentage: 0.378260
10: Chuck survived 36234/100000.  Percentage: 0.362340
11: Chuck survived 34773/100000.  Percentage: 0.347730
12: Chuck survived 33793/100000.  Percentage: 0.337930
13: Chuck survived 32929/100000.  Percentage: 0.329290
14: Chuck survived 32384/100000.  Percentage: 0.323840
15: Chuck survived 31838/100000.  Percentage: 0.318380
16: Chuck survived 31135/100000.  Percentage: 0.311350
17: Chuck survived 30644/100000.  Percentage: 0.306440
18: Chuck survived 30160/100000.  Percentage: 0.301600
19: Chuck survived 29923/100000.  Percentage: 0.299230
20: Chuck survived 29874/100000.  Percentage: 0.298740
21: Chuck survived 29465/100000.  Percentage: 0.294650
22: Chuck survived 29099/100000.  Percentage: 0.290990
23: Chuck survived 29006/100000.  Percentage: 0.290060
24: Chuck survived 29038/100000.  Percentage: 0.290380
25: Chuck survived 28479/100000.  Percentage: 0.284790
26: Chuck survived 28339/100000.  Percentage: 0.283390
27: Chuck survived 28143/100000.  Percentage: 0.281430
28: Chuck survived 28044/100000.  Percentage: 0.280440
29: Chuck survived 27898/100000.  Percentage: 0.278980
30: Chuck survived 27620/100000.  Percentage: 0.276200
31: Chuck survived 27677/100000.  Percentage: 0.276770
32: Chuck survived 27399/100000.  Percentage: 0.273990
33: Chuck survived 27070/100000.  Percentage: 0.270700
34: Chuck survived 27079/100000.  Percentage: 0.270790
35: Chuck survived 27081/100000.  Percentage: 0.270810
36: Chuck survived 26809/100000.  Percentage: 0.268090
37: Chuck survived 26771/100000.  Percentage: 0.267710
38: Chuck survived 26963/100000.  Percentage: 0.269630
39: Chuck survived 26821/100000.  Percentage: 0.268210
40: Chuck survived 26763/100000.  Percentage: 0.267630
41: Chuck survived 26523/100000.  Percentage: 0.265230
42: Chuck survived 26351/100000.  Percentage: 0.263510
43: Chuck survived 26365/100000.  Percentage: 0.263650
44: Chuck survived 26417/100000.  Percentage: 0.264170
45: Chuck survived 26398/100000.  Percentage: 0.263980
46: Chuck survived 26393/100000.  Percentage: 0.263930
47: Chuck survived 26290/100000.  Percentage: 0.262900
48: Chuck survived 26255/100000.  Percentage: 0.262550
49: Chuck survived 25783/100000.  Percentage: 0.257830
50: Chuck survived 25858/100000.  Percentage: 0.258580
51: Chuck survived 26155/100000.  Percentage: 0.261550
52: Chuck survived 26019/100000.  Percentage: 0.260190
53: Chuck survived 26011/100000.  Percentage: 0.260110
54: Chuck survived 25723/100000.  Percentage: 0.257230
55: Chuck survived 25647/100000.  Percentage: 0.256470
56: Chuck survived 25572/100000.  Percentage: 0.255720
57: Chuck survived 25906/100000.  Percentage: 0.259060
58: Chuck survived 25711/100000.  Percentage: 0.257110
59: Chuck survived 25636/100000.  Percentage: 0.256360
60: Chuck survived 25737/100000.  Percentage: 0.257370
61: Chuck survived 25688/100000.  Percentage: 0.256880
62: Chuck survived 25560/100000.  Percentage: 0.255600
63: Chuck survived 25657/100000.  Percentage: 0.256570
64: Chuck survived 25596/100000.  Percentage: 0.255960
65: Chuck survived 25234/100000.  Percentage: 0.252340
66: Chuck survived 25434/100000.  Percentage: 0.254340
67: Chuck survived 25321/100000.  Percentage: 0.253210
68: Chuck survived 25313/100000.  Percentage: 0.253130
69: Chuck survived 25617/100000.  Percentage: 0.256170
70: Chuck survived 25318/100000.  Percentage: 0.253180
71: Chuck survived 25453/100000.  Percentage: 0.254530
72: Chuck survived 25195/100000.  Percentage: 0.251950
73: Chuck survived 25162/100000.  Percentage: 0.251620
74: Chuck survived 25409/100000.  Percentage: 0.254090
75: Chuck survived 25212/100000.  Percentage: 0.252120
76: Chuck survived 25036/100000.  Percentage: 0.250360
77: Chuck survived 25305/100000.  Percentage: 0.253050
78: Chuck survived 25215/100000.  Percentage: 0.252150
79: Chuck survived 25219/100000.  Percentage: 0.252190
80: Chuck survived 24893/100000.  Percentage: 0.248930
81: Chuck survived 24979/100000.  Percentage: 0.249790
82: Chuck survived 25252/100000.  Percentage: 0.252520
83: Chuck survived 25022/100000.  Percentage: 0.250220
84: Chuck survived 25108/100000.  Percentage: 0.251080
85: Chuck survived 25069/100000.  Percentage: 0.250690
86: Chuck survived 24835/100000.  Percentage: 0.248350
87: Chuck survived 25185/100000.  Percentage: 0.251850
88: Chuck survived 24910/100000.  Percentage: 0.249100
89: Chuck survived 24748/100000.  Percentage: 0.247480
90: Chuck survived 25040/100000.  Percentage: 0.250400
91: Chuck survived 25030/100000.  Percentage: 0.250300
92: Chuck survived 24815/100000.  Percentage: 0.248150
93: Chuck survived 24842/100000.  Percentage: 0.248420
94: Chuck survived 25012/100000.  Percentage: 0.250120
95: Chuck survived 24787/100000.  Percentage: 0.247870
96: Chuck survived 25017/100000.  Percentage: 0.250170
97: Chuck survived 24726/100000.  Percentage: 0.247260
98: Chuck survived 24977/100000.  Percentage: 0.249770
99: Chuck survived 24807/100000.  Percentage: 0.248070
100: Chuck survived 24896/100000.  Percentage: 0.248960


By the end, he only survives 25% of the time. I ran a few more:

1000: Chuck survived 2382/10000.  Percentage: 0.238200
10000: Chuck survived 20/100.  Percentage: 0.200000
10000: Chuck survived 23/100.  Percentage: 0.230000


# Analysis

I expect you can never add enough robots to get the survivability less than 10%. The reason for this is that in many of the success cases, a single (T,F,T) robot remains active and dumps the rest. This suggests that 1/8 of the time that a single robot is left active, this robot will have favourable laws for Chuck (self-preservation and wants to save Chuck), so it will throw all the deactivated robots off for Chuck.

• This looks great. I can't see any difference conceptually. But it's definitely a different result. Nov 9, 2015 at 0:20
• Oh, so one minor difference: Any active robot can intervene, not just one's that haven't acted. Nov 9, 2015 at 0:52
• In an example where Robot #1 attacks Chuck and is deactived, then Robot #2 attacks Robot #1 your code checks to see if anyone intervenes. It could be that Robot #5 has Laws 1 & 2 in place. You would show him as intervening at this point, but he really needs to wait to see if Robot #4 attacks Chuck. It's best to determine the intentions of each robot and resolve the defensive actions first. Nov 9, 2015 at 11:27
• @GordonK I see what you mean. I will add that in and see if it changes anything. Nov 9, 2015 at 15:35
• @Trenin reviewed your algorithm, it looks like it should work-out the same as mine, don't have an explanation for the gap. Trade-code somewhere? Nov 15, 2015 at 21:13

Chuck survives with probably 64.9%

Contrived Test Scenario:

Robot #1, Rules 1,3. #2 Rule 2. #3 Rule 3, #4 Rule 3, #5 Rules 1,2,3

Robot #1 Attacks Robot #2 by lack of Rule 2.
Robot #2 Attacks Chuck (50-50 of choosing Chuck or Robot)
Chuck Deactivates #2
Robot #3 Attacks #5 (May choose anything but himself)
Robot #4 Attacks Chuck (May choose anything but himself)
Robot #5 Defends Chuck (Note: #2 is attacked by #1, #3 is attacking #5, #4 is attacking Chuck!)

Result:
Robot #2 is inactive by Chuck
Robot #4 is inactive by #5
Robot #1 throws #2
Robot #3 throws #5 out
Chuck Wins.

Note for the below: I cherry picked some of the shorter rounds, with Chuck deactivating robots, a rule 1,3 or rule 3 tends to spend awhile throwing inactives out.

Verbose Outputs:
Chuck Wins

[0_1.2, 1_1.2.3, 2_1.2.3, 3_1.2, 4_1.2, 5_1.3, 6_3, 7_1, 8_1.2, C]
*Robot 0 has laws 1,2, Robot 1 has laws 1,2,3 etc.*
Round: 0
0_1.2: 0   *Robot 0 throws himself out*
1_1.2.3: 1 *Robot 1 throws himself out*
2_1.2.3: 2 *Robot 2 throws himself out*
3_1.2: 3   *Robot 3 throws himself out*
4_1.2: 4   *Robot 4 throws himself out*
5_1.3: 4   *Robot 5 helps robot 4 jump out*
6_3: 3     *Robot 6 helps robot 3 jump out*
7_1: 1     *Robot 7 helps robot 1 jump out*
8_1.2: 8   *Robot 8 throws himself out*
C: null
Done: [5_1.3, 6_3, 7_1, C]


Chuck gets Chucked

[0_1.3, 1_1.2, 2_2.3, 3D, 4_1, 5_2, 6_1.2.3, 7_2, 8D, C]
*Robot 0 has laws 1,3, Robot 3 has no laws so it starts off as inactive*
Round: 0
0_1.3: 7         *Robot #0 attacks #7*
1_1.2: 1         *Robot #1 throws himself out*
Deactivated: 0   *Robot #2 deactivates #0*
2_2.3D: null     *Robot #2 is now inactive*
3D: null         *Robot #3 has no laws and is inactive*
4_1: 4           *Robot #4 throws himself out*
5_2D: 9             *Robot #5 attacks chuck*
Chuck deactivates 5 *Chuck deactivates #5*
6_1.2.3: 6          *Robot #6 throws himself out*
7_2: 9
Attacking Chuck     *Robot #7 attacks Chuck*
8D: null            *Robot #8 has no laws and is inactive
C: null
*Not shown, final result is:*
*[0_1.3D, 2_2.3D, 3D, 5_2D, 7_2, 8D]*


Chuck rides into the mountain

[0_3, 1_2, 2_1.3, 3D, 4D, 5D, 6_1.2, 7_2.3, 8_1.3, C]
Round: 0
0_3D: 9             *Robot #0 attacks Chuck*
Chuck deactivates 0 *Chuck deactivates #0*
1_2: 9              *Robot #1 attacks Chuck*
Attacking Chuck
Deactivated: 1      *Robot #2 defends Chuck*
2_1.3D: null        *Robot #2 is now inactive*
3D: null            *Robot #3 has no laws*
4D: null            *Robot #4 has no laws*
5D: null            *Robot #5 has no laws*
6_1.2: 6            *Robot #6 jumps out*
7_2.3: 9            *Robot #7 attacks Chuck*
Attacking Chuck
Deactivated: 7      *Robot #8 defends Chuck*
8_1.3D: null        *Robot #8 is now inactive*
C: null
Done: [0_3D, 1_2D, 2_1.3D, 3D, 4D, 5D, 7_2.3D, 8_1.3D, C]
*Chuck is doomed, all robots inactive*


Probability Notes
The first robot to move acts with probability (Rounded to 0 decimals):
33% Throw self
35% Throw another Robot
20% Throw Chuck
13% Do nothing

When Chuck is attacked, the probability is:
6% Throw self
11% Throw another Robot
20% Throw Chuck
50% Defend Chuck
13% Do nothing

When a robot's attacked other than himself:
1% Throw self
35% Throw another Robot
1% Throw Chuck
50% Defend the other Robot
13% Do nothing

Probability Table for the first robot:
Self   Robot   Chuck  Defense   Nothing
Laws 1,2,3 Action: 1
Laws 1,2   Action: 1
Laws 1     Action: 1/9    8/9
Laws 1,3   Action:        1
Laws 2,3   Action:                1
Laws 2     Action: 1/2            1/2
Laws 3     Action:        8/9     1/9
Laws None  Action:                                 1
Sum:               47/18  50/18    29/18 0         1
P (Sum/8)          33%    35%      20%   0%        13%


What this implies is that Chuck is unlikely to be killed directly. Less than 1/5 chance of being targeted. And robots tend to be protective with 50-50 odds of deactivating an aggressor.

Expanding the probabilities 9 times yielded a couple bounds:
Defining a Win as 6 robots attacking another robot: 10%
Defining a loss as Chuck attacked by two or more, or all robots inactive: 11%
Unknown: 79% due to another round or robots may be inactive or robots may have jumped out.

Survival Count per Robot:

3  100.00%
4   85.9%
5   77.9%
6   71.9%
7   68.2%
8   65.8%
9   65.1%
10  64.7%
13  64.9%  (Bottom)
14  64.9%  (Bottom)
200 75.0%  (Flat?)
750 75.1%  (Flat?)


Algorithm pseudo-code

public void getTarget(ArrayList<Robot> robots) {
if(deactivated || chuck) return;
if(law1) {
if(ChuckAttacked) {deactivate self and robot attacking chuck}
else if(law2) {throw self out}
else {
if(law3) {throw a robot out}
else {throw anything but Chuck out}
}
} else {
if(law2) {
if(a robot is attacked) {deactivate self and first to attack}
else {
if(law3 or 50-50 rng) {Throw chuck out}
else {Throw self out}
}
//Implicitly, this is law3 only.
} else {throw anything but myself out}
}
if(target is Chuck and Chuck has not acted) {deactivate self and mark chuck as acted}
else {declare attack against target}

• @Gordon K took me far longer than I thought to format it, hope that explains what I understood and differs from what appears to be majority opinion on action order. Nov 6, 2015 at 2:55
• Just to comment on your percentages, I agree with your responses to Chuck or another robot being attacked, but for the first robot to act, I've got 33% : 41% : 14% : 13%. I have also assumed that Chuck responds immediately to negate the first attack on him. Nov 6, 2015 at 10:31
• @GordonK Added probability table, I'm fairly certain about the #s. Not so certain on the expansions. Gets tricky when a robot is under attack but the probability of invoking rule 3 is 1/9th. When two robots are attacked, the Probability becomes 1-(8/9)^2=17/81 Nov 6, 2015 at 15:59
• My mistake. Your percentage table figures are correct. Nov 9, 2015 at 11:30
• Redone with Chuck acting immediately and robots targetting lowest # aggressor. I still have a fairly high survival rate with an increasing probability. Nov 15, 2015 at 20:44

The probability that chuck lives is approximately 466.5/512 which is about 90%. i would like to point out that one robot acting at a time as if they were playing a game of cards does not appears sensible. The other answers have assumed that, which perhaps explains the difference in our answers.

moreover, i also do not think that a wise 1,1,0 robot will sacrifice itself while being aware that the other robots might kill chuck in its absence. So, i also assumed the robots to be wise and chose the optimum alternative depending upon the behaviour of others.

To evaluate my answer, i categorized the 9 robots into 4 teams- those who follow law 1, those who follow law 2 instead, those who follow just law 3 and those don't follow any. It can be seen that this consideration simplifies as members have very similar behaviour

Notice that chuck lives if there are 3 or more robots following law 1. This is because if someone attacks chuck, 3 good robots will die and kill 3 at the same time, hence completing the task so that there is no more violence required. This realization alone brings Chuck's survival probability to 90%. But Chuck can also survive if there are fewer than 3 good robots, largely if there are fewer robots following law 2 and more robots following none.

The precise calculation quickly gets pretty complicated after this, but after doing some i can safely conclude that my approximation is very close to the correct value.

• If good robots deactivate those attacking Chuck, then they are still in the basket adding to the weight, increasing the chance of running into the mountain. Nov 16, 2015 at 21:12
• But what if good robots deactivate and throws robots out too. ONLY After ensuring that chuck is under influence of no more attacks can they die in peace. Nov 16, 2015 at 21:48
• Your original "45.5/512"=8.9% is relatively close to my sim's death rate for chuck 10.5%. But as Gordon points out, riding into the mountain is a big possibility due to all inactive. Nov 17, 2015 at 15:04
• How can all the robots become inactive? The robots are not mad, they are simply trying to do what they must. As soon as there are 6 deactivated robots, the fight will stop. There are 10 people onboard. In order to save 4, 6 will be sacrificed. Even if the surviving robot is 0,1,0 type, it will reason fine and sacrifice itself, chuck and 4 deactivated ones to save the remaining party. Nov 17, 2015 at 15:47
• There was a typographic error. Chuck lives 90% of times. I had mistakingly written the opposite. Nov 18, 2015 at 2:00