[Solved] My code is showing error [closed]


The key is item 7:

For example, if Config.MIN_ACTION is 1 and Config.MAX_ACTION is 3: If the action rankings are {9,90,1} the total is 100. Since actionRanking[0] is 9, then an action of picking up 1 should be chosen about 9/100 times. 2 should be chosen about 90/100 times and 1 should be chosen about 1/100 times.

Here’s how that example should be implemented:

  • First generate a random number between 0 and 99 inclusive (100 possible values).

  • If the random number is less than 9, then return 1. Otherwise subtract 9 from the random number.

  • If the adjusted random number is less than 90, then return 2. Otherwise subtract 90 from the adjusted random number.

  • The only possibility left is that the adjusted random number is 0, which is less than 1, so return 3.

In general, the pseudocode for the AI function (after the special cases at the beginning) should look like this:

compute the 'sum' of the entries in the 'actionRanking' array
generate a random number `R` between '0' and 'sum-1' inclusive
for each entry in 'actionRanking'
   if the entry is greater than 'R'
      return 'Config.MIN_ACTION' + the index for that entry
   otherwise
      subtract the entry from 'R'

1

solved My code is showing error [closed]