# Checkers games with computer random movement

Im studying Java OOP, and I have to make first assignment about making checkers board game. I have to get input from user if he plays, and than when his turn is over the computer will play. Computer's movement is random but if he has the opportunity to "eat" his rival, he has to do this and if not than making random move. Can someone help me with the coding?

• On which part are you stuck exactly right now? – wondra Mar 23 '18 at 10:05
• Computer turn, how can I write the code of selection random cell from line 2, for the first movement – Karin Yurchenko Mar 23 '18 at 10:37
• What have you tried so far? It could be even written as one-liner such as tokens.stream().collect(Collectors.collectingAndThen(Collectors.toList(), list -> Collections.shuffle(list).stream())).findFirst(token -> token.canMove()). – wondra Mar 23 '18 at 13:05
• @wondra That is terrifying and exciting at the same time. Congrats – Bálint Mar 23 '18 at 13:10
• hey, I have learned only Java and C programs. Have no idea what does it means. Thanks anyway! – Karin Yurchenko Mar 23 '18 at 17:18

The most straightforward way would be to build a list of all possible moves and then randomly select from them.

1. Initialize two empty lists, eatMoves and nonEatMoves
2. For each rival token:
• For each possible move of that token:
• if the move involves eating an opponent: