Answer above from Tim is practically correct for primary problem ( with 6 pirates), and he even caught "surplus +1" issue that I missed initially.
It is correct logic and I marked it as an answer, but since it still misses few things I will post them here for completeness: final solution for primary "6 pirates" problem and exact solution for harder "formula" problem.
"6 pirates" question
Reasoning logic is nicely described in Tim's answer so there is no need to repeat it here, although I will repeat important findings that continue to be valid for 7+ pirates:
- pirates younger than P3 have NO influence on result
- P3 and P4 pirates CAN influence result by offering themselves >100g, thus ensuring that P5 offer them zero/low gold, thus ensuring P6 offer them at least 1g
- P5 pirate is most interesting one : he can ensure that he gets fairly large amount of gold, by proposing for himself 3rd smallest amount - and since P6 need 3 additional votes, he must include his amount in final proposal. And largest possible 3rd smallest amount is 99g, eg ( 101,100,0,0,99 ) - zeros are for P3/4 that offered themselves >100g
- but there is "surplus" twist there: what P5 minimally need is two pirates with larger amount than him, so even (100,100,0,0,99) would do ... meaning there is surplus +1g that can go to any of P1..P4. So equally valid P5 proposals are: (101,100,0,0,99), (100,101,0,0,99), (100,100,1,0,99) and (100,100,0,1,99) with equal 1/4 chance
- responses to those proposals by P6 are, respectively: (0,0,1,1,100,198), (0,0,1,1,100,198), (0,0,2,1,100,197) and (0,0,1,2,100,297) with same 1/4 chance
- so answer to "what will P6 propose" is : P6 will propose 0g to P1/2 and 100g to P5. To P3/P4 he proposes 1g in half cases (when he gets 198g) and 1g/2g or 2g/1g otherwise (when he gets 197g)
- thus answer to "expected gold value for P6" is 1/4*(198+198+197+197)= 197.5g
Formula question
If only approximate value was needed, that this would be relatively simple formula C(P,G) , using integer math where % is moduo:
C(P,G) ~ G-2G/(P+P%2)-P/2+1
But actual correct formula is somewhat more complicated :
- it must also solve expected value for ALL younger pirates
- it must account for "surplus" variations
Formula is based on same logic that was used for "6 pirates", only generalized regarding total "P" pirates count:
- pirates younger than P-3 have NO influence on result
- #(P-3) and #(P-2) pirates CAN influence result by ensuring that #(P-1) offer them zero/low gold, thus ensuring #P offer them at least 1g
- #(P-1) second oldest pirate is most interesting one : he can ensure that he gets fairly large amount of gold.
- if V is number of votes needed by oldest, then second oldest will propose so he gets (V-1)th smallest amount. That way oldest can not ignore him in his offer
- if N is number of votes needed by second oldest, it turns out that being "(V-1) smallest" is always same as being "Nth largest". So optimal strategy for 2nd oldest is to split gold by N and fix by +/-1 so that he is smallest of those N values (while still being as large as possible, to satisfy "greedy")
Optimal proposal by second oldest pirate is key element of solution. From above we see that he must split gold to N semi-equal values Z. If Z=G/N (integer quotient) and M=G%N (remainder) then he can offer something like:
- Z+1,Z+1,Z,...,Z,0,0,Z-1
- 2nd oldest pirate (P-1) offers "Z-1" gold to himself and zeros to (P-2) and (P-3) since they will ensure in their offers for themselves at least Z+1 gold
- with N of those "~Z" values, 2nd oldest ensure his is smallest with "Z-1", so oldest pirate will be forced to offer him Z gold (one more gold)
- to younger pirates (1..P-4) he offers either "Z" or "Z+1" (or 0g, see below). There will be (M+1) of those "Z+1"
- special case is when M==N-1, since then 2nd oldest can offer (Z+1,Z+1...,Z+1,0,0,Z)
- note that while pirate (P-2) ensure his low/0g offer from second oldest (P-1) in standard way (by offering largest value to himself), pirate (P-3) must use same "Nth smallest" logic as (P-1) to ensure large offer from (P-2) pirate, which in turn ensure low/0g offer from second oldest (P-1).
But there is twist to above logic for second oldest (except in special case) : we actually have "surplus" of S=M+1 "+1s" that do not need to be given as "+1". They can be actually distributed in ANY way, among ALL pirates younger than 2nd oldest ( including those with 0g in proposal above ). If (Z,Z,Z,..Z,0,0,Z-1) is "baseline" with S "surplus" then if for example S=3, following are examples of valid proposals with equal expected gain for 2nd oldest :
- Z+1,Z+1,Z,..Z+1,0,0,Z-1
- Z,Z+1,Z,..Z,1,1,Z-1
- Z+3,Z,Z,..Z,0,0,Z-1
- Z,Z,Z,..Z,2,1,Z-1
- Z,Z,Z+1,..Z,0,2,Z-1
- ... and all other combinations with (1,1,1) or (2,1) or (3)
What is average "surplus" gold that any of X pirates can expect, if proposing pirate has S surplus total and choose randomly among all possible options?
That is interesting small problem in itself, but it turns out it is simple S/X ( I will skip proving this, but it is not hard ). And in this case where proposing pirate is second oldest, X=P-2 (he can distribute surplus to any other pirate except himself).
So, what is average expected gold for those (P-2) youngest pirates from proposal of oldest pirate? Without "surplus", those that got 0g from second oldest would get 1g from oldest. With "surplus", they will get 1+S/(P-2) gold on average.
But we have two groups of pirates who can get "low offer" (0g without surplus, <=S with surplus) by second oldest:
- (P-2) and (P-3) get guaranteed low offer, so their "expected gold value" after oldest offer is 1+S/(P-2)
- younger pirates 1st..(P-4)th get either "Z" or "0" (plus eventual surplus) - where order of those "Z"/"0" is random and there are K=V-4 of those "0"s ( where "V" are votes needed by oldest, and K>=0 ). So those younger pirates will get low offer from second oldest with chance K/(P-4)= (V-4)/(P-4) , and their "expected gold value" is (V-4)/(P-4)*(1+S/(P-2))
Second oldest will be offered (Z-1)+1 by oldest, and since Z= [G/N] (integer division), "expected gold value" by second oldest is [G/N]. And oldest "expected value" is total gold G minus expected values of all other pirates, or EV(P)= G - EV_2nd_oldest - 2xEV_older - (P-4)xEV_younger = G-[G/N]-(1+S/(P-2))*(V-2)
So formulas in normal cases for "expected gold value" of all pirates are:
- EV_younger =EV(pirates 1..P-4)= (V-4)/(P-4)*(1+S/(P-2))
- EV_older =EV(pirates P-2 and P-2)= 1+S/(P-2)
- EV 2nd_oldest =EV(P-1)= [G/N]
- EV_oldest =EV(P)= G-[G/N]-(1+S/(P-2))*(V-2)
But, as it was mentioned above, there is one special case when there is no "surplus", when M==N-1 and second oldest proposal looks like (Z+1,Z+1,...Z+1,0,0,Z). For that special case, expected values are same as in above formulas with S=0, but 2nd oldest now expect one more (Z+1 instead of Z), and accordingly oldest expect one less.
And formulas for special case, when there is no surplus, are :
- EV_younger =EV(pirates 1..P-4)= (V-4)/(P-4)
- EV_older =EV(pirates P-2 and P-2)= 1
- EV 2nd_oldest =EV(P-1)= [G/N]+1
- EV_oldest =EV(P)= G-[G/N]-V+1
Derived values (N,V,S) that both above groups of formulas depend on, in addition to actual parameters (P,G), were already explained above :
- V= int[P/2]+1 ( number of votes needed by oldest )
- N= int[(P+1)/2] ( number of votes needed by second oldest )
- S=G%N+1 ( surplus, where % is MOD function )
- special case is when G%N==N-1 ( then S=0 )
Note that only one set of formulas from above is applicable at a time, as explained above. So, depending on specific P and G, either "normal" or "special" case formulas are used.
Above formulas work under condition 6 <= P < 2*G :
- formula for K=V-4 is only valid if P>=6, otherwise it should be K=0
- it is fairly easy to cover P>=4 with change K=max(0,V-4), and changing number of older pirates with guaranteed low/0g by 2nd oldest from fixed 2 to IF(P>5,2,1)
- but P<=3 remain special cases that can not be covered with these formulas
- formulas also cover only situation when there is enough gold to share, which in general is when P<2*G
- it is not so easy to cover low gold cases. I suspect they would exhibit same 2^z survival pattern as in classic solution, but I did not solve those
What will oldest pirate actually propose was not in bonus question, but neither was EV for all other pirates, so we can try to answer that one too. Proposal of oldest pirate is based on second oldest (P-1) random distribution, which include himself and two groups : two older pirates (P-2) and (P-3) with guaranteed "~0", and younger pirates 1..(P-4) which get (N-1)x "~Z" and (V-4)x "~0" [ put in square brackets below, where "Z" and "0" can be in any order ], with "~" denoting that any of those pirates can get increase in [0,S]g range, but with total surplus in sum always being S.
Proposals by 2nd oldest and oldest, with surplus "~" and any order inside []:
- [~Z,~Z,~Z,~Z,~0,~0], ~0,~0, Z-1 : proposal by 2nd oldest,~= up to +S
- ( 0, 0, 0, 0,~1,~1), ~1,~1, Z , R : proposal by oldest
Example proposals by 2nd oldest, followed by proposal from oldest, if S=3:
- Z, 1, Z, 0, Z, Z, 2, 0, Z-1
- 0, 2, 0, 1, 0, 0, 3, 1, Z , R : R get -3 due to S
- 0,Z+1, Z,Z+1, 0, Z, 0, 1, Z-1
- 1, 0, 0, 0, 1, 0, 1, 2, Z , R : R gets -1 due to S
- 0,Z+1,Z+1,Z+1, 0, Z, 0, 0, Z-1
- 1, 0, 0, 0, 1, 0, 1, 1, Z , R : R gets -0 due to S
1
Oldest will propose "0g" to any of the younger pirates with "~Z", and will propose +1g to any pirate with "~0g" from 2nd oldest proposal, denoted by "~1g" in oldest proposal. Normal brackets around younger pirates in oldest proposal denote that "~1" and "0" can be in any order, where that order is determined not by him but by 2nd oldest pirate ( whose proposal use square brackets for that reason ). That "~1" is randomly in range [1,S+1], but increases above 1g cannot be larger than S in total ( and can be lower in total, even zero if all surplus by 2nd oldest goes to pirates with "~Z" )
So oldest will propose :
( 0, 0, 0, 0,~1,~1), ~1,~1, Z , R : proposal by oldest with any order inside ( brackets )
- "0" gold to (N-1) younger pirate, and "~1" gold to (V-4) younger pirates, in any order
- "~1" gold to pirates (P-2) and (P-3)
- "Z" gold to second oldest (P-1) pirate
- "R" gold, as remainder of initial G gold, to himself
- in "special cases" there is no surplus "~" and 2nd oldest get "Z+1" gold
8 pirates with 302g question
I will not answer here that particular question, nor simpler "7 pirates" one, since their final solution is also covered by general formula explanation.
But they are interesting to solve manually and see/check if there is really no way for younger pirates to "bomb" logic that was explained in formula solution.
And "8 pirates with 302 gold" is also very interesting to solve manually since that is lowest number of pirates where 0g offers appear for younger pirates, in addition to "surplus". If I had my final solution when I initially posted this question (which obviously I did not), I would have chosen to ask only for "(8p,302g)" as primary problem and "formula C(P,G)" as bonus one.