new file: CTF/.ipynb_checkpoints/fixed_map_example-checkpoint.png new file: CTF/.ipynb_checkpoints/random_map_example-checkpoint.png new file: CTF/CTF/README.md new file: CTF/CTF/backend/example_init.json new file: CTF/CTF/backend/example_plan_next_actions.json new file: CTF/CTF/backend/lib/game_engine.py new file: CTF/CTF/backend/main.ipynb new file: CTF/CTF/backend/pick_closest_flag.py new file: CTF/CTF/backend/pick_flag_ai.py new file: CTF/CTF/backend/python_tutorial.ipynb new file: CTF/CTF/backend/start.sh new file: CTF/CTF/backend/test_lib.ipynb new file: CTF/CTF/fixed_map_example.png new file: CTF/CTF/frontend/assets/characters.png new file: CTF/CTF/frontend/assets/characters_red_flag.png new file: CTF/CTF/frontend/assets/characters_yellow_flag.png new file: CTF/CTF/frontend/assets/red_flag_16_16.png new file: CTF/CTF/frontend/assets/red_flag_32_32.png new file: CTF/CTF/frontend/assets/tilemap.json new file: CTF/CTF/frontend/assets/tilemap.tmx new file: CTF/CTF/frontend/assets/tiles.png new file: CTF/CTF/frontend/assets/yellow_flag_16_16.png new file: CTF/CTF/frontend/assets/yellow_flag_32_32.png new file: CTF/CTF/frontend/game_config.json new file: CTF/CTF/frontend/index.html new file: CTF/CTF/frontend/phaser.js new file: CTF/CTF/frontend/project.config new file: CTF/CTF/frontend/src/assets.js new file: CTF/CTF/frontend/src/gameObjects/Flag.js new file: CTF/CTF/frontend/src/gameObjects/Player.js new file: CTF/CTF/frontend/src/main.js new file: CTF/CTF/frontend/src/scenes/Boot.js new file: CTF/CTF/frontend/src/scenes/Game.js new file: CTF/CTF/frontend/src/scenes/GameOver.js new file: CTF/CTF/frontend/src/scenes/Preloader.js new file: CTF/CTF/frontend/start.sh new file: CTF/CTF/random_map_example.png new file: CTF/README.md new file: CTF/backend/.ipynb_checkpoints/main-checkpoint.ipynb new file: CTF/backend/.ipynb_checkpoints/pick_closest_flag-checkpoint.py new file: CTF/backend/.ipynb_checkpoints/pick_flag_ai-checkpoint.py new file: CTF/backend/.ipynb_checkpoints/python_tutorial-checkpoint.ipynb new file: CTF/backend/.ipynb_checkpoints/start-checkpoint.sh new file: CTF/backend/.ipynb_checkpoints/test_lib-checkpoint.ipynb new file: CTF/backend/example_init.json new file: CTF/backend/example_plan_next_actions.json new file: CTF/backend/lib/__pycache__/game_engine.cpython-313.pyc new file: CTF/backend/lib/game_engine.py new file: CTF/backend/main.ipynb new file: CTF/backend/pick_closest_flag.py new file: CTF/backend/pick_flag_ai.py new file: CTF/backend/python_tutorial.ipynb new file: CTF/backend/start.sh new file: CTF/backend/test_lib.ipynb new file: CTF/fixed_map_example.png new file: CTF/frontend/.ipynb_checkpoints/game_config-checkpoint.json new file: CTF/frontend/assets/.ipynb_checkpoints/tilemap-checkpoint.json new file: CTF/frontend/assets/characters.png new file: CTF/frontend/assets/characters_red_flag.png new file: CTF/frontend/assets/characters_yellow_flag.png new file: CTF/frontend/assets/red_flag_16_16.png new file: CTF/frontend/assets/red_flag_32_32.png new file: CTF/frontend/assets/tilemap.json new file: CTF/frontend/assets/tilemap.tmx new file: CTF/frontend/assets/tiles.png new file: CTF/frontend/assets/yellow_flag_16_16.png new file: CTF/frontend/assets/yellow_flag_32_32.png new file: CTF/frontend/game_config.json new file: CTF/frontend/index.html new file: CTF/frontend/phaser.js new file: CTF/frontend/project.config new file: CTF/frontend/src/assets.js new file: CTF/frontend/src/gameObjects/Flag.js new file: CTF/frontend/src/gameObjects/Player.js new file: CTF/frontend/src/main.js new file: CTF/frontend/src/scenes/Boot.js new file: CTF/frontend/src/scenes/Game.js new file: CTF/frontend/src/scenes/GameOver.js new file: CTF/frontend/src/scenes/Preloader.js new file: CTF/frontend/start.sh new file: CTF/random_map_example.png
186 lines
8.2 KiB
Plaintext
186 lines
8.2 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "21c8be3f-c57b-439c-8ca8-5991dd0da465",
|
|
"metadata": {},
|
|
"source": [
|
|
"# 夺旗赛 Capture The Flag Test"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "0dfeabca-44d9-4906-abc6-cba1e4fc8a35",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 初始化 (使用上排目录栏的的 ▶️ 运行,▪️停止,⟳ 重启)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"id": "dfde1bf2-03b7-4f8c-8eff-07f486bfe520",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import importlib\n",
|
|
"import lib.game_engine\n",
|
|
"\n",
|
|
"# Force the reload manually\n",
|
|
"importlib.reload(lib.game_engine)\n",
|
|
"\n",
|
|
"# Re-import the specific classes/functions\n",
|
|
"from lib.game_engine import GameMap, run_game_server\n",
|
|
"\n",
|
|
"# Now initialize your objects\n",
|
|
"world = GameMap()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"id": "a3f08c96-ce25-43c5-97e6-955e6fc67746",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"\n",
|
|
"def load_example_json():\n",
|
|
" with open(\"example_init.json\", \"r\") as fin:\n",
|
|
" init_data = json.load(fin)\n",
|
|
" world.init(init_data)\n",
|
|
"\n",
|
|
" with open(\"example_plan_next_actions.json\", \"r\") as fin:\n",
|
|
" status_data = json.load(fin)\n",
|
|
" \n",
|
|
" world.init(init_data)\n",
|
|
" world.update(status_data)\n",
|
|
" world.show()\n",
|
|
" # world.show(flag_over_target=True, player_over_prison=True) "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"id": "b0eeca91-8a45-4c1f-8418-d5593968dd99",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
" 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19\n",
|
|
" 0 ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ \n",
|
|
" 1 ██ LF . . . . . . . . ██ . . . . . R0 . RF ██ \n",
|
|
" 2 ██ LF L0 . . . . . . . . . . . . . R1 . RF ██ \n",
|
|
" 3 ██ LF L1 . . . . . . . . . . . . . R2 . RF ██ \n",
|
|
" 4 ██ LF L2 . . . . . . . . ██ . . . . . . RF ██ \n",
|
|
" 5 ██ LF . . . . . . . ██ . ██ . . . . . . RF ██ \n",
|
|
" 6 ██ LF . . . . . . . . ██ . . . . ██ . . RF ██ \n",
|
|
" 7 ██ . . . . . . . . . . . . . . . . . . ██ \n",
|
|
" 8 ██ . . . . . . . . . . . . . . . . . . ██ \n",
|
|
" 9 ██ TT TT TT . . . . . . . . . . . ██ TT TT TT ██ \n",
|
|
"10 ██ TT TT TT . . . . . . . . . . . . TT TT TT ██ \n",
|
|
"11 ██ TT TT TT . . . . . ██ . . . . ██ . TT TT TT ██ \n",
|
|
"12 ██ . . . . . . . . ██ . . . ██ . . . . . ██ \n",
|
|
"13 ██ . . . . . . . . . . . . . ██ . . . . ██ \n",
|
|
"14 ██ . . . . . . . . . . ██ . . ██ . . . . ██ \n",
|
|
"15 ██ . . . . . . . . . . ██ . . . . . . . ██ \n",
|
|
"16 ██ PP PP PP . . . . . . . . . . . . PP PP PP ██ \n",
|
|
"17 ██ PP PP PP . . . . . . . . . . . . PP PP PP ██ \n",
|
|
"18 ██ PP PP PP . . . . . . ██ . . . . . PP PP PP ██ \n",
|
|
"19 ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ \n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"load_example_json()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"id": "854f32c5-e6cd-420e-ac44-6bf3dfbee646",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"11067.9\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"print(world.current_time)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"id": "e6bca36b-bb07-44c6-8b0a-d740987e5811",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"1000.0\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"print(world.show_gap_in_msec)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"id": "a425410f-c733-4240-a032-0f852f7b8d39",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"{'width': 20, 'height': 20, 'middle_line': 10.0, 'walls': {(4, 0), (19, 0), (8, 0), (14, 13), (19, 9), (10, 6), (0, 5), (5, 19), (19, 18), (11, 5), (0, 14), (11, 14), (7, 19), (18, 19), (19, 2), (19, 11), (0, 7), (9, 19), (0, 16), (13, 19), (19, 4), (0, 0), (11, 0), (9, 12), (0, 9), (15, 0), (13, 12), (15, 9), (1, 19), (17, 0), (19, 6), (9, 5), (3, 19), (14, 19), (0, 2), (16, 19), (5, 0), (11, 4), (7, 0), (18, 0), (9, 0), (14, 14), (10, 1), (13, 0), (19, 13), (15, 6), (10, 19), (0, 18), (12, 19), (1, 0), (19, 15), (0, 11), (3, 0), (14, 0), (19, 8), (0, 4), (16, 0), (19, 17), (0, 13), (2, 19), (6, 19), (14, 11), (4, 19), (19, 1), (19, 10), (0, 6), (19, 19), (8, 19), (0, 15), (11, 15), (19, 3), (10, 0), (19, 12), (9, 11), (0, 8), (10, 18), (0, 17), (12, 0), (19, 5), (0, 1), (19, 14), (0, 10), (0, 19), (11, 19), (15, 19), (19, 7), (0, 3), (2, 0), (19, 16), (17, 19), (0, 12), (6, 0)}, 'players': [{'name': 'L0', 'team': 'L', 'hasFlag': False, 'posX': 2, 'posY': 2, 'inPrison': False, 'inPrisonTimeLeft': 0, 'inPrisonDuration': 20000, 'mine': True}, {'name': 'L1', 'team': 'L', 'hasFlag': False, 'posX': 2, 'posY': 3, 'inPrison': False, 'inPrisonTimeLeft': 0, 'inPrisonDuration': 20000, 'mine': True}, {'name': 'L2', 'team': 'L', 'hasFlag': False, 'posX': 2, 'posY': 4, 'inPrison': False, 'inPrisonTimeLeft': 0, 'inPrisonDuration': 20000, 'mine': True}, {'name': 'R0', 'team': 'R', 'hasFlag': False, 'posX': 16, 'posY': 1, 'inPrison': False, 'inPrisonTimeLeft': 0, 'inPrisonDuration': 20000, 'mine': False}, {'name': 'R1', 'team': 'R', 'hasFlag': False, 'posX': 16, 'posY': 2, 'inPrison': False, 'inPrisonTimeLeft': 0, 'inPrisonDuration': 20000, 'mine': False}, {'name': 'R2', 'team': 'R', 'hasFlag': False, 'posX': 16, 'posY': 3, 'inPrison': False, 'inPrisonTimeLeft': 0, 'inPrisonDuration': 20000, 'mine': False}], 'flags': [{'canPickup': True, 'posX': 1, 'posY': 1, 'mine': True}, {'canPickup': True, 'posX': 1, 'posY': 2, 'mine': True}, {'canPickup': True, 'posX': 1, 'posY': 3, 'mine': True}, {'canPickup': True, 'posX': 1, 'posY': 4, 'mine': True}, {'canPickup': True, 'posX': 1, 'posY': 5, 'mine': True}, {'canPickup': True, 'posX': 1, 'posY': 6, 'mine': True}, {'canPickup': True, 'posX': 18, 'posY': 1, 'mine': False}, {'canPickup': True, 'posX': 18, 'posY': 2, 'mine': False}, {'canPickup': True, 'posX': 18, 'posY': 3, 'mine': False}, {'canPickup': True, 'posX': 18, 'posY': 4, 'mine': False}, {'canPickup': True, 'posX': 18, 'posY': 5, 'mine': False}, {'canPickup': True, 'posX': 18, 'posY': 6, 'mine': False}], 'current_time': 11067.9, 'next_show_time': 12067.9, 'my_team_name': 'L', 'show_gap_in_msec': 1000.0, 'my_team_prison': {(1, 18), (2, 17), (3, 17), (2, 16), (3, 16), (1, 17), (2, 18), (1, 16), (3, 18)}, 'opponent_team_prison': {(17, 17), (18, 17), (16, 16), (17, 16), (18, 16), (18, 18), (16, 18), (17, 18), (16, 17)}, 'my_team_target': {(1, 11), (2, 10), (3, 10), (2, 9), (3, 9), (1, 10), (2, 11), (1, 9), (3, 11)}, 'opponent_team_target': {(16, 10), (17, 10), (18, 10), (16, 9), (17, 9), (18, 9), (17, 11), (18, 11), (16, 11)}}\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# print all the variables in `world`\n",
|
|
"print(world.__dict__)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "010b21df-067a-4576-aedc-a3b6b8045da1",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.13.11"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|