Hi all, i am currently trying to create a counter which can help me select an action (A,B,C) depending on the highest value in that state.
Example:
First, the random counter would random between "HIGHEST" or "RANDOM". The probability of the random counter would be 90% "highest" and 10% "random". How i went about doing this is
randomcounter = Int((100 - 1 + 1) * Rnd + 1)
If epsilon > 10 Then
counter = "Q"
Else
counter = "random"
End If
[TABLE="class: grid, width: 300"]
<tbody>[TR]
[TD]Random Counter[/TD]
[TD]HIGHEST OR RANDOM[/TD]
[/TR]
</tbody>[/TABLE]
After the random counter has chosen between the 2. If it chose "HIGHEST", then based on a state(i would have determined this before), it would chose the highest value and give the corresponding action.
[TABLE="class: grid, width: 400, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]Action A[/TD]
[TD]Action B[/TD]
[TD]Action C[/TD]
[/TR]
[TR]
[TD]State1[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]State2[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]State3[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]State4[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]State5[/TD]
[TD]4[/TD]
[TD]6[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]State6[/TD]
[TD]1[/TD]
[TD]8[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]State7[/TD]
[TD]2[/TD]
[TD]5[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]State8[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]State9[/TD]
[TD]2[/TD]
[TD]0[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]State10[/TD]
[TD]8[/TD]
[TD]6[/TD]
[TD]0[/TD]
[/TR]
</tbody>[/TABLE]
In this example, my current state is State5. If my counter randoms to a "HIGHEST", im trying to get vba to store "Action C" (being the highest out of 4,6,7).
If the counter randoms to a "Random", the action stored would random between the 2 other action,not the highest value which is "Action A" or "Action C".
i am currently stuck using an index match formula in excel but im trying to implement in vba coding. One way i could think of would be:
If randomcounter = "Highest" and State = 1 Then
Actiontaken = max(range("B6:D6"))
thats really all i got..
Your help is much appreciated!
Example:
First, the random counter would random between "HIGHEST" or "RANDOM". The probability of the random counter would be 90% "highest" and 10% "random". How i went about doing this is
randomcounter = Int((100 - 1 + 1) * Rnd + 1)
If epsilon > 10 Then
counter = "Q"
Else
counter = "random"
End If
[TABLE="class: grid, width: 300"]
<tbody>[TR]
[TD]Random Counter[/TD]
[TD]HIGHEST OR RANDOM[/TD]
[/TR]
</tbody>[/TABLE]
After the random counter has chosen between the 2. If it chose "HIGHEST", then based on a state(i would have determined this before), it would chose the highest value and give the corresponding action.
[TABLE="class: grid, width: 400, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]Action A[/TD]
[TD]Action B[/TD]
[TD]Action C[/TD]
[/TR]
[TR]
[TD]State1[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]State2[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]State3[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]State4[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]State5[/TD]
[TD]4[/TD]
[TD]6[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]State6[/TD]
[TD]1[/TD]
[TD]8[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]State7[/TD]
[TD]2[/TD]
[TD]5[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]State8[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]State9[/TD]
[TD]2[/TD]
[TD]0[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]State10[/TD]
[TD]8[/TD]
[TD]6[/TD]
[TD]0[/TD]
[/TR]
</tbody>[/TABLE]
In this example, my current state is State5. If my counter randoms to a "HIGHEST", im trying to get vba to store "Action C" (being the highest out of 4,6,7).
If the counter randoms to a "Random", the action stored would random between the 2 other action,not the highest value which is "Action A" or "Action C".
i am currently stuck using an index match formula in excel but im trying to implement in vba coding. One way i could think of would be:
If randomcounter = "Highest" and State = 1 Then
Actiontaken = max(range("B6:D6"))
thats really all i got..
Your help is much appreciated!
Last edited: