|
691 | 691 | "\n", |
692 | 692 | "```\n", |
693 | 693 | "⬜ ⬜ 🔴 ⬜ ⬜\n", |
| 694 | + "⬜ ⬜ ⬜ ⬜ ⬜\n", |
694 | 695 | "⬜ ⬜ ⬜ ⬜ ⬜ Ball\n", |
| 696 | + "⬜ ⬜ ⬜ ⬜ ⬜\n", |
695 | 697 | "⬜ ⬜ ⬜ ⬜ ⬜ falls\n", |
| 698 | + "⬜ ⬜ ⬜ ⬜ ⬜\n", |
696 | 699 | "⬜ ⬜ ⬜ ⬜ ⬜ down\n", |
| 700 | + "⬜ ⬜ ⬜ ⬜ ⬜\n", |
| 701 | + "⬜ ⬜ ⬜ ⬜ ⬜\n", |
697 | 702 | "⬜ ⬜ 🏓 ⬜ ⬜\n", |
698 | 703 | " Paddle\n", |
699 | 704 | "```\n", |
|
702 | 707 | "<td width=\"60%\">\n", |
703 | 708 | "\n", |
704 | 709 | "**Rules:**\n", |
705 | | - "- 5×5 grid\n", |
| 710 | + "- 10×5 grid\n", |
706 | 711 | "- Ball falls from random column\n", |
707 | 712 | "- Move paddle left/right to catch it\n", |
708 | 713 | "\n", |
|
817 | 822 | " \"OPENSPIEL_GAME\": \"catch\",\n", |
818 | 823 | " \"OPENSPIEL_AGENT_PLAYER\": \"0\",\n", |
819 | 824 | " \"OPENSPIEL_OPPONENT_POLICY\": \"random\"},\n", |
820 | | - " stdout=subprocess.PIPE,\n", |
821 | | - " stderr=subprocess.PIPE,\n", |
| 825 | + " stdout=subprocess.DEVNULL,\n", |
| 826 | + " stderr=subprocess.DEVNULL,\n", |
822 | 827 | " text=True,\n", |
823 | 828 | " cwd=work_dir\n", |
824 | 829 | ")\n", |
|
895 | 900 | "\n", |
896 | 901 | "print(\"📥 Received OpenSpielObservation:\")\n", |
897 | 902 | "print(f\" • info_state: {result.observation.info_state[:10]}... (first 10 values)\")\n", |
| 903 | + "print(f\" • number of info_state: {len(result.observation.info_state)}\")\n", |
898 | 904 | "print(f\" • legal_actions: {result.observation.legal_actions}\")\n", |
899 | 905 | "print(f\" • game_phase: {result.observation.game_phase}\")\n", |
900 | 906 | "print(f\" • done: {result.done}\")\n", |
|
1006 | 1012 | "\n", |
1007 | 1013 | " def select_action(self, obs: OpenSpielObservation) -> int:\n", |
1008 | 1014 | " # Parse OpenSpiel observation\n", |
1009 | | - " # For Catch: info_state is a flattened 5x5 grid\n", |
| 1015 | + " # For Catch: info_state is a flattened 10x5 grid\n", |
1010 | 1016 | " # Ball position and paddle position encoded in the vector\n", |
1011 | 1017 | " info_state = obs.info_state\n", |
1012 | 1018 | "\n", |
1013 | 1019 | " # Find ball and paddle positions from info_state\n", |
1014 | | - " # Catch uses a 5x5 grid, so 25 values\n", |
| 1020 | + " # Catch uses a 10x5 grid, so 50 values\n", |
1015 | 1021 | " grid_size = 5\n", |
1016 | 1022 | "\n", |
1017 | | - " # Find positions (ball = 1.0, paddle = 0.5 in the flattened grid)\n", |
| 1023 | + " # Find positions (ball = 1.0 in the flattened grid, paddle = 1.0 in the last row of the flattened grid)\n", |
1018 | 1024 | " ball_col = None\n", |
1019 | 1025 | " paddle_col = None\n", |
1020 | 1026 | "\n", |
1021 | 1027 | " for idx, val in enumerate(info_state):\n", |
1022 | 1028 | " if abs(val - 1.0) < 0.01: # Ball\n", |
1023 | 1029 | " ball_col = idx % grid_size\n", |
1024 | | - " elif abs(val - 0.5) < 0.01: # Paddle\n", |
1025 | | - " paddle_col = idx % grid_size\n", |
| 1030 | + " break\n", |
| 1031 | + "\n", |
| 1032 | + " last_row = info_state[-grid_size:]\n", |
| 1033 | + " paddle_col = last_row.index(1.0) # Paddle\n", |
1026 | 1034 | "\n", |
1027 | 1035 | " if ball_col is not None and paddle_col is not None:\n", |
1028 | 1036 | " if paddle_col < ball_col:\n", |
|
0 commit comments