Spatialworld commited on
Commit
2c15e1f
·
verified ·
1 Parent(s): ab30cc7

Delete game with huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. game/data/Block3D/__init__.py +0 -0
  2. game/data/Block3D/__pycache__/__init__.cpython-313.pyc +0 -0
  3. game/data/Block3D/__pycache__/generate.cpython-313.pyc +0 -0
  4. game/data/Block3D/__pycache__/level_data.cpython-313.pyc +0 -0
  5. game/data/Block3D/generate.py +0 -57
  6. game/data/Block3D/level_data.py +0 -1
  7. game/data/__init__.py +0 -0
  8. game/data/__pycache__/__init__.cpython-313.pyc +0 -0
  9. game/data/maze3d/Level_01.png +0 -3
  10. game/data/maze3d/Level_01.txt +0 -5
  11. game/data/maze3d/Level_02.png +0 -3
  12. game/data/maze3d/Level_02.txt +0 -5
  13. game/data/maze3d/Level_03.png +0 -3
  14. game/data/maze3d/Level_03.txt +0 -5
  15. game/data/maze3d/Level_04.png +0 -3
  16. game/data/maze3d/Level_04.txt +0 -7
  17. game/data/maze3d/Level_05.png +0 -3
  18. game/data/maze3d/Level_05.txt +0 -7
  19. game/data/maze3d/Level_06.png +0 -3
  20. game/data/maze3d/Level_06.txt +0 -7
  21. game/data/maze3d/Level_07.png +0 -3
  22. game/data/maze3d/Level_07.txt +0 -7
  23. game/data/maze3d/Level_08.png +0 -3
  24. game/data/maze3d/Level_08.txt +0 -7
  25. game/data/maze3d/Level_09.png +0 -3
  26. game/data/maze3d/Level_09.txt +0 -9
  27. game/data/maze3d/Level_10.png +0 -3
  28. game/data/maze3d/Level_10.txt +0 -9
  29. game/data/maze3d/Level_11.png +0 -3
  30. game/data/maze3d/Level_11.txt +0 -9
  31. game/data/maze3d/Level_12.png +0 -3
  32. game/data/maze3d/Level_12.txt +0 -9
  33. game/data/maze3d/Level_13.png +0 -3
  34. game/data/maze3d/Level_13.txt +0 -11
  35. game/data/maze3d/Level_14.png +0 -3
  36. game/data/maze3d/Level_14.txt +0 -11
  37. game/data/maze3d/Level_15.png +0 -3
  38. game/data/maze3d/Level_15.txt +0 -11
  39. game/data/maze3d/Level_16.png +0 -3
  40. game/data/maze3d/Level_16.txt +0 -11
  41. game/data/maze3d/Level_17.png +0 -3
  42. game/data/maze3d/Level_17.txt +0 -11
  43. game/data/maze3d/Level_18.png +0 -3
  44. game/data/maze3d/Level_18.txt +0 -13
  45. game/data/maze3d/Level_19.png +0 -3
  46. game/data/maze3d/Level_19.txt +0 -13
  47. game/data/maze3d/Level_20.png +0 -3
  48. game/data/maze3d/Level_20.txt +0 -13
  49. game/data/maze3d/__pycache__/generate.cpython-313.pyc +0 -0
  50. game/data/maze3d/generate.py +0 -202
game/data/Block3D/__init__.py DELETED
File without changes
game/data/Block3D/__pycache__/__init__.cpython-313.pyc DELETED
Binary file (179 Bytes)
 
game/data/Block3D/__pycache__/generate.cpython-313.pyc DELETED
Binary file (5.41 kB)
 
game/data/Block3D/__pycache__/level_data.cpython-313.pyc DELETED
Binary file (3.4 kB)
 
