Bug 34785 - IGKGameModel must bind "scoreForPlayer:"
Summary: IGKGameModel must bind "scoreForPlayer:"
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 9.4 (iOS 9.2)
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-10-12 17:21 UTC by Larry O'Brien
Modified: 2015-10-14 10:24 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Larry O'Brien 2015-10-12 17:21:19 UTC
The scoreForPlayer: method is relied on by `GKMinMaxStrategist.GetBestMove` and must be exported by anything that implements IGKGameModel. 

The GKMinMaxStrategist.GetBestMove() method performs a search of the IGKGameModelUpdate[] returned by GetGameModelUpdates (IGKGameModelPlayer player). The value of each state is then passed to alternating calls of IGKGameModel.SetGameModel(IGKGameModel) and IGKGameModel.ScoreForModel(IGKPlayer), e.g.:

		public void SetGameModel (IGKGameModel gameModel)
			var newGameState = (TicTacToe)gameModel;
			board = newGameState.Board;
			activePlayer = (TicTacToePlayer)newGameState.GetActivePlayer ();

		[Export ("scoreForPlayer:")]
		public nint ScoreForPlayer (IGKGameModelPlayer player)
			return TicTacToeMove.ValueOf (this.Board, ((TicTacToePlayer)player).Marker);
Comment 1 Larry O'Brien 2015-10-12 19:40:41 UTC
OK, it's a little more complex than "must":

This method is optional; however, your game model class must implement at least one of the scoreForPlayer:, isLossForPlayer:, and isWinForPlayer: methods."
Comment 2 Sebastien Pouliot 2015-10-14 10:24:51 UTC
That does not sound like something we can enforce in the API (or at compile time) just like Apple can't and document that requirement.

* caught a cold so maybe I'm missing something obvious, please re-open with your proposal in that case.