@@ -20,8 +20,16 @@ class CatalogGame:
2020 description : str
2121 citation : str
2222
23- def __new__ (cls ) -> Game :
24- raise NotImplementedError ("Subclasses must implement __new__ method" )
23+ def __new__ (cls , * args , ** kwargs ) -> Game :
24+ """Create a game instance by calling the _game() method."""
25+ if hasattr (cls , "_game" ) and cls ._game is not CatalogGame ._game :
26+ return cls ._game (* args , ** kwargs )
27+ raise NotImplementedError ("Subclasses must implement _game() method" )
28+
29+ @staticmethod
30+ def _game () -> Game :
31+ """Override this method in subclasses to define the game."""
32+ raise NotImplementedError ("Subclasses must implement _game() method" )
2533
2634 @classmethod
2735 def _extract_metadata_from_game (cls , game : Game ) -> None :
@@ -39,7 +47,7 @@ def __init_subclass__(cls, **kwargs):
3947
4048 # For non-file-based games, create a temporary instance to extract metadata
4149 try :
42- temp_game = cls .__new__ ( cls )
50+ temp_game = cls ._game ( )
4351 cls ._extract_metadata_from_game (temp_game )
4452 except NotImplementedError :
4553 # Base class, skip
@@ -164,9 +172,10 @@ class OneShotTrust(CatalogGame):
164172 """
165173 citation = "Kreps (1990)"
166174
167- def __new__ (cls , unique_NE_variant : bool = False ) -> Game :
175+ @staticmethod
176+ def _game (unique_NE_variant : bool = False ):
168177 g = Game .new_tree (
169- players = ["Buyer" , "Seller" ], title = cls . title
178+ players = ["Buyer" , "Seller" ], title = "One-shot trust game, after Kreps (1990)"
170179 )
171180 g .append_move (g .root , "Buyer" , ["Trust" , "Not trust" ])
172181 g .append_move (g .root .children [0 ], "Seller" , ["Honor" , "Abuse" ])
0 commit comments