game/data/Block3D/generate.py DELETED
@@ -1,57 +0,0 @@
1
- import random
2
- STATIC_LEVELS = [{'name': '入门 - 一字型 (2块)', 'blocks': [(2, 2, 0), (3, 2, 0)]}, {'name': '简单 - 椅子 (4块)', 'blocks': [(2, 2, 0), (2, 3, 0), (2, 2, 1), (2, 2, 2)]}, {'name': '中等 - 拱门 (9块)', 'blocks': [(1, 2, 0), (1, 2, 1), (1, 2, 2), (3, 2, 0), (3, 2, 1), (3, 2, 2), (1, 2, 3), (2, 2, 3), (3, 2, 3)]}, {'name': '困难 - 螺旋梯 (10块)', 'blocks': [(2, 2, 0), (2, 3, 0), (3, 3, 0), (3, 2, 0), (3, 1, 1), (2, 1, 1), (1, 1, 1), (1, 2, 1), (1, 3, 2), (2, 3, 2)]}, {'name': '进阶 - 实心立方体 (8块)', 'blocks': [(2, 2, 0), (3, 2, 0), (2, 3, 0), (3, 3, 0), (2, 2, 1), (3, 2, 1), (2, 3, 1), (3, 3, 1)]}, {'name': '进阶 - 金字塔 (15块)', 'blocks': [(1, 1, 0), (2, 1, 0), (3, 1, 0), (1, 2, 0), (2, 2, 0), (3, 2, 0), (1, 3, 0), (2, 3, 0), (3, 3, 0), (2, 1, 1), (1, 2, 1), (2, 2, 1), (3, 2, 1), (2, 3, 1), (2, 2, 2)]}, {'name': '挑战 - 字母 H (10块)', 'blocks': [(1, 2, 0), (1, 2, 1), (1, 2, 2), (1, 2, 3), (3, 2, 0), (3, 2, 1), (3, 2, 2), (3, 2, 3), (2, 2, 1), (2, 2, 2)]}, {'name': '挑战 - 枯井 (16块)', 'blocks': [(1, 1, 0), (2, 1, 0), (3, 1, 0), (1, 3, 0), (2, 3, 0), (3, 3, 0), (1, 2, 0), (3, 2, 0), (1, 1, 1), (2, 1, 1), (3, 1, 1), (1, 3, 1), (2, 3, 1), (3, 3, 1), (1, 2, 1), (3, 2, 1)]}, {'name': '专家 - 浮空十字 (8块)', 'blocks': [(2, 2, 0), (2, 2, 1), (2, 2, 2), (2, 2, 3), (1, 2, 2), (3, 2, 2), (2, 1, 2), (2, 3, 2)]}]
3
-
4
- def generate_random_level_data(num_blocks, grid_size=6):
5
- """Helpers."""
6
- blocks = set()
7
- start_pos = (random.randint(1, grid_size - 2), random.randint(1, grid_size - 2), 0)
8
- blocks.add(start_pos)
9
- attempts = 0
10
- while len(blocks) < num_blocks and attempts < 1000:
11
- attempts += 1
12
- base = random.choice(list(blocks))
13
- bx, by, bz = base
14
- directions = [(1, 0, 0), (-1, 0, 0), (0, 1, 0), (0, -1, 0), (0, 0, 1), (0, 0, -1)]
15
- dx, dy, dz = random.choice(directions)
16
- nx, ny, nz = (bx + dx, by + dy, bz + dz)
17
- if 0 <= nx < grid_size and 0 <= ny < grid_size and (0 <= nz < grid_size):
18
- blocks.add((nx, ny, nz))
19
- return sorted(list(blocks))
20
-
21
- def export_to_file(filename='level_data.py'):
22
- all_levels = []
23
- all_levels.extend(STATIC_LEVELS)
24
- random_counts = [1, 1, 1, 3, 3, 3, 4, 4, 4, 5, 5]
25
- for count in random_counts:
26
- blocks = generate_random_level_data(count)
27
- all_levels.append({'name': f'随机生成 - 未知结构 ({count}块)', 'blocks': blocks})
28
- all_levels.sort(key=lambda x: len(x['blocks']))
29
- with open(filename, 'w', encoding='utf-8') as f:
30
- f.write('# Auto-generated Level Data\n')
31
- f.write('# Sorted by block count (Easy -> Hard)\n\n')
32
- f.write('LEVEL_DESIGNS = {\n')
33
- for index, data in enumerate(all_levels):
34
- new_id = str(index + 1)
35
- block_count = len(data['blocks'])
36
- f.write(f' "{new_id}": {{\n')
37
- f.write(f""" "name": "[Lv.{new_id}] {data['name']} (共{block_count}块)",\n""")
38
- f.write(f' "blocks": [\n')
39
- blocks = data['blocks']
40
- line_buffer = ''
41
- for b in blocks:
42
- s = str(b) + ', '
43
- if len(line_buffer) + len(s) > 80:
44
- f.write(f' {line_buffer}\n')
45
- line_buffer = s
46
- else:
47
- line_buffer += s
48
- if line_buffer:
49
- f.write(f' {line_buffer}\n')
50
- f.write(f' ]\n')
51
- f.write(f' }},\n')
52
- f.write('}\n')
53
- print(f'成功生成 {filename}!')
54
- print(f'共导出 {len(all_levels)} 个关卡,已按物块数量从小到大排序。')
55
- print(f'现在你可以按顺序游玩:python game.py 1, python game.py 2 ...')
56
- if __name__ == '__main__':
57
- export_to_file()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
game/data/Block3D/level_data.py DELETED
@@ -1 +0,0 @@
1
- LEVEL_DESIGNS = {'1': {'name': '[Lv.1] 随机生成 - 未知结构 (1块) (共1块)', 'blocks': [(2, 2, 0)]}, '2': {'name': '[Lv.2] 随机生成 - 未知结构 (1块) (共1块)', 'blocks': [(4, 4, 0)]}, '3': {'name': '[Lv.3] 随机生成 - 未知结构 (1块) (共1块)', 'blocks': [(1, 3, 0)]}, '4': {'name': '[Lv.4] 入门 - 一字型 (2块) (共2块)', 'blocks': [(2, 2, 0), (3, 2, 0)]}, '5': {'name': '[Lv.5] 随机生成 - 未知结构 (3块) (共3块)', 'blocks': [(1, 1, 0), (1, 1, 1), (1, 2, 0)]}, '6': {'name': '[Lv.6] 随机生成 - 未知结构 (3块) (共3块)', 'blocks': [(0, 4, 1), (1, 4, 0), (1, 4, 1)]}, '7': {'name': '[Lv.7] 随机生成 - 未知结构 (3块) (共3块)', 'blocks': [(4, 4, 0), (4, 5, 0), (5, 5, 0)]}, '8': {'name': '[Lv.8] 简单 - 椅子 (4块) (共4块)', 'blocks': [(2, 2, 0), (2, 3, 0), (2, 2, 1), (2, 2, 2)]}, '9': {'name': '[Lv.9] 随机生成 - 未知结构 (4块) (共4块)', 'blocks': [(2, 0, 0), (2, 1, 0), (3, 1, 0), (4, 1, 0)]}, '10': {'name': '[Lv.10] 随机生成 - 未知结构 (4块) (共4块)', 'blocks': [(3, 1, 0), (3, 2, 0), (4, 1, 0), (5, 1, 0)]}, '11': {'name': '[Lv.11] 随机生成 - 未知结构 (4块) (共4块)', 'blocks': [(1, 3, 0), (2, 2, 0), (2, 3, 0), (3, 2, 0)]}, '12': {'name': '[Lv.12] 随机生成 - 未知结构 (5块) (共5块)', 'blocks': [(4, 1, 0), (4, 2, 0), (4, 2, 1), (4, 2, 2), (5, 2, 0)]}, '13': {'name': '[Lv.13] 随机生成 - 未知结构 (5块) (共5块)', 'blocks': [(1, 2, 0), (1, 2, 1), (1, 2, 2), (1, 3, 1), (2, 2, 0)]}, '14': {'name': '[Lv.14] 进阶 - 实心立方体 (8块) (共8块)', 'blocks': [(2, 2, 0), (3, 2, 0), (2, 3, 0), (3, 3, 0), (2, 2, 1), (3, 2, 1), (2, 3, 1), (3, 3, 1)]}, '15': {'name': '[Lv.15] 专家 - 浮空十字 (8块) (共8块)', 'blocks': [(2, 2, 0), (2, 2, 1), (2, 2, 2), (2, 2, 3), (1, 2, 2), (3, 2, 2), (2, 1, 2), (2, 3, 2)]}, '16': {'name': '[Lv.16] 中等 - 拱门 (9块) (共9块)', 'blocks': [(1, 2, 0), (1, 2, 1), (1, 2, 2), (3, 2, 0), (3, 2, 1), (3, 2, 2), (1, 2, 3), (2, 2, 3), (3, 2, 3)]}, '17': {'name': '[Lv.17] 困难 - 螺旋梯 (10块) (共10块)', 'blocks': [(2, 2, 0), (2, 3, 0), (3, 3, 0), (3, 2, 0), (3, 1, 1), (2, 1, 1), (1, 1, 1), (1, 2, 1), (1, 3, 2), (2, 3, 2)]}, '18': {'name': '[Lv.18] 挑战 - 字母 H (10块) (共10块)', 'blocks': [(1, 2, 0), (1, 2, 1), (1, 2, 2), (1, 2, 3), (3, 2, 0), (3, 2, 1), (3, 2, 2), (3, 2, 3), (2, 2, 1), (2, 2, 2)]}, '19': {'name': '[Lv.19] 进阶 - 金字塔 (15块) (共15块)', 'blocks': [(1, 1, 0), (2, 1, 0), (3, 1, 0), (1, 2, 0), (2, 2, 0), (3, 2, 0), (1, 3, 0), (2, 3, 0), (3, 3, 0), (2, 1, 1), (1, 2, 1), (2, 2, 1), (3, 2, 1), (2, 3, 1), (2, 2, 2)]}, '20': {'name': '[Lv.20] 挑战 - 枯井 (16块) (共16块)', 'blocks': [(1, 1, 0), (2, 1, 0), (3, 1, 0), (1, 3, 0), (2, 3, 0), (3, 3, 0), (1, 2, 0), (3, 2, 0), (1, 1, 1), (2, 1, 1), (3, 1, 1), (1, 3, 1), (2, 3, 1), (3, 3, 1), (1, 2, 1), (3, 2, 1)]}}
 
 
game/data/__init__.py DELETED
File without changes
game/data/__pycache__/__init__.cpython-313.pyc DELETED
Binary file (171 Bytes)
 
