Zonk! computer strategy decider design and logic
13:52 12 Jul 2018

I have a question about an algorithm. I have a function that is called computer_strategy_decider, it takes 6 dices(numbers) and decides the dices to keep and the dices to re-roll.

You may want to take in consideration the function description and the scoring part:

computer_strategy_decider() – This function will decide which scoring strategy will be used. In summary, the computer will always play safe and have a very simple strategy. The computer will always choose the strategy that will give her the highest score (see scoring section). It will check all the strategies and decide which one will give her the highest score. For example, if the dices look as follows: 1, 2, 3, 4, 5, 6 then there is no need to check other strategies the scoring is 1500. If the scoring is as follows 1,1,1,5,5,5 then the computer will keep the first three and roll the last three as this will give her 1000 scoring point rather than keeping 5,5,5 which would give her 500.

Scoring rules:

  1. Each 5 is worth 50 points.
  2. Each 1 worth 100 points.
  3. Any three-of-a-kind rolled at once is worth 100x the face value of a single die. (e.g., three two's are worth 200, three three’s are worth 300, three four’s are worth 400, three five’s are worth 500 and three six’s are worth 600), apart from three one’s which worth 1000 (Note: they don’t have to be consecutive).
  4. Six of a kind (e.g. 4 4 4 4 4 4 , 5,5,5,5,5,5,,...) are worth 1000 points.
  5. A straight (1,2,3,4,5,6) is worth 1500 points (they do not need to be in that order, for example, it could be 3, 2, 1, 6, 5, 4).

also:

When dices are rolled, only one of the above can be used for scoring. Depending on the number of dices kept, one of the strategies will be for scoring. For example, if the user rolls “1 1 1 1 1 1” and they decide to keep 1 of those, and roll again the rest, they will get 100 points. If they decide to keep 3 of those and roll again the other three, they will get 1000 points. If they decide to keep all, then they will get 1000 points. Please see “computer_strategy_decider” function definition below for how computer will decide which strategy to use.

I want some help in solving this problem to be able to write this function to solve my problem.

int computer_stategy_decider(int csd_d1 , int csd_d2 ,int csd_d3 ,int csd_d4 ,int csd_d5 , int csd_d6){
int csd_result;

if(csd_d1+csd_d2+csd_d3+csd_d4+csd_d5+csd_d6==21){
    csd_result=1500;
    printf("I stop and Kept dices 1 2 3 4 5 6\nMy score: %d",csd_result);
}
else if(){}

above the only idea I could think of that is by summing the dices it can't work for all cases, only 6 of a kind. 111-111|222-222|333-333|444-444|555-555|666-666 & 123-456.

algorithm