Continuous action cannot convergence
Hi everyone,
I am experiencing problem in using the continuous action. My app is a board game, I use discrete action and works well. But there are invalid move issues, e.g. AI select a move that already occupied by other player In order to solve this, I change the action into continuous. Then my problem starts, it seems continuous action can never be trained up no matter how I adjust the parameters
My game is a very simple.
It has 10 x 10 map, each player can select a column in turn. Its move will be the bottomest of the slected column
Winning the game (4 move in a line) will has 1 reward
Losing the game will have -1 reward
Invalid move will have -1 reward
My state is 100 and action is 10
When in discrete action 0 = select column 0, action 1 =select column 1 ........
Training result is normal as below

But once I change into continuous input, it never learns. It always stays in around -0.9
Discrete action can only return 1 result, this is always a problem to solve invalid move. Besides, it also makes AI feedback without randomness. AI always takes same action under same situation, player will soon learn the pattern to defeat such AI And when a pattern is discovered, player can always win with same pattern
I am still having a difficult time to make continuous action work Anything can help ?
There are multiple things here. You said you tried to change to continuous output. How did you do this? Switching from a discrete state of size 100 to a continuous one is no easy task. You said you changed from discrete actions to continuous actions. How did you do this ? You must keep in mind that continuous actions is a vector of floats all between -1 and 1, you cannot expect a continuous action to behave the same as a discrete action. It is true that the agent would take the same action in the same situation in this scenario (given our current implementation of PPO) if you do not want to have to create your own learning algorithm and still use our implementation of PPO, maybe you could give some noise to the state input. This would introduce some level of randomness into the actions taken. Given what I understand from your game, I think sticking to discrete actions would be best.
Hi vincentpierre,
Yes, I mean continuous action. After changing to continuous action, I normalize the action vector and take the action according to the probability.
Discrete actions only gives one result. And always give the same result when state is same. Therefore it cannot provide 2nd best action when its result is invalid.
I am not sure how I can help. I think if you use continuous action and sample the action to take in C# (use the vector of action as a vector of probabilities) this will definitely confuse the learning (because a different action can be taken for the same vector of action). I say stick to discrete and add some noise to the input.
How to add noise into input to solve invalid move ?
When collecting the state, you can add some level of randomness to the state. I never tried this but I think it can work if the noise is not too big. This should give some randomness to the actions. It would not help for invalid moves. For invalid moves, penalizing and resetting seems like the best option to me for now.
@vincentpierre You said
It is true that the agent would take the same action in the same situation in this scenario (given our current implementation of PPO)
How is it? I see you set the action tensor here and draw a randn for epsilon here so the action shouldn't be the same even if the input is the same.
And as far as I know, adding noise is a technique to approach real-world behavior OpenAI blog, but I have no idea how noises can help in pure simulation...
@kwea123 We do not have epsilon for discrete control. Instead we generate a distribution over all actions and sample. The distribution will always be the same given a certain input but the action is sampled.
Hi Vincentpierre,
I have trained with
- penalizing and resetting for invalid moves
- also added a state variable of a randomly generated variable (as noise)
But even so, there still possibilities the trained model still take invalid moves
Do you think it is possible for discrete action to return a distribution over all actions (instead of just 1 action) ?
So that we can select the 2nd best
@vincentpierre Yeah that's what I understand
The distribution will always be the same given a certain input but the action is sampled.
The actions are sampled from the same distribution, but could be different (and probably should), right? If I misunderstood anything, could you please explain more? But the OP says that he gets the same output all the time, that's where I get confused.
You should not get the same output all the time, just the same distribution. I do not think you can access the distribution without modifying heavily the code base. Maybe at inference you could skip the fixed update and ask again at the next fixed update (skip the turn and try again next turn).
Maybe at inference you could skip the fixed update and ask again at the next fixed update (skip the turn and try again next turn)
Good idea, let me try
Hi @q7777777hk , Thanks for reaching out to us. Hopefully you were able to resolve your issue. We are closing this due to inactivity, but if you need additional assistance, feel free to reopen the issue.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.