objc2-gameplay-kit 0.3.2

Bindings to the GameplayKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;

use crate::*;

extern_class!(
    /// The Minmax Strategist is a generic AI that selects a game model update for a given player that maximises
    /// potential gain, while minimising potential loss. It does this by examining all of the updates available
    /// to the player in question, extrapolating the potential moves opposing players may take, projecting out
    /// maxLookAheadDepth number of turns. The selected update will result in the greatest potential gain, balanced
    /// against the potential gain of other players.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkminmaxstrategist?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GKMinmaxStrategist;
);

#[cfg(feature = "GKStrategist")]
extern_conformance!(
    unsafe impl GKStrategist for GKMinmaxStrategist {}
);

extern_conformance!(
    unsafe impl NSObjectProtocol for GKMinmaxStrategist {}
);

impl GKMinmaxStrategist {
    extern_methods!(
        /// The maximum number of future turns that will be processed when searching for a move.
        #[unsafe(method(maxLookAheadDepth))]
        #[unsafe(method_family = none)]
        pub unsafe fn maxLookAheadDepth(&self) -> NSInteger;

        /// Setter for [`maxLookAheadDepth`][Self::maxLookAheadDepth].
        #[unsafe(method(setMaxLookAheadDepth:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMaxLookAheadDepth(&self, max_look_ahead_depth: NSInteger);

        #[cfg(feature = "GKGameModel")]
        /// Selects the best move for the specified player. If randomSource is not nil, it will randomly select
        /// which move to use if there are one or more ties for the best. Returns nil if the player is invalid,
        /// the player is not a part of the game model, or the player has no valid moves available.
        #[unsafe(method(bestMoveForPlayer:))]
        #[unsafe(method_family = none)]
        pub unsafe fn bestMoveForPlayer(
            &self,
            player: &ProtocolObject<dyn GKGameModelPlayer>,
        ) -> Option<Retained<ProtocolObject<dyn GKGameModelUpdate>>>;

        #[cfg(feature = "GKGameModel")]
        /// Selects one move from the set of N best moves for the specified player, where N is equal to
        /// numMovesToConsider. If randomSource is nil, it will not randomly select, but will behave like
        /// bestMoveForPlayer and return the first best move. Returns nil if the player is invalid, the
        /// player is not a part of the game model, or the player has no valid moves available.
        #[unsafe(method(randomMoveForPlayer:fromNumberOfBestMoves:))]
        #[unsafe(method_family = none)]
        pub unsafe fn randomMoveForPlayer_fromNumberOfBestMoves(
            &self,
            player: &ProtocolObject<dyn GKGameModelPlayer>,
            num_moves_to_consider: NSInteger,
        ) -> Option<Retained<ProtocolObject<dyn GKGameModelUpdate>>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl GKMinmaxStrategist {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}