game/data/maze3d/Level_01.png DELETED

Git LFS Details

  • SHA256: 17b33e70d53b653cc2b370f810528b69cff3ddc8a80d3165f8593943f11b1243
  • Pointer size: 129 Bytes
  • Size of remote file: 7.89 kB
game/data/maze3d/Level_01.txt DELETED
@@ -1,5 +0,0 @@
1
- #####
2
- # S#
3
- # ###
4
- #E #
5
- #####
 
 
 
 
 
 
game/data/maze3d/Level_02.png DELETED

Git LFS Details

  • SHA256: 3205e35b3042842c3687ef8b6eec9b51915e26203fe3b4b577edc49c3eea6221
  • Pointer size: 129 Bytes
  • Size of remote file: 8.03 kB
game/data/maze3d/Level_02.txt DELETED
@@ -1,5 +0,0 @@
1
- #####
2
- # #S#
3
- # # #
4
- #E #
5
- #####
 
 
 
 
 
 
game/data/maze3d/Level_03.png DELETED

Git LFS Details

  • SHA256: 2f2c07e30e9c7b03a29950d0d0b866042a454073caf36fa3641be25ae66cfb0c
  • Pointer size: 129 Bytes
  • Size of remote file: 8.05 kB
game/data/maze3d/Level_03.txt DELETED
@@ -1,5 +0,0 @@
1
- #####
2
- #S #
3
- ### #
4
- # E#
5
- #####
 
 
 
 
 
 
game/data/maze3d/Level_04.png DELETED

