objc2_gameplay_kit/generated/GKMinmaxStrategist.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9extern_class!(
10 /// The Minmax Strategist is a generic AI that selects a game model update for a given player that maximises
11 /// potential gain, while minimising potential loss. It does this by examining all of the updates available
12 /// to the player in question, extrapolating the potential moves opposing players may take, projecting out
13 /// maxLookAheadDepth number of turns. The selected update will result in the greatest potential gain, balanced
14 /// against the potential gain of other players.
15 ///
16 /// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkminmaxstrategist?language=objc)
17 #[unsafe(super(NSObject))]
18 #[derive(Debug, PartialEq, Eq, Hash)]
19 pub struct GKMinmaxStrategist;
20);
21
22#[cfg(feature = "GKStrategist")]
23extern_conformance!(
24 unsafe impl GKStrategist for GKMinmaxStrategist {}
25);
26
27extern_conformance!(
28 unsafe impl NSObjectProtocol for GKMinmaxStrategist {}
29);
30
31impl GKMinmaxStrategist {
32 extern_methods!(
33 /// The maximum number of future turns that will be processed when searching for a move.
34 #[unsafe(method(maxLookAheadDepth))]
35 #[unsafe(method_family = none)]
36 pub unsafe fn maxLookAheadDepth(&self) -> NSInteger;
37
38 /// Setter for [`maxLookAheadDepth`][Self::maxLookAheadDepth].
39 #[unsafe(method(setMaxLookAheadDepth:))]
40 #[unsafe(method_family = none)]
41 pub unsafe fn setMaxLookAheadDepth(&self, max_look_ahead_depth: NSInteger);
42
43 #[cfg(feature = "GKGameModel")]
44 /// Selects the best move for the specified player. If randomSource is not nil, it will randomly select
45 /// which move to use if there are one or more ties for the best. Returns nil if the player is invalid,
46 /// the player is not a part of the game model, or the player has no valid moves available.
47 #[unsafe(method(bestMoveForPlayer:))]
48 #[unsafe(method_family = none)]
49 pub unsafe fn bestMoveForPlayer(
50 &self,
51 player: &ProtocolObject<dyn GKGameModelPlayer>,
52 ) -> Option<Retained<ProtocolObject<dyn GKGameModelUpdate>>>;
53
54 #[cfg(feature = "GKGameModel")]
55 /// Selects one move from the set of N best moves for the specified player, where N is equal to
56 /// numMovesToConsider. If randomSource is nil, it will not randomly select, but will behave like
57 /// bestMoveForPlayer and return the first best move. Returns nil if the player is invalid, the
58 /// player is not a part of the game model, or the player has no valid moves available.
59 #[unsafe(method(randomMoveForPlayer:fromNumberOfBestMoves:))]
60 #[unsafe(method_family = none)]
61 pub unsafe fn randomMoveForPlayer_fromNumberOfBestMoves(
62 &self,
63 player: &ProtocolObject<dyn GKGameModelPlayer>,
64 num_moves_to_consider: NSInteger,
65 ) -> Option<Retained<ProtocolObject<dyn GKGameModelUpdate>>>;
66 );
67}
68
69/// Methods declared on superclass `NSObject`.
70impl GKMinmaxStrategist {
71 extern_methods!(
72 #[unsafe(method(init))]
73 #[unsafe(method_family = init)]
74 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
75
76 #[unsafe(method(new))]
77 #[unsafe(method_family = new)]
78 pub unsafe fn new() -> Retained<Self>;
79 );
80}