简体   繁体   中英

2 players, pion move in a matrix

I have a question related to 2 players move in a matrix. I assume that there is a well known method for this question, but I didnt find one.

There is a matrix with m rows, n columns. 2 players will move a pion respectively. Pion can move only i+1 or j+1 which means only right or down. Last row and last column of the matrix is filled with given values. The purpose of the game is to reach last row or last column, first player wants to get max value, second player wants to get lowest value, in the last row/column.

在此处输入图片说明

According to above table, 2 players will move pion p from 0,0 position. First player wants to reach a bigger element, while second player wants to reach a smaller element.

My idea: Since players will move the pion respectively, I have separated the table as follows 在此处输入图片说明

cells with 1s refer the only possible moves of first player and 2s refer to only possible second player moves. From this point I thought about a dynamic programming solution but couldnt find any.

Any help is appreciated.

The state of dynamic programming is (number of row, number of column). The value is the best score the player can achieve by moving from this cell.
Base case: the score for a cell in the last row/column is fixed.
Inductive case: try to move right and down and choose the best option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM