Skip to content

Package: MoveGenerator

MoveGenerator

Coverage

1: /*
2: * Copyright © 2020-2023 Fachhochschule für die Wirtschaft (FHDW) Hannover
3: *
4: * This file is part of gaming-core.
5: *
6: * Gaming-core is free software: you can redistribute it and/or modify it under
7: * the terms of the GNU General Public License as published by the Free Software
8: * Foundation, either version 3 of the License, or (at your option) any later
9: * version.
10: *
11: * Gaming-core is distributed in the hope that it will be useful, but WITHOUT
12: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14: * details.
15: *
16: * You should have received a copy of the GNU General Public License along with
17: * gaming-core. If not, see <http://www.gnu.org/licenses/>.
18: */
19: package de.fhdw.gaming.core.domain;
20:
21: import java.util.Optional;
22:
23: /**
24: * Generates a valid move for a given player in a given game with a given state.
25: *
26: * @param <P> The type of game players.
27: * @param <S> The type of game states.
28: * @param <M> The type of game moves.
29: */
30: @FunctionalInterface
31: public interface MoveGenerator<P extends Player<P>, S extends State<P, S>, M extends Move<P, S>> {
32:
33: /**
34: * Generates a valid move. If no valid move is possible an empty {@link Optional} is returned.
35: *
36: * @param player The player to choose the move for.
37: * @param state The state of the game to operate on.
38: * @return The generated move or an empty {@link Optional} if no valid move is possible.
39: */
40: Optional<M> generate(P player, S state);
41: }