reset password
Author Message
BryanYeh
Posts: 38
Posted 17:42 Apr 29, 2014 |
function minscore (role,action,state)
 {var opponent = findopponent(role,game);
  var actions = findlegals(opponent,state,game);
  var score = 100;
  for (var i=0; i<actions.length; i++)
      {var move; 
       if (role==roles[0]) {move = [action,actions[i]]}
          else {move = [actions[i],action]}
       var newstate = findnext(move,state,game);
       var result = maxscore(role,newstate);
       if (result<score) {score = result}};
  return score}

This is the minscore from the minimax from chapter 6. What is move = [action,actions[i]] and move = [actions[i],action] difference and what is it suppose to return?

 

Last edited by BryanYeh at 20:18 Apr 29, 2014.
rabbott
Posts: 1649
Posted 21:07 Apr 29, 2014 |

I'm not sure. Here's my guess.

It looks like action, the parameter, is the action being considered by the player. minscore wants to find the minimum score that action may produce depending on the action taken by the opponent.  (This is the same function that my lowestStateScore function performs.)

It appears that the assumption is that there is only one opponent. So the combined move is a pair of actions, one by the player and one by the opponent. For each possible action the opponent may take, we want to know what happens when that action is combined with the action that is passed in as the parameter. 

The way a pair of actions is used to generate the next state is apparently to put them into a list of two elements and pass that list to findnext. In building the list, should the player's action come first or the opponent's action? The actions in the list are apparently in the same order as the roles of the game.  If the player is role[0], its action is first; otherwise the opponent's action is first and the player's action is second.

Last edited by rabbott at 21:10 Apr 29, 2014.
rodthung
Posts: 14
Posted 01:22 Apr 30, 2014 |

Here is what I did

create list of move : List<Move> = move

1. And if the role that we are considering is our player ( Role == Roles[0])

we add move to the list of move by 

move.add(action) //our move 

move.add(action.get(i)) // follow by the opponent move 

2. else if the role is opponent 

move.add(action.get(i)) // the opponent move 

move.add(action) // follow by our move 

PS. Before adding the move you have to make sure that we not adding the same move with the opponent

I think this would help