Git LFS Details

  • SHA256: f382c4fbb80d82f79de968c1efb5384c86b3763fd65032b06cfba913771938e0
  • Pointer size: 129 Bytes
  • Size of remote file: 7.93 kB
game/data/maze3d/Level_04.txt DELETED
@@ -1,7 +0,0 @@
1
- #######
2
- # E#
3
- # ### #
4
- # # #
5
- # # ###
6
- #S# #
7
- #######
 
 
 
 
 
 
 
 
game/data/maze3d/Level_05.png DELETED

Git LFS Details

  • SHA256: 783f9203f51844394c4bdab591674c862b0eceb015dd1959828bd353008ad10d
  • Pointer size: 129 Bytes
  • Size of remote file: 7.93 kB
game/data/maze3d/Level_05.txt DELETED
@@ -1,7 +0,0 @@
1
- #######
2
- #S #
3
- ##### #
4
- # # #
5
- # ### #
6
- # E#
7
- #######
 
 
 
 
 
 
 
 
game/data/maze3d/Level_06.png DELETED

Git LFS Details

  • SHA256: eabd3f3a4218852c2cece292a3840e3400358de556d19e1f49c6201a21903cfa
  • Pointer size: 129 Bytes
  • Size of remote file: 8.03 kB
game/data/maze3d/Level_06.txt DELETED
@@ -1,7 +0,0 @@
1
- #######
2
- # E#
3
- ##### #
4
- # #
5
- # ### #
6
- #S# #
7
- #######
 
 
 
 
 
 
 
 
game/data/maze3d/Level_07.png DELETED

Git LFS Details

  • SHA256: 35746117826f3d1ed7cda730c8a7169e7e6681e09ccd64606facfbabd22a0c7a
  • Pointer size: 129 Bytes
  • Size of remote file: 7.92 kB
game/data/maze3d/Level_07.txt DELETED
@@ -1,7 +0,0 @@
1
- #######
2
- #S# #
3
- # # # #
4
- # # # #
5
- # ### #
6
- # E#
7
- #######
 
 
 
 
 
 
 
 
game/data/maze3d/Level_08.png DELETED

Git LFS Details

  • SHA256: 4fe79ba99785ee9c24cc074e3c0d9dd6b2a3ec23ff367a87d1a5a209d6f5735d
  • Pointer size: 129 Bytes
  • Size of remote file: 8.2 kB
