graph-games-proto 0.3.1865__py3-none-any.whl → 0.3.1866__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
graph_games_proto/fns.py CHANGED
@@ -1009,18 +1009,9 @@ class ActionDrawUnit:
1009
1009
  # fig::Fig
1010
1010
  # logged_game_uuid::UUID
1011
1011
  # to_play::Vector{Int}
1012
- # num_route_cards::Int
1013
- # num_route_discards::Int
1014
- # num_unit_cards::Int
1015
- # num_unit_discards::Int
1016
- # faceup_spots::Vector{Union{Nothing,Int}}
1017
- # player_hands::Vector{PublicPlayerInfo}
1018
- # captured_segments::Vector{CapturedSegment}
1019
- # captured_points::Vector{CapturedPoint}
1020
1012
  # last_to_play::Union{Nothing,Int}
1021
1013
  # terminal::Bool
1022
1014
  # winners::Vector{Int}
1023
- # market_refills::Vector{MarketRefill}
1024
1015
 
1025
1016
 
1026
1017
  class AltAction(PClass):
@@ -2192,12 +2183,8 @@ class State(PClass):
2192
2183
  route_cards = field(type=PVector) # List[int]
2193
2184
  route_discards = field(type=PVector) # List[int]
2194
2185
  player_hands = field(type=PVector) # List[PlayerInfo]
2195
- unit_cards = field(type=PVector) # List[int]
2196
- faceup_spots = field(type=PVector) # List[Union{Nothing, int}]
2197
- unit_discards = field(type=PVector) # List[int]
2198
2186
  last_to_play = field(type=(int, type(None)), initial=None)
2199
2187
  winners = field(type=list) # List[int]
2200
- # market_refills::Vector{MarketRefill}
2201
2188
  def __todict__(self):
2202
2189
  return {
2203
2190
  "uuid2edge": {k: v.__todict__() for k, v in self.uuid2edge.items()},
@@ -2233,9 +2220,6 @@ class State(PClass):
2233
2220
  "route_cards": list(self.route_cards),
2234
2221
  "route_discards": list(self.route_discards),
2235
2222
  "player_hands": [x.__todict__() for x in self.player_hands],
2236
- "unit_cards": list(self.unit_cards),
2237
- "faceup_spots": list(self.faceup_spots),
2238
- "unit_discards": list(self.unit_discards),
2239
2223
  "last_to_play": self.last_to_play,
2240
2224
  "winners": self.winners,
2241
2225
  }
@@ -2275,9 +2259,6 @@ class State(PClass):
2275
2259
  route_cards=pvector(d["route_cards"]),
2276
2260
  route_discards=pvector(d["route_discards"]),
2277
2261
  player_hands=pvector([PlayerInfo.__fromdict__(h) for h in d["player_hands"]]),
2278
- unit_cards=pvector(d["unit_cards"]),
2279
- faceup_spots=pvector(d["faceup_spots"]),
2280
- unit_discards=pvector(d["unit_discards"]),
2281
2262
  last_to_play=d.get("last_to_play"),
2282
2263
  winners=d["winners"],
2283
2264
  )
@@ -2479,70 +2460,6 @@ class ScoreItem(PClass):
2479
2460
  )
2480
2461
 
2481
2462
 
