Yea this question is confusing to understand. I think the key point here is to realize that f(a,b) doesn’t do what you think it does (yes it does return an int revenue, but you are missing a very important detail). f(a,b) doesn’t care which player it is… lets break down your equation and see what it says:
f(a,b) = max(c[a]+min(f(a+1,b),f(a,b-1)), c[b]+min(f(a,b-1),f(a+1,b))
First,
c[a]+min(f(a+1,b),f(a,b-1))
What you are saying here is, the total amount Player gets when he chooses index a, is the coin itself plus the minimum revenue between picking a+1 or b-1. Which doesn’t make sense right? I mean, how are you taking Opponent into account?
Fine, lets argue from a different perspective. Lets say that we assume f(a+1,b) returns opponent’s revenue, then why are you adding your opponent’s revenue to the Players? Makes no sense either right?
Now go back to the original equation:
f(a,b) = max(c[a]+min(f(a+2,b),f(a+1,b-1)), c[b]+min(f(a,b-2),f(a+1,b-1))
c[a]+min(f(a+2,b),f(a+1,b-1))
The Opponent wants to minimize Player’s revenue, thus its equivalent to saying Player’s revenue is equals to the coin he picks up, plus the MIN revenue he can gain AFTER opponent picks up a+1 or b-1, thats why its a+2 or b-2, its from the Player’s perspective.
This solutions is really clever, you just have to keep thinking about it. I hope someone else can explain it better than I did. The insight for me was realizing the very subtle but important difference between
c[a]+min(f(a+1,b),f(a+1,b-1)
c[a]+min(f(a+2,b),f(a+1,b-1)
And that the equation is formulated from the Player’s perspective.