game/data/maze3d/Level_08.txt DELETED
@@ -1,7 +0,0 @@
1
- #######
2
- #S# #
3
- # # # #
4
- # # # #
5
- # # # #
6
- # #E#
7
- #######
 
 
 
 
 
 
 
 
game/data/maze3d/Level_09.png DELETED

Git LFS Details

  • SHA256: eb12f49f037eb5df53fed9e1273405d33f9b7640fdf2eea02fb52f840026c85f
  • Pointer size: 129 Bytes
  • Size of remote file: 8.31 kB
game/data/maze3d/Level_09.txt DELETED
@@ -1,9 +0,0 @@
1
- #########
2
- #S # #
3
- ##### # #
4
- # # # #
5
- # # # # #
6
- # # # # #
7
- # ### # #
8
- # E#
9
- #########
 
 
 
 
 
 
 
 
 
 
game/data/maze3d/Level_10.png DELETED

Git LFS Details

  • SHA256: 05fd423d8e999537ce072b6117a0942b3969a84a7fa88ff6c90cc82969bda668
  • Pointer size: 129 Bytes
  • Size of remote file: 8.25 kB
game/data/maze3d/Level_10.txt DELETED
@@ -1,9 +0,0 @@
1
- #########
2
- # S#
3
- # #######
4
- # # #
5
- # ### ###
6
- # # #
7
- ### ### #
8
- #E #
9
- #########
 
 
 
 
 
 
 
 
 
 
game/data/maze3d/Level_11.png DELETED

Git LFS Details

  • SHA256: f6fde0e956704f7de806c6d5a37b35748739ed9176b0675695404b6d0d2b6060
  • Pointer size: 129 Bytes
  • Size of remote file: 8 kB
game/data/maze3d/Level_11.txt DELETED
@@ -1,9 +0,0 @@
1
- #########
2
- # E#
3
- # ##### #
4
- # # # #
5
- # ### # #
6
- # # #
7
- ####### #
8
- #S #
9
- #########
 
 
 
 
 
 
 
 
 
 
game/data/maze3d/Level_12.png DELETED

Git LFS Details

  • SHA256: 72ec6275da3e23b168bbd0a3bcfe21f42d0993485705ddb3ac18f612f9cab7b7
  • Pointer size: 129 Bytes
  • Size of remote file: 8.31 kB
game/data/maze3d/Level_12.txt DELETED
@@ -1,9 +0,0 @@
1
- #########
2
- # E#
3
- # # #####
4
- # # # #
5
- # ### # #
6
- # # #
7
- ####### #
8
- #S #
9
- #########
 
 
 
 
 
 
 
 
 
 
game/data/maze3d/Level_13.png DELETED

Git LFS Details

  • SHA256: 37cfa95d332731ae54dc3f034d9dd5c7b43f4b5183c39568160a476fc1f08bf9
  • Pointer size: 129 Bytes
  • Size of remote file: 8.16 kB
game/data/maze3d/Level_13.txt DELETED
@@ -1,11 +0,0 @@
1
- ###########
2
- #S# #
3
- # # ### # #
4
- # # # # #
5
- # ##### # #
6
- # # # #
7
- ##### # ###
8
- # # # #
9
- # ### ### #
10
- # E#
11
- ###########
 
 
 
 
 
 
 
 
 
 
 
 
game/data/maze3d/Level_14.png DELETED

Git LFS Details

  • SHA256: 370c42d645f56b8ee75ec538820834c952939f72fc43e18b005213d3e78830d4
  • Pointer size: 129 Bytes
  • Size of remote file: 8.21 kB
game/data/maze3d/Level_14.txt DELETED
@@ -1,11 +0,0 @@
1
- ###########
2
- #S #
3
- ######### #
4
- # #
5
- # #########
6
- # # #
7
- # ####### #
8
- # #
9
- ######### #
10
- # E#
11
- ###########
 
 
 
 
 
 
 
 
 
 
 
 
game/data/maze3d/Level_15.png DELETED

Git LFS Details

  • SHA256: 6362e97be34eb85878f57bd69d2f24e5b0ca99276463796bd0556f0e6011647e
  • Pointer size: 129 Bytes
  • Size of remote file: 8.43 kB
game/data/maze3d/Level_15.txt DELETED
@@ -1,11 +0,0 @@
1
- ###########
2
- #S # # #
3
- ### # # # #
4
- # # # # #
5
- # ### # # #
6
- # # # #
7
- ### ##### #
8
- # # # #
9
- # ##### # #
10
- # E#
11
- ###########
 
 
 
 
 
 
 
 
 
 
 
 
game/data/maze3d/Level_16.png DELETED