2482
- # Implementing the following GraphQL type:
2483
- # type PublicPlayerInfo {
2484
- # final_score: PlayerScore
2485
- # longest_trail: [Int]!
2486
- # longest_trail_len: Int!
2487
- # num_pieces: Int!
2488
- # num_route_cards: Int!
2489
- # num_unit_cards: Int!
2490
- # paths: [Int]!
2491
- # route_statuses: [RouteStatus]
2492
- # score: Int!
2493
- # }
2494
- class PublicPlayerInfo(PClass):
2495
- final_score = field(type=(PlayerScore, type(None)), initial=None) # Union{Nothing, PlayerScore}
2496
- longest_trail = field(type=list) # List[int]
2497
- longest_trail_len = field(type=int)
2498
- num_pieces = field(type=int)
2499
- num_route_cards = field(type=int)
2500
- num_new_route_cards = field(type=int)
2501
- num_unit_cards = field(type=int)
2502
- paths = field(type=list) # List[int]
2503
- points = field(type=list) # List[UUID]
2504
- tokens = field(type=list) # List[UUID]
2505
- route_statuses = field(type=list) # List[RouteStatus]
2506
- score = field(type=int)
2507
- num_point_pieces = field(type=int, initial=0) # Added to match PlayerInfo
2508
- completed_clusters = field(type=list, initial=[]) # Added to match PlayerInfo
2509
- def __todict__(self):
2510
- return {
2511
- "final_score": self.final_score.__todict__() if self.final_score else None,
2512
- "longest_trail": self.longest_trail,
2513
- "longest_trail_len": self.longest_trail_len,
2514
- "num_pieces": self.num_pieces,
2515
- "num_route_cards": self.num_route_cards,
2516
- "num_new_route_cards": self.num_new_route_cards,
2517
- "num_unit_cards": self.num_unit_cards,
2518
- "paths": self.paths,
2519
- "points": self.points,
2520
- "tokens": self.tokens,
2521
- "route_statuses": [x.__todict__() for x in self.route_statuses],
2522
- "score": self.score,
2523
- "num_point_pieces": self.num_point_pieces,
2524
- "completed_clusters": self.completed_clusters,
2525
- }
2526
- @staticmethod
2527
- def __fromdict__(d):
2528
- return PublicPlayerInfo(
2529
- final_score=PlayerScore.__fromdict__(d["final_score"]) if d.get("final_score") else None,
2530
- longest_trail=d["longest_trail"],
2531
- longest_trail_len=d["longest_trail_len"],
2532
- num_pieces=d["num_pieces"],
2533
- num_route_cards=d["num_route_cards"],
2534
- num_new_route_cards=d["num_new_route_cards"],
2535
- num_unit_cards=d["num_unit_cards"],
2536
- paths=d["paths"],
2537
- points=d["points"],
2538
- tokens=d["tokens"],
2539
- route_statuses=[RouteStatus.__fromdict__(x) for x in d["route_statuses"]],
2540
- score=d["score"],
2541
- num_point_pieces=d.get("num_point_pieces", 0),
2542
- completed_clusters=d.get("completed_clusters", []),
2543
- )
2544
-
2545
-
2546
2463
  class AllottedTime(PClass):
2547
2464
  seconds = field(type=int)
2548
2465
  since_action_idx = field(type=int)
@@ -2598,20 +2515,10 @@ class PublicState(PClass):
2598
2515
  piles = field(type=list) # List[Pile]
2599
2516
  player_idxs = field(type=list) # List[int]
2600
2517
  initial_to_play = field(type=list) # List[int]
2601
- to_play = field(type=list) # List[int]
2602
- unit_discards = field(type=list) # List[int]
2603
- num_route_cards = field(type=int)
2604
- num_route_discards = field(type=int)
2605
- num_unit_cards = field(type=int)
2606
- num_unit_discards = field(type=int)
2607
- faceup_spots = field(type=list) # List[Union{Nothing, int}]
2608
2518
  players = field(type=list) # List[PublicPlayer]
2609
- player_hands = field(type=list) # List[PublicPlayerInfo]
2610
2519
  last_to_play = field(type=(int, type(None)), initial=None)
2611
2520
  winners = field(type=list)
2612
2521
  terminal = field(type=bool)
2613
- captured_points = field(type=list) # List[CapturedPoint]
2614
- captured_segments = field(type=list) # List[CapturedSegment]
2615
2522
  def __todict__(self):
