|
1 | 1 | import json
|
| 2 | +import random |
| 3 | +import sys |
| 4 | + |
| 5 | +# Available configurations: |
| 6 | +# - fourSquare |
| 7 | +# - evacuateRoom |
| 8 | +# - twoExitsTwoGroups |
| 9 | + |
| 10 | +def main(argv): |
| 11 | + if len(argv) == 0: |
| 12 | + toGenerate = ["fourSquare", "evacuateRoom", "twoExitsTwoGroups"] |
| 13 | + else: |
| 14 | + toGenerate = argv |
| 15 | + |
| 16 | + for config in toGenerate: |
| 17 | + if config == "fourSquare": |
| 18 | + fourSquare = {} |
| 19 | + fourSquare["config"] = {"width": 9, "height": 9, "scale": 100, "delay": 0} |
| 20 | + |
| 21 | + fourSquare["room"] = {"walls": [ |
| 22 | + [3.15, 3.15, 4.25, 3.15], |
| 23 | + [4.25, 3.15, 4.25, 4.25], |
| 24 | + [4.25, 4.25, 3.15, 4.25], |
| 25 | + [3.15, 4.25, 3.15, 3.15], |
| 26 | + |
| 27 | + [4.75, 3.15, 5.85, 3.15], |
| 28 | + [5.85, 3.15, 5.85, 4.25], |
| 29 | + [5.85, 4.25, 4.75, 4.25], |
| 30 | + [4.75, 4.25, 4.75, 3.15], |
| 31 | + |
| 32 | + [3.15, 4.75, 4.25, 4.75], |
| 33 | + [4.25, 4.75, 4.25, 5.85], |
| 34 | + [4.25, 5.85, 3.15, 5.85], |
| 35 | + [3.15, 5.85, 3.15, 4.75], |
| 36 | + |
| 37 | + [4.75, 4.75, 5.85, 4.75], |
| 38 | + [5.85, 4.75, 5.85, 5.85], |
| 39 | + [5.85, 5.85, 4.75, 5.85], |
| 40 | + [4.75, 5.85, 4.75, 4.75] |
| 41 | + ]} |
| 42 | + |
| 43 | + actorList = [] |
| 44 | + offsets = [[0.5, 0.5], [6.5, 0.5], [0.5, 6.5], [6.5, 6.5]] |
| 45 | + colors = [[255, 0, 0], [0, 255, 0], [0, 0, 255], [150, 150, 150]] |
| 46 | + for o in range (0, len(offsets)): |
| 47 | + for i in range(0, 5): |
| 48 | + for j in range(0, 5): |
| 49 | + actorList.append({ |
| 50 | + "pos": [offsets[o][0] + (i * 0.5), offsets[o][1] + (j * 0.5)], |
| 51 | + "velocity": [0.01, 0.01], |
| 52 | + "desiredSpeed": 2.0, |
| 53 | + "path": [[offsets[len(offsets) - o - 1][0] + (i * 0.5), offsets[len(offsets) - o - 1][1] + (j * 0.5)]], |
| 54 | + "mass": 50, |
| 55 | + "radius": 0.05, |
| 56 | + "atDestination": False, |
| 57 | + "color": colors[o], |
| 58 | + "heatmapEnabled": False |
| 59 | + }) |
| 60 | + fourSquare["actors"] = actorList |
| 61 | + |
| 62 | + with open("fourSquare.json", "w") as out: |
| 63 | + json.dump(fourSquare, out, ensure_ascii=False, indent=4) |
| 64 | + |
| 65 | + elif config == "evacuateRoom": |
| 66 | + evacuateRoom = {} |
| 67 | + evacuateRoom["config"] = {"width": 9, "height": 9, "scale": 100, "delay": 0} |
| 68 | + |
| 69 | + evacuateRoom["room"] = {"walls": [ |
| 70 | + [0.5, 0.5, 8.5, 0.5], |
| 71 | + [8.5, 0.5, 8.5, 8.5], |
| 72 | + [8.5, 8.5, 0.5, 8.5], |
| 73 | + [0.5, 8.5, 0.5, 4.15], |
| 74 | + [0.5, 3.85, 0.5, 0.5] |
| 75 | + ]} |
| 76 | + |
| 77 | + actorList = [] |
| 78 | + for i in range(0, 20): |
| 79 | + for j in range(0, 35): |
| 80 | + actorList.append({ |
| 81 | + "pos": [4 + (i * 0.2), 1 + (j * 0.2)], |
| 82 | + "velocity": [0.01, 0.01], |
| 83 | + "desiredSpeed": 2.0, |
| 84 | + "path": [[0.5, 4.1], [-5, 4.1]], |
| 85 | + "mass": 50, |
| 86 | + "radius": 0.05, |
| 87 | + "atDestination": False, |
| 88 | + "color": [255, 0, 0], |
| 89 | + "heatmapEnabled": True |
| 90 | + }) |
| 91 | + evacuateRoom["actors"] = actorList |
| 92 | + |
| 93 | + with open("evacuateRoom.json", "w") as out: |
| 94 | + json.dump(evacuateRoom, out, ensure_ascii=False, indent=4) |
| 95 | + |
| 96 | + elif config == "twoExitsTwoGroups": |
| 97 | + twoExitsTwoGroups = {} |
| 98 | + twoExitsTwoGroups["config"] = {"width": 9, "height": 9, "scale": 100, "delay": 0} |
| 99 | + |
| 100 | + twoExitsTwoGroups["room"] = {"walls": [ |
| 101 | + [0.5, 0.5, 8.5, 0.5], |
| 102 | + [8.5, 0.5, 8.5, 6], |
| 103 | + [8.5, 6.4, 8.5, 8.5], |
| 104 | + [8.5, 8.5, 0.5, 8.5], |
| 105 | + [0.5, 8.5, 0.5, 4.2], |
| 106 | + [0.5, 3.8, 0.5, 0.5] |
| 107 | + ]} |
| 108 | + |
| 109 | + actorList = [] |
| 110 | + for i in range(0, 10): |
| 111 | + for j in range(0, 35): |
| 112 | + actorList.append({ |
| 113 | + "pos": [6.5 + (i * 0.2), 1 + (j * 0.2)], |
| 114 | + "velocity": [0.01, 0.01], |
| 115 | + "desiredSpeed": 2.0, |
| 116 | + "path": [[0.5, 4.0], [-10, 4.0]], |
| 117 | + "mass": 50, |
| 118 | + "radius": 0.05, |
| 119 | + "atDestination": False, |
| 120 | + "color": [255, 0, 0], |
| 121 | + "heatmapEnabled": False |
| 122 | + }) |
| 123 | + for i in range(0, 10): |
| 124 | + for j in range(0, 35): |
| 125 | + actorList.append({ |
| 126 | + "pos": [0.8 + (i * 0.2), 1 + (j * 0.2)], |
| 127 | + "velocity": [0.01, 0.01], |
| 128 | + "desiredSpeed": 2.0, |
| 129 | + "path": [[8.5, 6.2], [20, 6.2]], |
| 130 | + "mass": 50, |
| 131 | + "radius": 0.05, |
| 132 | + "atDestination": False, |
| 133 | + "color": [0, 255, 0], |
| 134 | + "heatmapEnabled": False |
| 135 | + }) |
| 136 | + twoExitsTwoGroups["actors"] = actorList |
| 137 | + |
| 138 | + with open("twoExitsTwoGroups.json", "w") as out: |
| 139 | + json.dump(twoExitsTwoGroups, out, ensure_ascii=False, indent=4) |
2 | 140 |
|
3 | 141 | if __name__ == "__main__":
|
4 |
| - print("Hey") |
| 142 | + main(sys.argv[1:]) |
0 commit comments