Git LFS Details

  • SHA256: 1641e6848aa5cf6b0331dbf55379248fd3014a50553d54ec4583afb481ea7cae
  • Pointer size: 129 Bytes
  • Size of remote file: 8.42 kB
game/data/maze3d/Level_16.txt DELETED
@@ -1,11 +0,0 @@
1
- ###########
2
- #S# #
3
- # # # ### #
4
- # # # # #
5
- # # # # ###
6
- # # # # # #
7
- # ### # # #
8
- # # #
9
- ######### #
10
- # E#
11
- ###########
 
 
 
 
 
 
 
 
 
 
 
 
game/data/maze3d/Level_17.png DELETED

Git LFS Details

  • SHA256: c84d15fb0f731ecfe49d78d76855a876984b4123c737bbbc299345dd0c51d433
  • Pointer size: 129 Bytes
  • Size of remote file: 8.36 kB
game/data/maze3d/Level_17.txt DELETED
@@ -1,11 +0,0 @@
1
- ###########
2
- #S# # #
3
- # # ### # #
4
- # # # # #
5
- # # # ### #
6
- # # # # #
7
- # # # ### #
8
- # # #
9
- ######### #
10
- # E#
11
- ###########
 
 
 
 
 
 
 
 
 
 
 
 
game/data/maze3d/Level_18.png DELETED

Git LFS Details

  • SHA256: 0306d953996ef121edbd21ec22d10411e4a667a53eb73e2380422de671ef0c22
  • Pointer size: 129 Bytes
  • Size of remote file: 8.59 kB
game/data/maze3d/Level_18.txt DELETED
@@ -1,13 +0,0 @@
1
- #############
2
- #S# #
3
- # # ####### #
4
- # # # #
5
- # # ### #####
6
- # # # #
7
- # ### ##### #
8
- # # # # #
9
- # # ### # ###
10
- # # # #
11
- # ######### #
12
- # E#
13
- #############
 
 
 
 
 
 
 
 
 
 
 
 
 
 
game/data/maze3d/Level_19.png DELETED

Git LFS Details

  • SHA256: 8c03b17b16505b2a795ab9064ced9ccb0fa71631d2fcd02d5ec398d9a7b281d2
  • Pointer size: 129 Bytes
  • Size of remote file: 8.62 kB
game/data/maze3d/Level_19.txt DELETED
@@ -1,13 +0,0 @@
1
- #############
2
- #S # #
3
- ######### # #
4
- # # # #
5
- # # # ##### #
6
- # # # # #
7
- # # ##### # #
8
- # # # # # #
9
- # # # # # # #
10
- # # # # # #
11
- # ##### # # #
12
- # # E#
13
- #############
 
 
 
 
 
 
 
 
 
 
 
 
 
 
game/data/maze3d/Level_20.png DELETED

Git LFS Details

  • SHA256: 48ee2acdc65652ccfa869902d202c1e24ecd30fa27c5e84a300b8d5b9cc284a8
  • Pointer size: 129 Bytes
  • Size of remote file: 8.84 kB
game/data/maze3d/Level_20.txt DELETED
@@ -1,13 +0,0 @@
1
- #############
2
- #S# # #
3
- # # # ### ###
4
- # # # #
5
- # ######### #
6
- # # # #
7
- # # ##### # #
8
- # # # # #
9
- ##### # # # #
10
- # # # # #
11
- # # ##### # #
12
- # # E#
13
- #############
 
 
 
 
 
 
 
 
 
 
 
 
 
 
game/data/maze3d/__pycache__/generate.cpython-313.pyc DELETED
Binary file (12.5 kB)
 