2616
2523
  return {
2617
2524
  "deadlines": [deadline.__todict__() if deadline else None for deadline in self.deadlines],
@@ -2633,20 +2540,10 @@ class PublicState(PClass):
2633
2540
  "piles": [pile.__todict__() for pile in self.piles],
2634
2541
  "player_idxs": self.player_idxs,
2635
2542
  "initial_to_play": self.initial_to_play,
2636
- "to_play": self.to_play,
2637
- "unit_discards": self.unit_discards,
2638
- "num_route_cards": self.num_route_cards,
2639
- "num_route_discards": self.num_route_discards,
2640
- "num_unit_cards": self.num_unit_cards,
2641
- "num_unit_discards": self.num_unit_discards,
2642
- "faceup_spots": self.faceup_spots,
2643
2543
  "players": [x.__todict__() for x in self.players],
2644
- "player_hands": [x.__todict__() for x in self.player_hands],
2645
2544
  "last_to_play": self.last_to_play,
2646
2545
  "winners": self.winners,
2647
2546
  "terminal": self.terminal,
2648
- "captured_points": [x.__todict__() for x in self.captured_points],
2649
- "captured_segments": [x.__todict__() for x in self.captured_segments],
2650
2547
  }
2651
2548
  @staticmethod
2652
2549
  def __fromdict__(d):
@@ -2670,25 +2567,11 @@ class PublicState(PClass):
2670
2567
  piles=[Pile.__fromdict__(x) for x in d["piles"]],
2671
2568
  player_idxs=d["player_idxs"],
2672
2569
  initial_to_play=d["initial_to_play"],
2673
- to_play=d["to_play"],
2674
- unit_discards=d["unit_discards"],
2675
- num_route_cards=d["num_route_cards"],
2676
- num_route_discards=d["num_route_discards"],
2677
- num_unit_cards=d["num_unit_cards"],
2678
- num_unit_discards=d["num_unit_discards"],
2679
- faceup_spots=d["faceup_spots"],
2680
2570
  players=[PublicPlayer.__fromdict__(x) for x in d["players"]],
2681
- player_hands=[PublicPlayerInfo.__fromdict__(x) for x in d["player_hands"]],
2682
2571
  last_to_play=d.get("last_to_play"),
2683
2572
  winners=d["winners"],
2684
2573
  terminal=d["terminal"],
2685
- captured_points=[CapturedPoint.__fromdict__(x) for x in d["captured_points"]],
2686
- captured_segments=[CapturedSegment.__fromdict__(x) for x in d["captured_segments"]],
2687
2574
  )
2688
- # fig::Fig
2689
- # captured_segments::Vector{CapturedSegment}
2690
- # captured_points::Vector{CapturedPoint}
2691
- # market_refills::Vector{MarketRefill}
2692
2575
 
2693
2576
 
2694
2577
  class PlayerState(PClass):
@@ -3001,9 +2884,6 @@ def getinitialstate(game_config):
3001
2884
  route_cards=pvector(route_cards),
3002
2885
  route_discards=pvector([]),
3003
2886
  player_hands=pvector(player_hands),
3004
- unit_cards=pvector(unit_cards),
3005
- unit_discards=pvector([]),
3006
- faceup_spots=pvector(faceup_spots),
3007
2887
  last_to_play=None,
3008
2888
  winners=[],
3009
2889
  terminal=False,
@@ -4590,20 +4470,10 @@ def getpublicstate(s):
4590
4470
  piles=s.piles,
4591
4471
  player_idxs=s.player_idxs,
4592
4472
  initial_to_play=s.initial_to_play,
4593
- to_play=gettoplay(s),
4594
- unit_discards=list(s.unit_discards),
4595
- num_route_cards=len(s.route_cards),
4596
- num_route_discards=len(s.route_discards),
4597
- num_unit_cards=len(s.unit_cards),
4598
- num_unit_discards=len(s.unit_discards),
4599
- faceup_spots=list(s.faceup_spots),
4600
4473
  players=[getpublicplayer(s, p) for p in s.players],
4601
- player_hands=[getpublicplayerinfo(s, p) for p in s.player_hands],
4602
4474
  last_to_play=s.last_to_play,
4603
4475
  winners=s.winners,
4604
4476
  terminal=s.terminal,
4605
- captured_points=getcapturedpoints(s),
4606
- captured_segments=getcapturedsegments(s),
4607
4477
  )
4608
4478
 
4609
4479
 
@@ -4635,31 +4505,6 @@ def getpublicplayer(s, p):
4635
4505
  )
4636
4506
 
4637
4507
 
4638
- @dispatch(State, PlayerInfo)
4639
- def getpublicplayerinfo(s, p):
4640
- # if s.terminal
4641
- # route_statuses = getroutestatuses(p)
4642
- # else
4643
- # route_statuses = []
4644
- # end
4645
- return PublicPlayerInfo(
4646
- final_score=p.final_score,
4647
- longest_trail=p.longest_trail,
4648
- longest_trail_len=p.longest_trail_len,
4649
- num_pieces=p.num_pieces,
4650
- num_route_cards=len(p.route_cards),
4651
- num_new_route_cards=len(p.new_route_cards),
4652
- num_unit_cards=len(p.unit_cards),
4653
- paths=p.paths,
4654
- points=p.points,
4655
- tokens=p.tokens,
4656
- route_statuses=[], # TODO: implement!
4657
- score=getpublicscore(s, p.player_idx),
4658
- num_point_pieces=p.num_point_pieces,
4659
- completed_clusters=p.completed_clusters,
4660
- )
4661
-
4662
-
4663
4508
  # Implementing the following Julia function:
4664
4509
  # function getpublicscore(s::State, player_idx::Int)
4665
4510
  # addends = Int[]
@@ -4978,17 +4823,6 @@ def getrouteoptionsets(s, player_idx, min_required):
4978
4823
  # min_initial_routes = getsettingvalue(s.fig, :min_initial_routes)
4979
4824
  # min_chosen_routes = getsettingvalue(s.fig, :min_chosen_routes)
4980
4825
 
4981
- # # Initial Route Card Discard
4982
- # if getsettingvalue(s, :action_route_discard) && length(s.action_history) < s.game_config.num_players
4983
- # return [
4984
- # ActionSpec(
4985
- # player_idx=player_idx,
4986
- # action_name=ROUTE_DISCARD,
4987
- # return_route_option_sets=getrouteoptionsets(s, player_idx, min_initial_routes),
4988
- # )
4989
- # ]
4990
- # end
4991
-
4992
4826
  # action_specs = ActionSpec[]
4993
4827
  # if getsettingvalue(s, :action_draw_unit_faceup) && !isempty(getvalidspotnums(s))
4994
4828
  # push!(
@@ -5998,21 +5832,7 @@ def printaction(a, i):
5998
5832
  # )
5999
5833
  # end
6000
5834
  # end
6001
-
6002
- # # Longest trail
6003
- # if !getsettingvalue(s, :disable_longest_path_bonus)
6004
- # longest_path_score = getsettingvalue(s.fig, :longest_path_score)
6005
- # if in(player_idx, s.longest_trail_player_idxs)
6006
- # push!(
6007
- # breakdown,
6008
- # ScoreItem(
6009
- # code_idx=getscorecodeidx(s.fig, :LONGEST_ROAD),
6010
- # amount=longest_path_score,
6011
- # )
6012
- # )
6013
- # end
6014
- # end
6015
-
5835
+ #
6016
5836
  # # Completed routes
6017
5837
  # if getsettingvalue(s, :route_scoring)
6018
5838
  # hand = s.player_hands[player_idx]
@@ -6245,74 +6065,6 @@ def getlegalactionspecs(s, player_idxs):
6245
6065
  return legal_actions
6246
6066
 
6247
6067
 