game/data/maze3d/generate.py DELETED
@@ -1,202 +0,0 @@
1
- import os
2
- import random
3
- import collections
4
- import matplotlib.pyplot as plt
5
- import numpy as np
6
- OUTPUT_DIR = 'D:\\work\\agent\\3Dplanning\\spatial_planning_game\\data\\maze3d'
7
- WALL = '#'
8
- EMPTY = ' '
9
- START = 'S'
10
- EXIT = 'E'
11
- if not os.path.exists(OUTPUT_DIR):
12
- os.makedirs(OUTPUT_DIR)
13
-
14
- def _generate_single_attempt(width, height, straightness, dead_end_removal, difficulty):
15
- grid = [[WALL for _ in range(width)] for _ in range(height)]
16
- sx, sy = (1, 1)
17
- ex, ey = (width - 2, height - 2)
18
- obstacle_coords = set()
19
- if width >= 15:
20
- raw_len = int(min(width, height) * (0.05 + difficulty * 0.15))
21
- safe_limit = min(width, height) // 4
22
- protrude_len = max(2, min(raw_len, safe_limit))
23
- start_top_x = 5
24
- start_left_y = 5
25
- end_bottom_x = width - 6
26
- end_right_y = height - 6
27
- if start_top_x < width - 2:
28
- for i in range(protrude_len):
29
- obstacle_coords.add((start_top_x, 1 + i))
30
- if start_left_y < height - 2:
31
- for i in range(protrude_len):
32
- obstacle_coords.add((1 + i, start_left_y))
33
- if end_bottom_x > 2:
34
- for i in range(protrude_len):
35
- obstacle_coords.add((end_bottom_x, height - 2 - i))
36
- if end_right_y > 2:
37
- for i in range(protrude_len):
38
- obstacle_coords.add((width - 2 - i, end_right_y))
39
- if width > 13:
40
- area = width * height
41
- density_base = 0.005 if width < 21 else 0.01
42
- num_random = int(area * density_base * (1 + difficulty * 2))
43
- num_random = min(num_random, area // 15)
44
- for _ in range(num_random):
45
- cx = random.randrange(3, width - 3, 2)
46
- cy = random.randrange(3, height - 3, 2)
47
- if abs(cx - sx) + abs(cy - sy) > 4 and abs(cx - ex) + abs(cy - ey) > 4:
48
- obstacle_coords.add((cx, cy))
49
- grid[sy][sx] = START
50
- visited = set([(sx, sy)]) | obstacle_coords
51
- stack = [(sx, sy, 0, 0)]
52
- directions = [(0, -2), (0, 2), (-2, 0), (2, 0)]
53
- while stack:
54
- cx, cy, last_dx, last_dy = stack[-1]
55
- neighbors = []
56
- for dx, dy in directions:
57
- nx, ny = (cx + dx, cy + dy)
58
- if 1 <= nx < width - 1 and 1 <= ny < height - 1:
59
- if (nx, ny) not in visited:
60
- neighbors.append((nx, ny, dx, dy))
61
- if neighbors:
62
- same_dir_n = next((n for n in neighbors if n[2] == last_dx and n[3] == last_dy), None)
63
- if same_dir_n and random.random() < straightness:
64
- chosen = same_dir_n
65
- else:
66
- chosen = random.choice(neighbors)
67
- nx, ny, dx, dy = chosen
68
- grid[cy + dy // 2][cx + dx // 2] = EMPTY
69
- grid[ny][nx] = EMPTY
70
- visited.add((nx, ny))
71
- stack.append((nx, ny, dx, dy))
72
- else:
73
- stack.pop()
74
- grid[ey][ex] = EXIT
75
- if dead_end_removal > 0:
76
- dead_ends = []
77
- for y in range(1, height - 1):
78
- for x in range(1, width - 1):
79
- if grid[y][x] == EMPTY:
80
- w_count = sum((1 for dx, dy in [(0, 1), (0, -1), (1, 0), (-1, 0)] if grid[y + dy][x + dx] == WALL))
81
- if w_count == 3:
82
- dead_ends.append((x, y))
83
- random.shuffle(dead_ends)
84
- remove_count = int(len(dead_ends) * dead_end_removal)
85
- for i in range(remove_count):
86
- dx, dy = dead_ends[i]
87
- valid_n = []
88
- for nx, ny in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
89
- tx, ty = (dx + nx, dy + ny)
90
- if 1 <= tx < width - 1 and 1 <= ty < height - 1:
91
- if grid[ty][tx] == WALL and (tx, ty) not in obstacle_coords:
92
- valid_n.append((nx, ny))
93
- if valid_n:
94
- wx, wy = random.choice(valid_n)
95
- grid[dy + wy][dx + wx] = EMPTY
96
- return (grid, (sx, sy), (ex, ey), obstacle_coords)
97
-
98
- def solve_bfs(grid, width, height, start, end):
99
- """Helpers."""
100
- queue = collections.deque([[start]])
101
- visited = set([start])
102
- while queue:
103
- path = queue.popleft()
104
- cx, cy = path[-1]
105
- if (cx, cy) == end:
106
- return path
107
- for dx, dy in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
108
- nx, ny = (cx + dx, cy + dy)
109
- if 0 <= nx < width and 0 <= ny < height and (grid[ny][nx] != WALL) and ((nx, ny) not in visited):
110
- visited.add((nx, ny))
111
- new_path = list(path)
112
- new_path.append((nx, ny))
113
- queue.append(new_path)
114
- return []
115
-
116
- def generate_maze_robust(width, height, straightness, removal, difficulty):
117
- """Helpers."""
118
- attempt = 0
119
- while True:
120
- attempt += 1
121
- grid, start, end, obstacles = _generate_single_attempt(width, height, straightness, removal, difficulty)
122
- if solve_bfs(grid, width, height, start, end):
123
- return (grid, start, end, obstacles)
124
- if attempt > 30:
125
- return _generate_single_attempt(width, height, straightness, removal, 0.0)
126
-
127
- def hash_grid(grid, start, end):
128
- """Helpers."""
129
- grid_str = ''.join([''.join(row) for row in grid])
130
- return f'{grid_str}|{start}|{end}'
131
-
132
- def save_unique_level(index, width, height, straightness, removal, difficulty, seen_hashes):
133
- MAX_RETRIES = 50
134
- for attempt in range(MAX_RETRIES):
135
- grid, start, end, obstacles = generate_maze_robust(width, height, straightness, removal, difficulty)
136
- if width == height and width < 10:
137
- ops = random.choice(['none', 'flip_h', 'flip_v', 'transpose'])
138
- if ops != 'none':
139
- grid_np = np.array([list(r) for r in grid])
140
- if ops == 'flip_h':
141
- grid_np = np.fliplr(grid_np)
142
- start = (width - 1 - start[0], start[1])
143
- end = (width - 1 - end[0], end[1])
144
- elif ops == 'flip_v':
145
- grid_np = np.flipud(grid_np)
146
- start = (start[0], height - 1 - start[1])
147
- end = (end[0], height - 1 - end[1])
148
- elif ops == 'transpose':
149
- grid_np = grid_np.T
150
- start = (start[1], start[0])
151
- end = (end[1], end[0])
152
- grid = grid_np.tolist()
153
- current_hash = hash_grid(grid, start, end)
154
- if current_hash not in seen_hashes:
155
- seen_hashes.add(current_hash)
156
- filename_base = f'Level_{index + 1:02d}'
157
- with open(os.path.join(OUTPUT_DIR, f'{filename_base}.txt'), 'w', encoding='utf-8') as f:
158
- for line in grid:
159
- f.write(''.join(line) + '\n')
160
- path = solve_bfs(grid, width, height, start, end)
161
- matrix = np.zeros((height, width))
162
- for y in range(height):
163
- for x in range(width):
164
- if (x, y) in obstacles and width >= 13:
165
- matrix[y][x] = 0.3
166
- elif grid[y][x] == WALL:
167
- matrix[y][x] = 0.0
168
- else:
169
- matrix[y][x] = 1.0
170
- plt.figure(figsize=(8, 8))
171
- plt.imshow(matrix, cmap='gray', interpolation='nearest')
172
- if path:
173
- px, py = zip(*path)
174
- plt.plot(px, py, color='red', linewidth=2, alpha=0.6)
175
- plt.scatter(start[0], start[1], c='lime', s=100, label='Start')
176
- plt.scatter(end[0], end[1], c='orange', s=100, label='Exit')
177
- plt.title(f'Level {index + 1}: {width}x{height} | Obstacles: {len(obstacles)}')
178
- plt.axis('off')
179
- plt.savefig(os.path.join(OUTPUT_DIR, f'{filename_base}.png'), bbox_inches='tight')
180
- plt.close()
181
- return True
182
- print(f' [警告] Level {index + 1} ({width}x{height}): 尝试 {MAX_RETRIES} 次仍无法生成完全唯一的地图,保留最后一次结果。')
183
- return True
184
-
185
- def main():
186
- print(f'🚀 开始生成动态难度迷宫 (防重复增强版)...')
187
- TOTAL_LEVELS = 20
188
- MIN_SIZE, MAX_SIZE = (5, 13)
189
- seen_hashes = set()
190
- for i in range(TOTAL_LEVELS):
191
- t = i / (TOTAL_LEVELS - 1)
192
- size = int(MIN_SIZE + t * (MAX_SIZE - MIN_SIZE))
193
- if size % 2 == 0:
194
- size += 1
195
- difficulty = t
196
- straightness = 0.85 - t * 0.5
197
- removal = 0.5 - t * 0.4
198
- save_unique_level(i, size, size, straightness, removal, difficulty, seen_hashes)
199
- print(f' [进度 {i + 1}/{TOTAL_LEVELS}] 已生成 {size}x{size} 关卡')
200
- print(f'\n✅ 全部完成!文件已保存至: {OUTPUT_DIR}')
201
- if __name__ == '__main__':
202
- main()