6248
- # Implementing the following Julia function:
6249
- # function getcapturedsegments(s::State)
6250
- # (; fig) = s
6251
- # (; board_config) = fig
6252
- # public_player_hands = PublicPlayerInfo.(s, s.player_hands)
6253
- # (; board_paths) = board_config
6254
- # captured_segments = CapturedSegment[]
6255
- # for (player_num, player_hand) in enumerate(public_player_hands)
6256
- # for path_num in player_hand.paths
6257
- # link_path = board_paths[path_num].path
6258
- # for segment in link_path.segments
6259
- # captured_segment = CapturedSegment(
6260
- # player_num,
6261
- # segment.uuid,
6262
- # )
6263
- # push!(captured_segments, captured_segment)
6264
- # end
6265
- # end
6266
- # end
6267
- # captured_segments
6268
- # end
6269
- @dispatch(State)
6270
- def getcapturedsegments(s):
6271
- public_player_hands = [getpublicplayerinfo(s, p) for p in s.player_hands]
6272
- board_paths = s.game_config.fig.board_config.board_paths
6273
- captured_segments = []
6274
- for player_idx, player_hand in enumerate(public_player_hands):
6275
- for path_idx in player_hand.paths:
6276
- link_path = board_paths[path_idx].path
6277
- for segment in link_path.segments:
6278
- captured_segment = CapturedSegment(
6279
- player_num=(player_idx+1),
6280
- segment_uuid=segment.uuid,
6281
- )
6282
- captured_segments.append(captured_segment)
6283
- return captured_segments
6284
-
6285
-
6286
- # Implementing the following Julia function:
6287
- # function getcapturedpoints(s::State)
6288
- # (; fig) = s
6289
- # public_player_hands = PublicPlayerInfo.(s, s.player_hands)
6290
- # captured_points = CapturedPoint[]
6291
- # for (player_num, player_hand) in enumerate(public_player_hands)
6292
- # for point_uuid in player_hand.points
6293
- # captured_point = CapturedPoint(
6294
- # player_num,
6295
- # point_uuid,
6296
- # )
6297
- # push!(captured_points, captured_point)
6298
- # end
6299
- # end
6300
- # captured_points
6301
- # end
6302
- @dispatch(State)
6303
- def getcapturedpoints(s):
6304
- public_player_hands = [getpublicplayerinfo(s, p) for p in s.player_hands]
6305
- captured_points = []
6306
- for player_idx, player_hand in enumerate(public_player_hands):
6307
- for point_uuid in player_hand.points:
6308
- captured_point = CapturedPoint(
6309
- player_num=player_idx+1,
6310
- point_uuid=point_uuid,
6311
- )
6312
- captured_points.append(captured_point)
6313
- return captured_points
6314
-
6315
-
6316
6068
  def json_serializer(obj):
6317
6069
  if isinstance(obj, set):
6318
6070
  return list(obj)
@@ -6556,9 +6308,9 @@ def get_imagined_state(static_board_config, player_state):
6556
6308
  remove_card_idx(to_mutate, card_idx)
6557
6309
 
6558
6310
 
6559
- imagined_route_card_idxs = rng.sample(possible_route_card_idxs, public_state.num_route_cards)
6311
+ # imagined_route_card_idxs = rng.sample(possible_route_card_idxs, public_state.num_route_cards)
6560
6312
  remove_card_idxs(possible_route_card_idxs, imagined_route_card_idxs)
6561
- imagined_route_discard_idxs = rng.sample(possible_route_card_idxs, public_state.num_route_discards)
6313
+ # imagined_route_discard_idxs = rng.sample(possible_route_card_idxs, public_state.num_route_discards)
6562
6314
  remove_card_idxs(possible_route_card_idxs, imagined_route_discard_idxs)
6563
6315
 
6564
6316
  imagined_route_cards = [x+1 for x in imagined_route_card_idxs]
@@ -6570,9 +6322,9 @@ def get_imagined_state(static_board_config, player_state):
6570
6322
  for unit_card in my_hand.unit_cards:
6571
6323
  remove_card_idx(possible_unit_card_idxs, unit_card-1)
6572
6324
 
6573
- imagined_unit_card_idxs = rng.sample(possible_unit_card_idxs, public_state.num_unit_cards)
6574
- imagined_unit_cards = [x+1 for x in imagined_unit_card_idxs]
6575
- remove_card_idxs(possible_unit_card_idxs, imagined_unit_card_idxs)
6325
+ # imagined_unit_card_idxs = rng.sample(possible_unit_card_idxs, public_state.num_unit_cards)
6326
+ # imagined_unit_cards = [x+1 for x in imagined_unit_card_idxs]
6327
+ # remove_card_idxs(possible_unit_card_idxs, imagined_unit_card_idxs)
6576
6328
 
6577
6329
 
6578
6330
  imagined_player_hands = []
@@ -6581,10 +6333,10 @@ def get_imagined_state(static_board_config, player_state):
6581
6333
  if player_idx == my_hand.player_idx:
6582
6334
  imagined_player_hands.append(PlayerInfo.clone(my_hand))
6583
6335
  else:
6584
- imagined_player_unit_card_idxs = rng.sample(possible_unit_card_idxs, public_player_info.num_unit_cards)
6336
+ # imagined_player_unit_card_idxs = rng.sample(possible_unit_card_idxs, public_player_info.num_unit_cards)
6585
6337
  imagined_player_unit_cards = [x+1 for x in imagined_player_unit_card_idxs]
6586
6338
  remove_card_idxs(possible_unit_card_idxs, imagined_player_unit_card_idxs)
6587
- imagined_player_route_card_idxs = rng.sample(possible_route_card_idxs, public_player_info.num_route_cards)
6339
+ # imagined_player_route_card_idxs = rng.sample(possible_route_card_idxs, public_player_info.num_route_cards)
6588
6340
  remove_card_idxs(possible_route_card_idxs, imagined_player_route_card_idxs)
6589
6341
  imagined_player_new_route_card_idxs = rng.sample(possible_route_card_idxs, public_player_info.num_new_route_cards)
6590
6342
  remove_card_idxs(possible_route_card_idxs, imagined_player_new_route_card_idxs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: graph_games_proto
3
- Version: 0.3.1865
3
+ Version: 0.3.1866
4
4
  Requires-Dist: multipledispatch==1.0.0
5
5
  Requires-Dist: pyrsistent==0.20.0
6
6
  Requires-Dist: numpy==2.2.4
@@ -1,9 +1,9 @@
1
1
  graph_games_proto/__init__.py,sha256=O5XjRfe3DlxbJn4zezDvvy7cXvL4IzIRPZCL3Y-n7s8,776
2
2
  graph_games_proto/all_types.py,sha256=IpbwftEcHS5Ewz-saFNk0lO9FvcbuHG36odRTayCXUk,54911
3
- graph_games_proto/fns.py,sha256=PJUsPdN8ztl9yFVr3c2RC2M0A5gEK9IvdN1RHEauD4A,242723
3
+ graph_games_proto/fns.py,sha256=5BJ0dY9mk4e0hoMBdyJyxsEvPvy8bFgP4vtdCtrnoKY,232658
4
4
  graph_games_proto/main.py,sha256=fj2U7KcwrpZtuUhjOX5yVxY18LZvvsxDFYZ_S5mxe04,145
5
5
  graph_games_proto/state.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- graph_games_proto-0.3.1865.dist-info/METADATA,sha256=WeOSB_09jBe0pkxkIF2IjrMxECzJnvismkPqD8n7obw,188
7
- graph_games_proto-0.3.1865.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
- graph_games_proto-0.3.1865.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
- graph_games_proto-0.3.1865.dist-info/RECORD,,
6
+ graph_games_proto-0.3.1866.dist-info/METADATA,sha256=NyOtxe3kFzamm50WU8vuNk9VdjbnbuoQkgWnZNAZPm8,188
7
+ graph_games_proto-0.3.1866.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
+ graph_games_proto-0.3.1866.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
+ graph_games_proto-0.3.1866.dist-info/RECORD,,