├── .gitignore ├── CodeCraft2019.sln ├── CodeCraft2019 ├── .gitignore ├── CMakeLists.txt ├── CodeCraft-2019.cpp ├── CodeCraft2019.vcxproj ├── config-1 │ ├── car.txt │ ├── cross.txt │ └── road.txt ├── config-2 │ ├── car.txt │ ├── cross.txt │ └── road.txt ├── config-3 │ ├── car.txt │ ├── cross.txt │ └── road.txt ├── config-4 │ ├── car.txt │ ├── cross.txt │ └── road.txt ├── config-exam-1 │ ├── car.txt │ ├── cross.txt │ └── road.txt ├── config-exam-2 │ ├── car.txt │ ├── cross.txt │ └── road.txt ├── config2-1 │ ├── car.txt │ ├── cross.txt │ ├── presetAnswer.txt │ └── road.txt ├── config2-2 │ ├── car.txt │ ├── cross.txt │ ├── presetAnswer.txt │ └── road.txt ├── config2-check-1 │ ├── answer.txt │ ├── car.txt │ ├── cross.txt │ ├── presetAnswer.txt │ ├── road.txt │ └── 判题结果.txt ├── config2-check-2 │ ├── answer.txt │ ├── car.txt │ ├── cross.txt │ ├── presetAnswer.txt │ ├── road.txt │ └── 判题结果.txt ├── config2-exam-1 │ ├── car.txt │ ├── cross.txt │ ├── presetAnswer.txt │ └── road.txt ├── config2-exam-2 │ ├── car.txt │ ├── cross.txt │ ├── presetAnswer.txt │ └── road.txt ├── config3-1 │ ├── car.txt │ ├── cross.txt │ ├── presetAnswer.txt │ ├── relation.txt │ └── road.txt ├── config3-2 │ ├── car.txt │ ├── cross.txt │ ├── presetAnswer.txt │ ├── relation.txt │ └── road.txt ├── config3-exam-1 │ ├── car.txt │ ├── cross.txt │ ├── presetAnswer.txt │ ├── relation.txt │ └── road.txt ├── config3-exam-2 │ ├── car.txt │ ├── cross.txt │ ├── presetAnswer.txt │ ├── relation.txt │ └── road.txt ├── config_0 │ ├── car.txt │ ├── cross.txt │ └── road.txt ├── config_1 │ ├── car.txt │ ├── cross.txt │ └── road.txt ├── config_10 │ ├── car.txt │ ├── cross.txt │ └── road.txt ├── config_2 │ ├── car.txt │ ├── cross.txt │ └── road.txt ├── config_3 │ ├── car.txt │ ├── cross.txt │ └── road.txt ├── config_4 │ ├── car.txt │ ├── cross.txt │ └── road.txt ├── config_5 │ ├── car.txt │ ├── cross.txt │ └── road.txt ├── config_6 │ ├── car.txt │ ├── cross.txt │ └── road.txt ├── config_7 │ ├── car.txt │ ├── cross.txt │ └── road.txt ├── config_8 │ ├── car.txt │ ├── cross.txt │ └── road.txt ├── config_9 │ ├── car.txt │ ├── cross.txt │ └── road.txt ├── run-framework.cpp ├── run-framework.h ├── scenario │ ├── CMakeLists.txt │ ├── car.cpp │ ├── car.h │ ├── config.cpp │ ├── config.h │ ├── cross.cpp │ ├── cross.h │ ├── road.cpp │ ├── road.h │ ├── scenario.cpp │ └── scenario.h ├── scheduler │ ├── CMakeLists.txt │ ├── dead-lock-solver.cpp │ ├── dead-lock-solver.h │ ├── garage-counter.cpp │ ├── garage-counter.h │ ├── load-state.cpp │ ├── load-state.h │ ├── scheduler-answer.cpp │ ├── scheduler-answer.h │ ├── scheduler-floyd.cpp │ ├── scheduler-floyd.h │ ├── scheduler-time-weight.cpp │ ├── scheduler-time-weight.h │ ├── scheduler.cpp │ └── scheduler.h ├── simulation │ ├── CMakeLists.txt │ ├── score-calculator.cpp │ ├── score-calculator.h │ ├── sim-car.cpp │ ├── sim-car.h │ ├── sim-road.cpp │ ├── sim-road.h │ ├── sim-scenario.cpp │ ├── sim-scenario.h │ ├── simulator.cpp │ ├── simulator.h │ ├── tactics.cpp │ ├── tactics.h │ ├── trace.cpp │ └── trace.h ├── tester │ ├── CMakeLists.txt │ ├── map-generator.h │ ├── map-genrator.cpp │ ├── sim-scenario-tester.cpp │ └── sim-scenario-tester.h └── util │ ├── CMakeLists.txt │ ├── assert.h │ ├── callback.h │ ├── copy-object.h │ ├── define.h │ ├── file-reader.cpp │ ├── file-reader.h │ ├── log.cpp │ ├── log.h │ ├── map-array.cpp │ ├── map-array.h │ ├── memory-pool.cpp │ ├── memory-pool.h │ ├── pmap.h │ ├── quick-map.h │ ├── random-stream.cpp │ ├── random-stream.h │ ├── random.cpp │ ├── random.h │ ├── timer.cpp │ └── timer.h ├── README.md ├── Visualization ├── CodeCraft2019Visualization.sln ├── CodeCraft2019Visualization │ ├── App.xaml │ ├── App.xaml.cs │ ├── Basic.cs │ ├── CodeCraft2019Visualization.csproj │ ├── Config.cs │ ├── Drawer.cs │ ├── IO.cs │ ├── Initialize.cs │ ├── Logging.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── Newtonsoft.Json.dll │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ └── Scenario.cs ├── README.md ├── bin │ └── Release │ │ ├── CodeCraft2019Visualization.exe │ │ ├── Newtonsoft.Json.dll │ │ ├── config │ │ ├── car.txt │ │ ├── cross.txt │ │ ├── presetAnswer.txt │ │ ├── relation.txt │ │ └── road.txt │ │ └── log.tr └── screenshot │ └── screenshot.png ├── backups ├── .gitignore ├── 0.1.1161.CodeCraft-code.tar.gz ├── 0.2.979.CodeCraft-code.tar.gz ├── 0.3.713.CodeCraft-code.tar.gz ├── 0.4.CHECK.CodeCraft-code.tar.gz ├── 0.5.M1T397.CodeCraft-code.tar.gz ├── 0.6.M1T357.CodeCraft-code.tar.gz ├── 1.1.2767.CodeCraft-code.tar.gz ├── 1.2.2034.CodeCraft-code.tar.gz ├── 1.3.2019.CodeCraft-code.tar.gz ├── 2.1.FAILED.CodeCraft-code.tar.gz ├── 2.2.4690.CodeCraft-code.tar.gz ├── 2.3.3087.CodeCraft-code.tar.gz ├── 3.1.M2T1732.CodeCraft-code.tar.gz ├── 3.2.M2T1732.CodeCraft-code.tar.gz └── 3.3.3057.CodeCraft-code.tar.gz └── introduction └── introduction.png /.gitignore: -------------------------------------------------------------------------------- 1 | /* 2 | */: 3 | !CodeCraft2019.sln 4 | !CodeCraft2019/ 5 | !backups/ 6 | !Visualization/ 7 | !introduction/ 8 | -------------------------------------------------------------------------------- /CodeCraft2019.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CodeCraft2019", "CodeCraft2019\CodeCraft2019.vcxproj", "{7FE48AE7-6698-4131-96AE-259872CBC346}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {7FE48AE7-6698-4131-96AE-259872CBC346}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {7FE48AE7-6698-4131-96AE-259872CBC346}.Debug|Win32.Build.0 = Debug|Win32 14 | {7FE48AE7-6698-4131-96AE-259872CBC346}.Release|Win32.ActiveCfg = Release|Win32 15 | {7FE48AE7-6698-4131-96AE-259872CBC346}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /CodeCraft2019/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore all files but this file 2 | /* 3 | */: 4 | !/.gitignore 5 | 6 | # except config files but not test config 7 | !/config*/ 8 | /config_test*/ 9 | # ignore files in config directories 10 | /config*/* 11 | # except given files 12 | !/config*/car.txt 13 | !/config*/cross.txt 14 | !/config*/road.txt 15 | !/config*/presetAnswer.txt 16 | !/config*/relation.txt 17 | # special files in checking directories 18 | !/config*-check*/判题结果.txt 19 | !/config*-check*/answer.txt 20 | 21 | # code files 22 | !/util/ 23 | !/scenario/ 24 | !/simulation/ 25 | !/scheduler/ 26 | !/tester/ 27 | !/*.h 28 | !/*.cpp 29 | !/CMakeLists.txt 30 | 31 | # project files 32 | !CodeCraft2019.vcxproj -------------------------------------------------------------------------------- /CodeCraft2019/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # CMake 最低版本号要求 2 | cmake_minimum_required(VERSION 2.8) 3 | 4 | # 项目信息 5 | project("CodeCraft-2019") 6 | 7 | # include路径 8 | include_directories(${PROJECT_SOURCE_DIR}/lib) 9 | include_directories(${PROJECT_SOURCE_DIR}/util) 10 | include_directories(${PROJECT_SOURCE_DIR}/scenario) 11 | include_directories(${PROJECT_SOURCE_DIR}/simulation) 12 | include_directories(${PROJECT_SOURCE_DIR}/scheduler) 13 | include_directories(${PROJECT_SOURCE_DIR}/tester) 14 | 15 | # 设置可执行文件生成路径 16 | set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/../bin) 17 | 18 | # 生成debug版本 19 | SET(CMAKE_BUILD_TYPE "release") 20 | if (CMAKE_BUILD_TYPE STREQUAL debug) 21 | add_definitions(-D_DEBUG) 22 | endif () 23 | SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb -std=c++11") 24 | SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall -std=c++11") 25 | 26 | # 编译子目录 27 | add_subdirectory(util) 28 | add_subdirectory(scenario) 29 | add_subdirectory(simulation) 30 | add_subdirectory(scheduler) 31 | add_subdirectory(tester) 32 | 33 | # 查找当前目录下的所有源文件 34 | # 并将名称保存到 DIR_LIB_SRCS 变量 35 | aux_source_directory(. DIR_SRCS) 36 | 37 | # 指定生成目标 38 | add_executable(CodeCraft-2019 ${DIR_SRCS}) 39 | 40 | # 链接 41 | target_link_libraries(CodeCraft-2019 util scenario simulation scheduler tester) 42 | -------------------------------------------------------------------------------- /CodeCraft2019/config-1/cross.txt: -------------------------------------------------------------------------------- 1 | #(id,roadId,roadId,roadId,roadId) 2 | (1, 5000, 5007, -1, -1) 3 | (2, 5001, 5008, 5000, -1) 4 | (3, 5002, 5009, 5001, -1) 5 | (4, 5003, 5010, 5002, -1) 6 | (5, 5004, 5011, 5003, -1) 7 | (6, 5005, 5012, 5004, -1) 8 | (7, 5006, 5013, 5005, -1) 9 | (8, -1, 5014, 5006, -1) 10 | (9, 5015, 5022, -1, 5007) 11 | (10, 5016, 5023, 5015, 5008) 12 | (11, 5017, 5024, 5016, 5009) 13 | (12, 5018, 5025, 5017, 5010) 14 | (13, 5019, 5026, 5018, 5011) 15 | (14, 5020, 5027, 5019, 5012) 16 | (15, 5021, 5028, 5020, 5013) 17 | (16, -1, 5029, 5021, 5014) 18 | (17, 5030, 5035, -1, 5022) 19 | (18, -1, 5036, 5030, 5023) 20 | (19, 5031, 5037, -1, 5024) 21 | (20, 5032, 5038, 5031, 5025) 22 | (21, 5033, -1, 5032, 5026) 23 | (22, -1, 5039, 5033, 5027) 24 | (23, 5034, -1, -1, 5028) 25 | (24, -1, 5040, 5034, 5029) 26 | (25, 5041, 5048, -1, 5035) 27 | (26, 5042, 5049, 5041, 5036) 28 | (27, 5043, 5050, 5042, 5037) 29 | (28, 5044, 5051, 5043, 5038) 30 | (29, 5045, 5052, 5044, -1) 31 | (30, 5046, 5053, 5045, 5039) 32 | (31, 5047, 5054, 5046, -1) 33 | (32, -1, 5055, 5047, 5040) 34 | (33, 5056, 5062, -1, 5048) 35 | (34, 5057, 5063, 5056, 5049) 36 | (35, -1, 5064, 5057, 5050) 37 | (36, 5058, 5065, -1, 5051) 38 | (37, 5059, 5066, 5058, 5052) 39 | (38, 5060, 5067, 5059, 5053) 40 | (39, 5061, 5068, 5060, 5054) 41 | (40, -1, 5069, 5061, 5055) 42 | (41, 5070, 5077, -1, 5062) 43 | (42, 5071, 5078, 5070, 5063) 44 | (43, 5072, 5079, 5071, 5064) 45 | (44, 5073, 5080, 5072, 5065) 46 | (45, 5074, 5081, 5073, 5066) 47 | (46, 5075, 5082, 5074, 5067) 48 | (47, 5076, -1, 5075, 5068) 49 | (48, -1, 5083, 5076, 5069) 50 | (49, 5084, 5090, -1, 5077) 51 | (50, 5085, 5091, 5084, 5078) 52 | (51, 5086, 5092, 5085, 5079) 53 | (52, 5087, 5093, 5086, 5080) 54 | (53, -1, 5094, 5087, 5081) 55 | (54, 5088, 5095, -1, 5082) 56 | (55, 5089, 5096, 5088, -1) 57 | (56, -1, 5097, 5089, 5083) 58 | (57, 5098, -1, -1, 5090) 59 | (58, 5099, -1, 5098, 5091) 60 | (59, 5100, -1, 5099, 5092) 61 | (60, 5101, -1, 5100, 5093) 62 | (61, 5102, -1, 5101, 5094) 63 | (62, 5103, -1, 5102, 5095) 64 | (63, 5104, -1, 5103, 5096) 65 | (64, -1, -1, 5104, 5097) -------------------------------------------------------------------------------- /CodeCraft2019/config-1/road.txt: -------------------------------------------------------------------------------- 1 | #(id,length,speed,channel,from,to,isDuplex) 2 | (5000, 15, 6, 2, 1, 2, 1) 3 | (5001, 18, 4, 2, 2, 3, 1) 4 | (5002, 20, 6, 1, 3, 4, 1) 5 | (5003, 18, 8, 2, 4, 5, 1) 6 | (5004, 18, 4, 1, 5, 6, 1) 7 | (5005, 18, 8, 3, 6, 7, 1) 8 | (5006, 12, 6, 2, 7, 8, 1) 9 | (5007, 20, 8, 4, 1, 9, 1) 10 | (5008, 12, 6, 4, 2, 10, 1) 11 | (5009, 20, 4, 4, 3, 11, 1) 12 | (5010, 10, 4, 5, 4, 12, 1) 13 | (5011, 20, 6, 4, 5, 13, 1) 14 | (5012, 20, 6, 1, 6, 14, 1) 15 | (5013, 15, 8, 5, 7, 15, 1) 16 | (5014, 15, 8, 4, 8, 16, 1) 17 | (5015, 15, 8, 2, 9, 10, 1) 18 | (5016, 20, 4, 3, 10, 11, 1) 19 | (5017, 10, 6, 5, 11, 12, 0) 20 | (5018, 10, 4, 2, 12, 13, 1) 21 | (5019, 10, 4, 5, 13, 14, 1) 22 | (5020, 12, 4, 2, 14, 15, 1) 23 | (5021, 10, 6, 2, 15, 16, 1) 24 | (5022, 20, 6, 1, 9, 17, 1) 25 | (5023, 18, 4, 1, 10, 18, 1) 26 | (5024, 15, 8, 2, 11, 19, 1) 27 | (5025, 10, 6, 5, 12, 20, 1) 28 | (5026, 18, 6, 1, 13, 21, 0) 29 | (5027, 15, 6, 4, 14, 22, 1) 30 | (5028, 20, 4, 3, 15, 23, 1) 31 | (5029, 20, 4, 3, 16, 24, 1) 32 | (5030, 10, 6, 2, 17, 18, 1) 33 | (5031, 18, 6, 2, 19, 20, 1) 34 | (5032, 20, 8, 5, 20, 21, 1) 35 | (5033, 18, 8, 4, 21, 22, 1) 36 | (5034, 18, 8, 2, 23, 24, 1) 37 | (5035, 18, 8, 3, 17, 25, 1) 38 | (5036, 12, 6, 2, 18, 26, 0) 39 | (5037, 20, 4, 2, 19, 27, 1) 40 | (5038, 20, 4, 3, 20, 28, 1) 41 | (5039, 18, 8, 3, 22, 30, 1) 42 | (5040, 15, 6, 4, 24, 32, 1) 43 | (5041, 12, 8, 1, 25, 26, 1) 44 | (5042, 12, 4, 5, 26, 27, 1) 45 | (5043, 10, 8, 3, 27, 28, 0) 46 | (5044, 20, 6, 5, 28, 29, 1) 47 | (5045, 10, 6, 5, 29, 30, 1) 48 | (5046, 12, 4, 1, 30, 31, 1) 49 | (5047, 18, 8, 5, 31, 32, 1) 50 | (5048, 18, 4, 5, 25, 33, 1) 51 | (5049, 15, 6, 5, 26, 34, 1) 52 | (5050, 15, 6, 1, 27, 35, 1) 53 | (5051, 18, 8, 3, 28, 36, 1) 54 | (5052, 18, 4, 1, 29, 37, 1) 55 | (5053, 12, 8, 3, 30, 38, 0) 56 | (5054, 15, 6, 3, 31, 39, 1) 57 | (5055, 12, 8, 1, 32, 40, 1) 58 | (5056, 12, 4, 2, 33, 34, 1) 59 | (5057, 18, 4, 4, 34, 35, 1) 60 | (5058, 10, 4, 4, 36, 37, 1) 61 | (5059, 20, 8, 5, 37, 38, 1) 62 | (5060, 10, 6, 1, 38, 39, 1) 63 | (5061, 18, 8, 2, 39, 40, 1) 64 | (5062, 12, 8, 4, 33, 41, 1) 65 | (5063, 10, 6, 1, 34, 42, 1) 66 | (5064, 20, 8, 4, 35, 43, 1) 67 | (5065, 15, 6, 4, 36, 44, 1) 68 | (5066, 12, 8, 4, 37, 45, 1) 69 | (5067, 10, 4, 5, 38, 46, 1) 70 | (5068, 20, 4, 5, 39, 47, 1) 71 | (5069, 18, 4, 2, 40, 48, 1) 72 | (5070, 12, 4, 4, 41, 42, 1) 73 | (5071, 15, 8, 5, 42, 43, 1) 74 | (5072, 15, 8, 5, 43, 44, 1) 75 | (5073, 18, 8, 4, 44, 45, 1) 76 | (5074, 10, 8, 3, 45, 46, 0) 77 | (5075, 20, 6, 1, 46, 47, 1) 78 | (5076, 15, 6, 1, 47, 48, 1) 79 | (5077, 12, 8, 1, 41, 49, 1) 80 | (5078, 18, 8, 2, 42, 50, 1) 81 | (5079, 20, 8, 1, 43, 51, 1) 82 | (5080, 10, 4, 3, 44, 52, 0) 83 | (5081, 18, 6, 3, 45, 53, 1) 84 | (5082, 10, 6, 1, 46, 54, 1) 85 | (5083, 20, 6, 3, 48, 56, 1) 86 | (5084, 20, 8, 4, 49, 50, 1) 87 | (5085, 10, 8, 1, 50, 51, 0) 88 | (5086, 20, 6, 1, 51, 52, 1) 89 | (5087, 12, 6, 1, 52, 53, 1) 90 | (5088, 15, 8, 3, 54, 55, 1) 91 | (5089, 12, 8, 5, 55, 56, 1) 92 | (5090, 10, 4, 3, 49, 57, 1) 93 | (5091, 12, 6, 3, 50, 58, 1) 94 | (5092, 12, 6, 5, 51, 59, 1) 95 | (5093, 18, 8, 3, 52, 60, 1) 96 | (5094, 18, 6, 2, 53, 61, 1) 97 | (5095, 20, 6, 4, 54, 62, 1) 98 | (5096, 10, 4, 3, 55, 63, 1) 99 | (5097, 10, 6, 1, 56, 64, 1) 100 | (5098, 15, 6, 1, 57, 58, 1) 101 | (5099, 15, 8, 5, 58, 59, 1) 102 | (5100, 12, 6, 3, 59, 60, 1) 103 | (5101, 20, 4, 3, 60, 61, 1) 104 | (5102, 10, 6, 4, 61, 62, 1) 105 | (5103, 10, 6, 3, 62, 63, 1) 106 | (5104, 18, 6, 5, 63, 64, 1) -------------------------------------------------------------------------------- /CodeCraft2019/config-2/cross.txt: -------------------------------------------------------------------------------- 1 | #(id,roadId,roadId,roadId,roadId) 2 | (1, 5000, 5007, -1, -1) 3 | (2, 5001, 5008, 5000, -1) 4 | (3, 5002, 5009, 5001, -1) 5 | (4, 5003, 5010, 5002, -1) 6 | (5, 5004, 5011, 5003, -1) 7 | (6, 5005, 5012, 5004, -1) 8 | (7, 5006, 5013, 5005, -1) 9 | (8, -1, 5014, 5006, -1) 10 | (9, 5015, 5022, -1, 5007) 11 | (10, 5016, 5023, 5015, 5008) 12 | (11, 5017, 5024, 5016, 5009) 13 | (12, 5018, 5025, 5017, 5010) 14 | (13, 5019, 5026, 5018, 5011) 15 | (14, 5020, 5027, 5019, 5012) 16 | (15, 5021, 5028, 5020, 5013) 17 | (16, -1, 5029, 5021, 5014) 18 | (17, 5030, 5035, -1, 5022) 19 | (18, -1, 5036, 5030, 5023) 20 | (19, 5031, 5037, -1, 5024) 21 | (20, 5032, 5038, 5031, 5025) 22 | (21, 5033, -1, 5032, 5026) 23 | (22, -1, 5039, 5033, 5027) 24 | (23, 5034, -1, -1, 5028) 25 | (24, -1, 5040, 5034, 5029) 26 | (25, 5041, 5048, -1, 5035) 27 | (26, 5042, 5049, 5041, 5036) 28 | (27, 5043, 5050, 5042, 5037) 29 | (28, 5044, 5051, 5043, 5038) 30 | (29, 5045, 5052, 5044, -1) 31 | (30, 5046, 5053, 5045, 5039) 32 | (31, 5047, 5054, 5046, -1) 33 | (32, -1, 5055, 5047, 5040) 34 | (33, 5056, 5062, -1, 5048) 35 | (34, 5057, 5063, 5056, 5049) 36 | (35, -1, 5064, 5057, 5050) 37 | (36, 5058, 5065, -1, 5051) 38 | (37, 5059, 5066, 5058, 5052) 39 | (38, 5060, 5067, 5059, 5053) 40 | (39, 5061, 5068, 5060, 5054) 41 | (40, -1, 5069, 5061, 5055) 42 | (41, 5070, 5077, -1, 5062) 43 | (42, 5071, 5078, 5070, 5063) 44 | (43, 5072, 5079, 5071, 5064) 45 | (44, 5073, 5080, 5072, 5065) 46 | (45, 5074, 5081, 5073, 5066) 47 | (46, 5075, 5082, 5074, 5067) 48 | (47, 5076, -1, 5075, 5068) 49 | (48, -1, 5083, 5076, 5069) 50 | (49, 5084, 5090, -1, 5077) 51 | (50, 5085, 5091, 5084, 5078) 52 | (51, 5086, 5092, 5085, 5079) 53 | (52, 5087, 5093, 5086, 5080) 54 | (53, -1, 5094, 5087, 5081) 55 | (54, 5088, 5095, -1, 5082) 56 | (55, 5089, 5096, 5088, -1) 57 | (56, -1, 5097, 5089, 5083) 58 | (57, 5098, -1, -1, 5090) 59 | (58, 5099, -1, 5098, 5091) 60 | (59, 5100, -1, 5099, 5092) 61 | (60, 5101, -1, 5100, 5093) 62 | (61, 5102, -1, 5101, 5094) 63 | (62, 5103, -1, 5102, 5095) 64 | (63, 5104, -1, 5103, 5096) 65 | (64, -1, -1, 5104, 5097) -------------------------------------------------------------------------------- /CodeCraft2019/config-2/road.txt: -------------------------------------------------------------------------------- 1 | #(id,length,speed,channel,from,to,isDuplex) 2 | (5000, 12, 4, 4, 1, 2, 1) 3 | (5001, 18, 8, 5, 2, 3, 1) 4 | (5002, 20, 4, 1, 3, 4, 1) 5 | (5003, 20, 4, 2, 4, 5, 1) 6 | (5004, 15, 8, 1, 5, 6, 1) 7 | (5005, 18, 8, 1, 6, 7, 1) 8 | (5006, 12, 8, 2, 7, 8, 1) 9 | (5007, 12, 6, 2, 1, 9, 1) 10 | (5008, 20, 4, 5, 2, 10, 1) 11 | (5009, 12, 8, 3, 3, 11, 1) 12 | (5010, 18, 4, 2, 4, 12, 1) 13 | (5011, 12, 4, 1, 5, 13, 1) 14 | (5012, 15, 8, 5, 6, 14, 1) 15 | (5013, 18, 8, 1, 7, 15, 1) 16 | (5014, 18, 4, 2, 8, 16, 1) 17 | (5015, 10, 8, 4, 9, 10, 1) 18 | (5016, 12, 4, 4, 10, 11, 1) 19 | (5017, 18, 6, 1, 11, 12, 0) 20 | (5018, 15, 4, 4, 12, 13, 1) 21 | (5019, 12, 4, 3, 13, 14, 1) 22 | (5020, 10, 6, 2, 14, 15, 1) 23 | (5021, 15, 8, 4, 15, 16, 1) 24 | (5022, 12, 8, 4, 9, 17, 1) 25 | (5023, 20, 4, 2, 10, 18, 1) 26 | (5024, 18, 8, 3, 11, 19, 1) 27 | (5025, 20, 4, 1, 12, 20, 1) 28 | (5026, 15, 6, 1, 13, 21, 0) 29 | (5027, 18, 8, 1, 14, 22, 1) 30 | (5028, 18, 8, 3, 15, 23, 1) 31 | (5029, 15, 6, 2, 16, 24, 1) 32 | (5030, 10, 4, 3, 17, 18, 1) 33 | (5031, 12, 4, 5, 19, 20, 1) 34 | (5032, 15, 4, 4, 20, 21, 1) 35 | (5033, 20, 8, 5, 21, 22, 1) 36 | (5034, 10, 8, 2, 23, 24, 1) 37 | (5035, 18, 6, 2, 17, 25, 1) 38 | (5036, 20, 4, 3, 18, 26, 0) 39 | (5037, 10, 8, 5, 19, 27, 1) 40 | (5038, 20, 6, 1, 20, 28, 1) 41 | (5039, 12, 4, 3, 22, 30, 1) 42 | (5040, 15, 6, 2, 24, 32, 1) 43 | (5041, 12, 8, 4, 25, 26, 1) 44 | (5042, 18, 4, 4, 26, 27, 1) 45 | (5043, 20, 4, 1, 27, 28, 0) 46 | (5044, 15, 4, 1, 28, 29, 1) 47 | (5045, 12, 6, 4, 29, 30, 1) 48 | (5046, 10, 4, 2, 30, 31, 1) 49 | (5047, 18, 6, 2, 31, 32, 1) 50 | (5048, 12, 8, 1, 25, 33, 1) 51 | (5049, 18, 8, 2, 26, 34, 1) 52 | (5050, 18, 8, 3, 27, 35, 1) 53 | (5051, 10, 6, 3, 28, 36, 1) 54 | (5052, 15, 8, 3, 29, 37, 1) 55 | (5053, 18, 8, 4, 30, 38, 0) 56 | (5054, 20, 8, 5, 31, 39, 1) 57 | (5055, 15, 8, 4, 32, 40, 1) 58 | (5056, 18, 4, 5, 33, 34, 1) 59 | (5057, 20, 8, 3, 34, 35, 1) 60 | (5058, 12, 6, 1, 36, 37, 1) 61 | (5059, 18, 8, 4, 37, 38, 1) 62 | (5060, 20, 8, 4, 38, 39, 1) 63 | (5061, 20, 6, 2, 39, 40, 1) 64 | (5062, 18, 6, 5, 33, 41, 1) 65 | (5063, 20, 6, 3, 34, 42, 1) 66 | (5064, 12, 8, 4, 35, 43, 1) 67 | (5065, 12, 8, 3, 36, 44, 1) 68 | (5066, 18, 6, 5, 37, 45, 1) 69 | (5067, 20, 8, 2, 38, 46, 1) 70 | (5068, 15, 6, 2, 39, 47, 1) 71 | (5069, 10, 4, 3, 40, 48, 1) 72 | (5070, 12, 8, 1, 41, 42, 1) 73 | (5071, 12, 4, 5, 42, 43, 1) 74 | (5072, 10, 8, 3, 43, 44, 1) 75 | (5073, 12, 4, 5, 44, 45, 1) 76 | (5074, 15, 8, 4, 45, 46, 0) 77 | (5075, 10, 4, 2, 46, 47, 1) 78 | (5076, 18, 8, 5, 47, 48, 1) 79 | (5077, 15, 6, 3, 41, 49, 1) 80 | (5078, 10, 8, 1, 42, 50, 1) 81 | (5079, 10, 4, 4, 43, 51, 1) 82 | (5080, 10, 8, 2, 44, 52, 0) 83 | (5081, 10, 8, 2, 45, 53, 1) 84 | (5082, 18, 8, 2, 46, 54, 1) 85 | (5083, 10, 6, 1, 48, 56, 1) 86 | (5084, 15, 8, 4, 49, 50, 1) 87 | (5085, 15, 8, 5, 50, 51, 0) 88 | (5086, 10, 4, 2, 51, 52, 1) 89 | (5087, 10, 4, 1, 52, 53, 1) 90 | (5088, 10, 4, 4, 54, 55, 1) 91 | (5089, 18, 8, 5, 55, 56, 1) 92 | (5090, 15, 6, 1, 49, 57, 1) 93 | (5091, 18, 8, 4, 50, 58, 1) 94 | (5092, 15, 8, 1, 51, 59, 1) 95 | (5093, 20, 6, 1, 52, 60, 1) 96 | (5094, 10, 4, 3, 53, 61, 1) 97 | (5095, 18, 8, 2, 54, 62, 1) 98 | (5096, 12, 8, 3, 55, 63, 1) 99 | (5097, 15, 8, 1, 56, 64, 1) 100 | (5098, 18, 4, 2, 57, 58, 1) 101 | (5099, 18, 8, 3, 58, 59, 1) 102 | (5100, 15, 8, 3, 59, 60, 1) 103 | (5101, 15, 6, 1, 60, 61, 1) 104 | (5102, 10, 4, 5, 61, 62, 1) 105 | (5103, 12, 8, 5, 62, 63, 1) 106 | (5104, 20, 6, 5, 63, 64, 1) -------------------------------------------------------------------------------- /CodeCraft2019/config-3/cross.txt: -------------------------------------------------------------------------------- 1 | #(id,roadId,roadId,roadId,roadId) 2 | (1, 5000, 5009, -1, -1) 3 | (2, 5001, 5010, 5000, -1) 4 | (3, 5002, 5011, 5001, -1) 5 | (4, 5003, 5012, 5002, -1) 6 | (5, 5004, 5013, 5003, -1) 7 | (6, 5005, 5014, 5004, -1) 8 | (7, 5006, 5015, 5005, -1) 9 | (8, 5007, 5016, 5006, -1) 10 | (9, 5008, 5017, 5007, -1) 11 | (10, -1, 5018, 5008, -1) 12 | (11, 5019, 5028, -1, 5009) 13 | (12, 5020, 5029, 5019, 5010) 14 | (13, 5021, -1, 5020, 5011) 15 | (14, 5022, 5030, 5021, 5012) 16 | (15, 5023, 5031, 5022, 5013) 17 | (16, 5024, 5032, 5023, 5014) 18 | (17, 5025, 5033, 5024, 5015) 19 | (18, 5026, 5034, 5025, 5016) 20 | (19, 5027, 5035, 5026, 5017) 21 | (20, -1, 5036, 5027, 5018) 22 | (21, 5037, 5043, -1, 5028) 23 | (22, -1, 5044, 5037, 5029) 24 | (23, 5038, 5045, -1, -1) 25 | (24, 5039, 5046, 5038, 5030) 26 | (25, 5040, -1, 5039, 5031) 27 | (26, -1, 5047, 5040, 5032) 28 | (27, 5041, -1, -1, 5033) 29 | (28, -1, 5048, 5041, 5034) 30 | (29, 5042, -1, -1, 5035) 31 | (30, -1, 5049, 5042, 5036) 32 | (31, 5050, 5059, -1, 5043) 33 | (32, 5051, 5060, 5050, 5044) 34 | (33, 5052, 5061, 5051, 5045) 35 | (34, 5053, 5062, 5052, 5046) 36 | (35, 5054, 5063, 5053, -1) 37 | (36, 5055, 5064, 5054, 5047) 38 | (37, 5056, 5065, 5055, -1) 39 | (38, 5057, -1, 5056, 5048) 40 | (39, 5058, 5066, 5057, -1) 41 | (40, -1, 5067, 5058, 5049) 42 | (41, 5068, 5076, -1, 5059) 43 | (42, 5069, 5077, 5068, 5060) 44 | (43, -1, -1, 5069, 5061) 45 | (44, 5070, 5078, -1, 5062) 46 | (45, 5071, 5079, 5070, 5063) 47 | (46, 5072, 5080, 5071, 5064) 48 | (47, 5073, 5081, 5072, 5065) 49 | (48, 5074, 5082, 5073, -1) 50 | (49, 5075, 5083, 5074, 5066) 51 | (50, -1, 5084, 5075, 5067) 52 | (51, 5085, 5094, -1, 5076) 53 | (52, 5086, 5095, 5085, 5077) 54 | (53, 5087, 5096, 5086, -1) 55 | (54, 5088, 5097, 5087, 5078) 56 | (55, 5089, 5098, 5088, 5079) 57 | (56, 5090, 5099, 5089, 5080) 58 | (57, 5091, -1, 5090, 5081) 59 | (58, 5092, 5100, 5091, 5082) 60 | (59, 5093, -1, 5092, 5083) 61 | (60, -1, 5101, 5093, 5084) 62 | (61, 5102, 5110, -1, 5094) 63 | (62, 5103, 5111, 5102, 5095) 64 | (63, 5104, 5112, 5103, 5096) 65 | (64, 5105, 5113, 5104, 5097) 66 | (65, -1, 5114, 5105, 5098) 67 | (66, 5106, 5115, -1, 5099) 68 | (67, 5107, 5116, 5106, -1) 69 | (68, 5108, 5117, 5107, 5100) 70 | (69, 5109, 5118, 5108, -1) 71 | (70, -1, 5119, 5109, 5101) 72 | (71, 5120, 5129, -1, 5110) 73 | (72, 5121, -1, 5120, 5111) 74 | (73, 5122, 5130, 5121, 5112) 75 | (74, 5123, 5131, 5122, 5113) 76 | (75, 5124, 5132, 5123, 5114) 77 | (76, 5125, 5133, 5124, 5115) 78 | (77, 5126, -1, 5125, 5116) 79 | (78, 5127, 5134, 5126, 5117) 80 | (79, 5128, -1, 5127, 5118) 81 | (80, -1, 5135, 5128, 5119) 82 | (81, 5136, 5144, -1, 5129) 83 | (82, 5137, 5145, 5136, -1) 84 | (83, 5138, 5146, 5137, 5130) 85 | (84, 5139, 5147, 5138, 5131) 86 | (85, -1, 5148, 5139, 5132) 87 | (86, 5140, -1, -1, 5133) 88 | (87, 5141, 5149, 5140, -1) 89 | (88, 5142, 5150, 5141, 5134) 90 | (89, 5143, 5151, 5142, -1) 91 | (90, -1, 5152, 5143, 5135) 92 | (91, 5153, -1, -1, 5144) 93 | (92, 5154, -1, 5153, 5145) 94 | (93, 5155, -1, 5154, 5146) 95 | (94, 5156, -1, 5155, 5147) 96 | (95, 5157, -1, 5156, 5148) 97 | (96, 5158, -1, 5157, -1) 98 | (97, 5159, -1, 5158, 5149) 99 | (98, 5160, -1, 5159, 5150) 100 | (99, 5161, -1, 5160, 5151) 101 | (100, -1, -1, 5161, 5152) -------------------------------------------------------------------------------- /CodeCraft2019/config-4/cross.txt: -------------------------------------------------------------------------------- 1 | #(id,roadId,roadId,roadId,roadId) 2 | (1, 5000, 5009, -1, -1) 3 | (2, 5001, 5010, 5000, -1) 4 | (3, 5002, 5011, 5001, -1) 5 | (4, 5003, 5012, 5002, -1) 6 | (5, 5004, 5013, 5003, -1) 7 | (6, 5005, 5014, 5004, -1) 8 | (7, 5006, 5015, 5005, -1) 9 | (8, 5007, 5016, 5006, -1) 10 | (9, 5008, 5017, 5007, -1) 11 | (10, -1, 5018, 5008, -1) 12 | (11, 5019, 5028, -1, 5009) 13 | (12, 5020, 5029, 5019, 5010) 14 | (13, 5021, -1, 5020, 5011) 15 | (14, 5022, 5030, 5021, 5012) 16 | (15, 5023, 5031, 5022, 5013) 17 | (16, 5024, 5032, 5023, 5014) 18 | (17, 5025, 5033, 5024, 5015) 19 | (18, 5026, 5034, 5025, 5016) 20 | (19, 5027, 5035, 5026, 5017) 21 | (20, -1, 5036, 5027, 5018) 22 | (21, 5037, 5043, -1, 5028) 23 | (22, -1, 5044, 5037, 5029) 24 | (23, 5038, 5045, -1, -1) 25 | (24, 5039, 5046, 5038, 5030) 26 | (25, 5040, -1, 5039, 5031) 27 | (26, -1, 5047, 5040, 5032) 28 | (27, 5041, -1, -1, 5033) 29 | (28, -1, 5048, 5041, 5034) 30 | (29, 5042, -1, -1, 5035) 31 | (30, -1, 5049, 5042, 5036) 32 | (31, 5050, 5059, -1, 5043) 33 | (32, 5051, 5060, 5050, 5044) 34 | (33, 5052, 5061, 5051, 5045) 35 | (34, 5053, 5062, 5052, 5046) 36 | (35, 5054, 5063, 5053, -1) 37 | (36, 5055, 5064, 5054, 5047) 38 | (37, 5056, 5065, 5055, -1) 39 | (38, 5057, -1, 5056, 5048) 40 | (39, 5058, 5066, 5057, -1) 41 | (40, -1, 5067, 5058, 5049) 42 | (41, 5068, 5076, -1, 5059) 43 | (42, 5069, 5077, 5068, 5060) 44 | (43, -1, -1, 5069, 5061) 45 | (44, 5070, 5078, -1, 5062) 46 | (45, 5071, 5079, 5070, 5063) 47 | (46, 5072, 5080, 5071, 5064) 48 | (47, 5073, 5081, 5072, 5065) 49 | (48, 5074, 5082, 5073, -1) 50 | (49, 5075, 5083, 5074, 5066) 51 | (50, -1, 5084, 5075, 5067) 52 | (51, 5085, 5094, -1, 5076) 53 | (52, 5086, 5095, 5085, 5077) 54 | (53, 5087, 5096, 5086, -1) 55 | (54, 5088, 5097, 5087, 5078) 56 | (55, 5089, 5098, 5088, 5079) 57 | (56, 5090, 5099, 5089, 5080) 58 | (57, 5091, -1, 5090, 5081) 59 | (58, 5092, 5100, 5091, 5082) 60 | (59, 5093, -1, 5092, 5083) 61 | (60, -1, 5101, 5093, 5084) 62 | (61, 5102, 5110, -1, 5094) 63 | (62, 5103, 5111, 5102, 5095) 64 | (63, 5104, 5112, 5103, 5096) 65 | (64, 5105, 5113, 5104, 5097) 66 | (65, -1, 5114, 5105, 5098) 67 | (66, 5106, 5115, -1, 5099) 68 | (67, 5107, 5116, 5106, -1) 69 | (68, 5108, 5117, 5107, 5100) 70 | (69, 5109, 5118, 5108, -1) 71 | (70, -1, 5119, 5109, 5101) 72 | (71, 5120, 5129, -1, 5110) 73 | (72, 5121, -1, 5120, 5111) 74 | (73, 5122, 5130, 5121, 5112) 75 | (74, 5123, 5131, 5122, 5113) 76 | (75, 5124, 5132, 5123, 5114) 77 | (76, 5125, 5133, 5124, 5115) 78 | (77, 5126, -1, 5125, 5116) 79 | (78, 5127, 5134, 5126, 5117) 80 | (79, 5128, -1, 5127, 5118) 81 | (80, -1, 5135, 5128, 5119) 82 | (81, 5136, 5144, -1, 5129) 83 | (82, 5137, 5145, 5136, -1) 84 | (83, 5138, 5146, 5137, 5130) 85 | (84, 5139, 5147, 5138, 5131) 86 | (85, -1, 5148, 5139, 5132) 87 | (86, 5140, -1, -1, 5133) 88 | (87, 5141, 5149, 5140, -1) 89 | (88, 5142, 5150, 5141, 5134) 90 | (89, 5143, 5151, 5142, -1) 91 | (90, -1, 5152, 5143, 5135) 92 | (91, 5153, -1, -1, 5144) 93 | (92, 5154, -1, 5153, 5145) 94 | (93, 5155, -1, 5154, 5146) 95 | (94, 5156, -1, 5155, 5147) 96 | (95, 5157, -1, 5156, 5148) 97 | (96, 5158, -1, 5157, -1) 98 | (97, 5159, -1, 5158, 5149) 99 | (98, 5160, -1, 5159, 5150) 100 | (99, 5161, -1, 5160, 5151) 101 | (100, -1, -1, 5161, 5152) -------------------------------------------------------------------------------- /CodeCraft2019/config2-check-1/cross.txt: -------------------------------------------------------------------------------- 1 | #(id,roadId,roadId,roadId,roadId) 2 | (18, 5887, -1, 5311, 6741) 3 | (61, 6852, 6224, 5247, 6480) 4 | (76, 6754, 6576, 5975, 5465) 5 | (77, 6634, 5588, 5610, 5148) 6 | (95, 6054, -1, 6703, 6576) 7 | (98, 6940, 6090, 6788, 6732) 8 | (117, 6617, 5657, 6253, 5973) 9 | (137, 6230, -1, 5887, 6849) 10 | (152, 6368, 5605, 6717, 6942) 11 | (183, 6324, 6597, 6898, 6897) 12 | (202, 5233, 6160, 5797, 6211) 13 | (328, 6601, 5144, 6072, 6623) 14 | (390, 6111, 5050, 5013, 5201) 15 | (394, 5844, 6121, 6717, 5144) 16 | (431, 6901, 5464, 5485, 6399) 17 | (480, 5700, 5148, 6602, 5995) 18 | (486, 5649, 5836, 6669, 5916) 19 | (495, 6726, 5067, 5653, 6634) 20 | (497, 5793, 6327, 5117, 6493) 21 | (519, 6467, 5165, 5289, 6351) 22 | (521, 6054, 5965, 5030, -1) 23 | (539, -1, 5218, 5739, 5368) 24 | (544, 6344, 6959, -1, -1) 25 | (555, 6998, 6617, 6127, -1) 26 | (556, 5610, 6597, 6852, 5142) 27 | (576, 5207, 5793, 6530, 5975) 28 | (579, -1, 5368, 5247, 6816) 29 | (583, 6224, 6324, 6176, 5806) 30 | (687, 6578, 6480, 5739, 5464) 31 | (757, 6696, 6524, 6010, 5022) 32 | (834, 5519, 6601, 6524, 6336) 33 | (850, -1, 5455, 6696, 5845) 34 | (858, 6569, -1, 6814, 6462) 35 | (936, -1, -1, 5393, 5270) 36 | (976, 5588, 5641, 5233, 6898) 37 | (999, 5685, 5641, 5653, 6368) 38 | (1024, 6788, 5393, -1, 5956) 39 | (1035, 6685, 5965, 6754, 5165) 40 | (1102, 5092, 5080, 6364, 5013) 41 | (1112, 6816, 5806, 5860, -1) 42 | (1131, -1, 6318, 5207, 6703) 43 | (1139, 6448, 5911, 6901, 6253) 44 | (1150, 6669, 6726, 5700, 6111) 45 | (1160, 5270, 6090, 5311, -1) 46 | (1188, 6977, 6683, 6850, 5450) 47 | (1191, 5485, 5218, -1, 6785) 48 | (1217, 6294, 6508, 5493, 5340) 49 | (1227, 5320, 6364, 5367, 5445) 50 | (1236, 6230, 6327, 6318, -1) 51 | (1265, 6685, 6092, -1, 5895) 52 | (1297, 6483, 6191, -1, 5845) 53 | (1346, 5289, 5465, 6905, 6121) 54 | (1347, 5275, 5241, 6998, -1) 55 | (1411, 5895, -1, -1, 5030) 56 | (1413, 6940, 5683, 6642, 6741) 57 | (1416, 5797, 5117, 6849, 6642) 58 | (1441, 5788, 6351, 5844, 5519) 59 | (1481, 5685, 5323, 6493, 6160) 60 | (1483, 6092, 6467, 6621, -1) 61 | (1497, 5241, 5092, 6676, 5657) 62 | (1538, 6865, 5080, 5275, -1) 63 | (1556, 5860, 6541, 5956, -1) 64 | (1610, -1, 6621, 5788, 5827) 65 | (1650, 6905, 6530, 5323, 6942) 66 | (1651, 5450, 6483, 5022, 6294) 67 | (1676, 6814, -1, 6959, 6683) 68 | (1680, 6127, 5130, 5663, -1) 69 | (1689, 6336, 5455, -1, 5827) 70 | (1719, 5663, 5039, -1, -1) 71 | (1748, 5973, 6399, 6287, 5130) 72 | (1763, 5303, 6897, 6211, 5683) 73 | (1767, 5303, 6732, 6541, 6176) 74 | (1778, -1, 6569, 5367, 6865) 75 | (1820, 5445, 6462, 6977, 5340) 76 | (1824, 5201, 5320, 5493, 5916) 77 | (1846, 6344, -1, 6191, 6850) 78 | (1885, 5836, 6072, 5605, 5067) 79 | (1933, 5911, 6602, 5142, 6578) 80 | (1956, 6676, 5050, 5995, 6448) 81 | (1970, 6508, 6010, 6623, 5649) 82 | (1973, 6287, 6785, -1, 5039) -------------------------------------------------------------------------------- /CodeCraft2019/config2-check-1/判题结果.txt: -------------------------------------------------------------------------------- 1 | specialResult is Result{scheduleTime = 207, allScheduleTime = 89895} 2 | originResult is Result{scheduleTime = 613, allScheduleTime = 2732618} 3 | CodeCraftJudge end schedule time is 909 allScheduleTime is 3443372 -------------------------------------------------------------------------------- /CodeCraft2019/config2-check-2/cross.txt: -------------------------------------------------------------------------------- 1 | #(id,roadId,roadId,roadId,roadId) 2 | (15, -1, 5570, 5489, 5229) 3 | (16, 6083, 6236, -1, 5146) 4 | (35, 5836, 5709, 6556, 5440) 5 | (70, 6856, 5131, 6050, 6513) 6 | (74, 5619, 5834, -1, 6046) 7 | (102, 5912, 5339, 5424, 6000) 8 | (117, 5455, 5271, 5909, 6939) 9 | (188, 6556, 6555, 5351, 5920) 10 | (200, 5239, 5111, 6613, 6939) 11 | (212, 6272, 5000, 6666, 5785) 12 | (243, 5493, 6884, 6810, 5225) 13 | (262, 6681, 6148, 6917, 5566) 14 | (274, -1, 6029, 5664, 5146) 15 | (296, -1, 5090, 6922, 6118) 16 | (329, -1, 5983, 6951, 5105) 17 | (330, 6875, 6806, 6610, 6986) 18 | (331, 6981, 5026, 6056, -1) 19 | (358, 5405, 5268, 6692, 5455) 20 | (362, 6457, 6513, 6046, -1) 21 | (404, 6403, 6007, 5912, 5713) 22 | (427, 6079, 5664, 5317, 6165) 23 | (495, 5558, 5983, -1, 6815) 24 | (534, 6716, 5975, 5111, 5502) 25 | (540, 6527, -1, -1, 5562) 26 | (557, -1, 5203, 5760, 6815) 27 | (566, 6547, 5026, 5424, 5767) 28 | (573, 6686, 5909, 6083, 6079) 29 | (575, 6748, 5760, 5471, 5975) 30 | (599, 6056, 5960, 6457, -1) 31 | (604, 6050, 6152, 5438, 5619) 32 | (617, 5970, 5570, -1, -1) 33 | (663, 5669, 6523, 5317, 5821) 34 | (687, 6527, 5268, 6927, -1) 35 | (768, 6664, 6692, 5562, -1) 36 | (770, 5465, 6523, 5468, 6058) 37 | (798, 5489, 6461, 5438, 6043) 38 | (808, 5649, 6570, 5669, 5305) 39 | (809, -1, 5223, 5713, 5839) 40 | (838, 6511, 5995, 5397, 5880) 41 | (898, 5339, 5579, 6555, 6311) 42 | (921, 5468, 6570, 5995, 6917) 43 | (930, 5150, 5107, 6705, 5440) 44 | (933, 6579, 5700, 5340, -1) 45 | (982, 6209, 5397, 5649, 5700) 46 | (999, 6776, 6863, 5579, 6007) 47 | (1084, 6272, 6806, 6058, 6148) 48 | (1088, 6547, 6884, 6856, 5960) 49 | (1142, 6810, 5767, 6311, 5709) 50 | (1168, 6664, -1, 6236, 5271) 51 | (1212, 5768, 6055, 5481, 6922) 52 | (1252, 6871, 6622, 6799, 5803) 53 | (1303, 6209, 6821, -1, 6736) 54 | (1331, 5826, 5155, 5131, 5493) 55 | (1338, 6161, -1, 5105, 6776) 56 | (1344, 6066, -1, 5229, 6989) 57 | (1357, -1, 5839, 6000, 6981) 58 | (1363, 6622, 5768, 6720, 6805) 59 | (1364, -1, 5340, 5305, 5591) 60 | (1379, 5566, 6511, 6643, 5481) 61 | (1392, 6927, 6445, 5203, -1) 62 | (1422, 6720, 5090, -1, 6066) 63 | (1453, -1, 6161, 6403, 5286) 64 | (1475, 6461, 5970, -1, 5834) 65 | (1525, 5550, 6705, 6610, 5785) 66 | (1561, 5502, 6600, 6986, 5107) 67 | (1565, 5803, 5826, 5593, 6666) 68 | (1573, 6029, -1, 5591, 5821) 69 | (1612, 5465, 6875, 6735, 6165) 70 | (1628, 6639, 5558, 6748, 5559) 71 | (1636, 6174, 5880, 6736, -1) 72 | (1675, -1, -1, 6821, 6579) 73 | (1693, 6152, 5155, 6799, 6348) 74 | (1705, 6348, 6805, 6989, 6043) 75 | (1805, 6639, 5351, 6863, 6951) 76 | (1806, 5836, 5550, 5593, 5225) 77 | (1807, 6871, 5000, 6681, 6055) 78 | (1812, 5405, 6613, 5471, 6445) 79 | (1859, -1, -1, 5286, 5223) 80 | (1899, 5150, 5920, 5559, 6716) 81 | (1973, 6643, 6174, -1, 6118) 82 | (1980, 6735, 6600, 5239, 6686) -------------------------------------------------------------------------------- /CodeCraft2019/config2-check-2/判题结果.txt: -------------------------------------------------------------------------------- 1 | specialResult is Result{scheduleTime = 190, allScheduleTime = 81636} 2 | originResult is Result{scheduleTime = 622, allScheduleTime = 2718989} 3 | CodeCraftJudge end schedule time is 897 allScheduleTime is 3386497 -------------------------------------------------------------------------------- /CodeCraft2019/config3-1/relation.txt: -------------------------------------------------------------------------------- 1 | # 车号,车牌文件名 2 | 25826, 2a996130912f4cbf.jpg 3 | 72383, 2a9bc390b0c84dfd.jpg 4 | 42134, 2a9e25eea92328c7.jpg 5 | 86247, 2aa0884aa93d7160.jpg 6 | 90761, 2aa0884b85f360c7.jpg 7 | 106713, 2aa0884c8b61ec05.jpg 8 | 101248, 2aa2eaa89295ef10.jpg 9 | 17305, 2aa54d088ec40625.jpg 10 | 44544, 2aa7af6486c280c7.jpg 11 | 86055, 2aa7af65b19b75eb.jpg 12 | 44057, 2aac74228d4faa40.jpg 13 | 107582, 2aac7423af9cf9e2.jpg 14 | 76153, 2aaed6808b1ab599.jpg 15 | 12589, 2ab138dcb08f6d3a.jpg 16 | 79877, 2ab138dd848c6c3c.jpg 17 | 70628, 2ab39b3a8892ed0d.jpg 18 | 105621, 2ab39b3b8f34a0da.jpg 19 | 64223, 2ab5fd9a8bd05938.jpg 20 | 60102, 2ab5fd9bb1876484.jpg 21 | 50714, 2ab85ff68c72b24a.jpg 22 | 33513, 2abac254b8ad9d04.jpg 23 | 40808, 2abac2559ae7e8fd.jpg 24 | 97332, 2abd24b4bdc812d4.jpg 25 | 76175, 2abf8712b5200768.jpg 26 | 72959, 2abf87139e17ccb1.jpg 27 | 108926, 2ac1e96ebeeaa9c1.jpg 28 | 19486, 2ac44bcc8cfd85fe.jpg 29 | 21700, 2ac44bcd98cef6df.jpg 30 | 30019, 2ac6ae2cb16d914f.jpg 31 | 72789, 2ac9108a8c4b5958.jpg 32 | 108407, 2ac9108b96c4061b.jpg 33 | 74736, 2acb72e6b4363101.jpg 34 | 23508, 2acb72e793bea346.jpg 35 | 45965, 2acdd546a30365d3.jpg 36 | 53361, 2ad037a4afe6bdc9.jpg 37 | 90902, 2ad037a582ed83a9.jpg 38 | 63672, 2ad29a00b978dfd6.jpg 39 | 64054, 2ad29a01bdb20c3c.jpg 40 | 30319, 2ad4fc5e8f21fed7.jpg 41 | 14281, 2ad4fc5f888a7547.jpg 42 | 76634, 2ad75ebe9376488b.jpg 43 | 89261, 2ad75ebfa5d88393.jpg 44 | 37282, 2ad9c11ca05f2074.jpg 45 | 63111, 2adc2378a1f515f1.jpg 46 | 62893, 2adc237982a2ef2d.jpg 47 | 70839, 2ade85d8a6cd9693.jpg 48 | 33389, 2ade85d981c3d5fb.jpg 49 | 31367, 2ae0e8368a33d279.jpg 50 | 36653, 2ae0e83794b46374.jpg 51 | 10207, 2ae34a92acbfe3f3.jpg 52 | 39412, 2ae5acf0aca98a78.jpg 53 | 95287, 2ae5acf1810f76b6.jpg 54 | 72607, 2ae80f50acde88fd.jpg 55 | 19561, 2ae80f5183c6cb3d.jpg 56 | 87810, 2aea71aeb24c0181.jpg 57 | 18771, 2aea71af934a474c.jpg 58 | 29104, 2aecd40a99a41de5.jpg 59 | 68966, 2aecd40b966f96bf.jpg 60 | 53074, 2aef36689c096cda.jpg 61 | 103853, 2af198c887fcd46e.jpg 62 | 47889, 2af3fb24994f54ed.jpg 63 | 71325, 2af3fb2581cdbcfa.jpg 64 | 82670, 2af65d82a02fabd3.jpg 65 | 42764, 2af65d838272fdbe.jpg 66 | 21179, 2af8bfe2b380dd02.jpg 67 | 26667, 2afb224080ff09af.jpg 68 | 105338, 2afb2241a1f7acb9.jpg 69 | 67155, 2afd849c94080e80.jpg 70 | 16337, 2afd849d8ac292a9.jpg 71 | 48037, 2affe6fa9f1c2e64.jpg 72 | 24755, 2b04abb695706d16.jpg 73 | 16864, 2b04abb78700bfbe.jpg 74 | 91437, 2b0bd2d2b8aac769.jpg 75 | 70837, 2b0bd2d3829c2dda.jpg 76 | 64498, 2b0e352eb40f09ec.jpg 77 | 95008, 2b1a21068feb7f9b.jpg 78 | 55913, 2b1a2107a59f8d63.jpg 79 | 12666, 2b1c8364840a8f13.jpg 80 | 71825, 2b1c8365b857f01d.jpg 81 | 30758, 2b1ee5c0b6063cbb.jpg 82 | 34423, 2b1ee5c1bde76062.jpg 83 | 104560, 2b2ad198b57a8dee.jpg 84 | 41144, 2b2ad1998b5b6b9b.jpg 85 | 64363, 2b2d33f692799e01.jpg 86 | 62051, 2b2f96529d77587f.jpg 87 | 57637, 2b2f96539c9b197f.jpg 88 | 85116, 2b2f9654be7105d3.jpg 89 | 27693, 2b3b8228ae41201c.jpg 90 | 98066, 2b3b8229ade468a0.jpg 91 | 105666, 2b3de4889dc12291.jpg 92 | 105590, 2b4c32ba863f1558.jpg 93 | 58002, 2b4c32bbb15204f4.jpg 94 | 103532, 2b4e951a813c1e44.jpg 95 | 97615, 2b4e951b8deaa397.jpg 96 | 87727, 2b5a80eea66d6843.jpg 97 | 83049, 2b5a80ef8a2aefc9.jpg 98 | 55392, 2b5ce34c84a2d928.jpg 99 | 58115, 2b5ce34daf844fd9.jpg 100 | 90083, 2b5f45acac6db35f.jpg 101 | 93054, 2b5f45ad91f8d913.jpg -------------------------------------------------------------------------------- /CodeCraft2019/config3-2/relation.txt: -------------------------------------------------------------------------------- 1 | # 车号,车牌文件名 2 | 61838, 4275d1ee9c495d27.jpg 3 | 68468, 4281bdc2aecadfa0.jpg 4 | 80630, 4288e4dc87c55c43.jpg 5 | 57017, 4294d0b495051f3a.jpg 6 | 87002, 4304dff68749d63d.jpg 7 | 21932, 4309a4b0a2492bb3.jpg 8 | 49125, 4310cbcaa7bde1f9.jpg 9 | 46971, 4317f2e4b87f57bc.jpg 10 | 81841, 4323debaa5cb7beb.jpg 11 | 63484, 4328a376be435b6f.jpg 12 | 103954, 4336f1aca8f32838.jpg 13 | 46419, 4342dd80ae3f270c.jpg 14 | 105771, 4347a23e99aaea98.jpg 15 | 102740, 4355f070b6f03b3c.jpg 16 | 19006, 4361dc4893edbf04.jpg 17 | 84032, 4366a1029698e98e.jpg 18 | 68382, 4393edfea4b8b89d.jpg 19 | 16636, 4403fd4091b6d118.jpg 20 | 35416, 4408c1faa308fab2.jpg 21 | 34173, 4414add2a3a669c0.jpg 22 | 86236, 4422fc06a89a184e.jpg 23 | 99769, 4427c0c09d1d3a6e.jpg 24 | 13282, 4433ac98b32a57fa.jpg 25 | 18824, 4441faca9aa27423.jpg 26 | 102768, 4446bf88bb08e1c8.jpg 27 | 10654, 4459d276878dd152.jpg 28 | 31866, 4460f992a08827a6.jpg 29 | 92078, 4465be4c8e373ba6.jpg 30 | 50180, 4471aa24bfee0ef6.jpg 31 | 63163, 4478d13e863a7a92.jpg 32 | 12418, 4484bd12913a7cca.jpg 33 | 21281, 4490a8e881dc3c95.jpg 34 | 63104, 4497d002873a54ad.jpg 35 | 18279, 4500b82cae78fa43.jpg 36 | 11867, 4507df469974099a.jpg 37 | 32462, 4513cb1c94d743ce.jpg 38 | 66481, 4526de0a851631df.jpg 39 | 68516, 4539f0fa825fdde5.jpg 40 | 44961, 4551c8a686fc8198.jpg 41 | 69038, 4564db98a7df0e7a.jpg 42 | 58183, 4577ee889cc0c634.jpg 43 | 107876, 4596ed4ca8ddf7bd.jpg 44 | 89921, 4606fc90b709aaaa.jpg 45 | 74946, 4612e8648a57d946.jpg 46 | 16061, 4617ad228ca0815a.jpg 47 | 94103, 4631e72c976624fc.jpg 48 | 84202, 4636abe69f36b762.jpg 49 | 24461, 4644fa1cbef1b1e0.jpg 50 | 43810, 4649bed8b5307269.jpg 51 | 18590, 4650e5f0900b324c.jpg 52 | 72347, 4655aaae9927ecad.jpg 53 | 108038, 4668bd9c8bbc65ae.jpg 54 | 85794, 4693a838993ba67c.jpg 55 | 42783, 4703b77a940e78db.jpg 56 | 12153, 4716ca6c90201fe1.jpg 57 | 66238, 4735c930b210b4a4.jpg 58 | 50394, 4748dc229d997224.jpg 59 | 108874, 4754c7f68868cbc0.jpg 60 | 96397, 4760b3ccb2cf655b.jpg 61 | 29715, 4767dae6b5378414.jpg 62 | 99751, 4773c6be93a3fdf1.jpg 63 | 88824, 4786d9ae888bcdac.jpg 64 | 46620, 4792c5828324a878.jpg 65 | 21724, 4799ec9c8e2eb066.jpg 66 | 58132, 4809fbde80f3acb6.jpg 67 | 47003, 4815e7b6a8c7ddd8.jpg 68 | 69391, 4828faa48a89d5da.jpg 69 | 109336, 4839ab3699038c50.jpg 70 | 92841, 4840d252819b8577.jpg 71 | 109974, 4853e5409ede7643.jpg 72 | 69474, 4858a9fe9796ea05.jpg 73 | 11882, 4866f830880b88a4.jpg 74 | 77573, 4872e4089a9f458f.jpg 75 | 94392, 4877a8c295b1da88.jpg 76 | 24250, 4885f6f69fbfc4bb.jpg 77 | 101530, 4891e2ccb70ab289.jpg 78 | 84323, 4896a78a86645b0e.jpg 79 | 31282, 4901f2108eec1ddc.jpg 80 | 50421, 4906b6ca89c76208.jpg 81 | 60630, 4912a2a2bcd8b137.jpg 82 | 66381, 4919c9baa028e73f.jpg 83 | 83177, 4920f0d4983d3672.jpg 84 | 39002, 4925b59292b75aa7.jpg 85 | 54488, 4931a166b68e4817.jpg 86 | 53368, 4944b458a9bd349f.jpg 87 | 33025, 4950a02ea0cb476b.jpg 88 | 36976, 4957c748993dc9e5.jpg 89 | 100548, 4963b31ca903d34b.jpg 90 | 87408, 4982b1e4a1a9ffe7.jpg 91 | 37506, 4989d8feb58168ed.jpg 92 | 24482, 4995c4d286bbb626.jpg 93 | 64147, 5002e62ead4a1d23.jpg 94 | 78512, 5015f91e9b2a83eb.jpg 95 | 15467, 5021e4f6aa2b6265.jpg 96 | 28062, 5026a9b083dc044b.jpg 97 | 91752, 5034f7e4aff383f1.jpg 98 | 33461, 5039bca285328ad0.jpg 99 | 107595, 5040e3bab05e5ab2.jpg 100 | 78341, 5045a876bc897c69.jpg 101 | 10259, 5053f6ac90bd0737.jpg -------------------------------------------------------------------------------- /CodeCraft2019/config3-exam-1/relation.txt: -------------------------------------------------------------------------------- 1 | # 车号,车牌文件名 2 | 61127, 5064a73e804aea06.jpg 3 | 41964, 5083a6028df79214.jpg 4 | 64054, 5096b8f49a9344bc.jpg 5 | 15446, 5106c836ae30a2da.jpg 6 | 95354, 5112b40aaca1e52b.jpg 7 | 18691, 5119db24a1c7b93e.jpg 8 | 22201, 5125c6faad522bea.jpg 9 | 49932, 5131b2d286436a2c.jpg 10 | 98490, 5144c5c086a45afc.jpg 11 | 59257, 5150b198ae9ddb7f.jpg 12 | 100347, 5163c488ae7b6453.jpg 13 | 106956, 5176d7768be3fba3.jpg 14 | 91825, 5182c34cb03a240a.jpg 15 | 23283, 5189ea66958e10eb.jpg 16 | 33914, 5195d63e94d0c7a6.jpg 17 | 94446, 5205e58090602d90.jpg 18 | 57218, 5211d154a2ae8048.jpg 19 | 102329, 5218f86eb1a4e39a.jpg 20 | 81811, 5229a900bd8c7f25.jpg 21 | 27139, 5237f73683470a8e.jpg 22 | 73495, 5243e30ab684998d.jpg 23 | 97120, 5248a7c8a66e43f8.jpg 24 | 15595, 5256f5faab31dab3.jpg 25 | 69089, 5262e1d2bee3d0aa.jpg 26 | 58107, 5267a68ca240c037.jpg 27 | 77318, 5281e09890d4d4fe.jpg 28 | 76845, 5286a55283bb1743.jpg 29 | 48985, 5294f388bcad7c2c.jpg 30 | 94460, 5302a06cb1b15f60.jpg 31 | 18695, 5309c78687b0826f.jpg 32 | 72805, 5310ee9e810b0f0a.jpg 33 | 75623, 5315b35cb30c61a3.jpg 34 | 29456, 5328c64a9c7305aa.jpg 35 | 34052, 5334b222a60d6cf4.jpg 36 | 40387, 5347c51298734630.jpg 37 | 12619, 5353b0e6b68bdbc5.jpg 38 | 37752, 5361ff1cb98858e3.jpg 39 | 46586, 5366c3d8906d011d.jpg 40 | 43092, 5372afaea2594cb7.jpg 41 | 43070, 5379d6c898b86e7c.jpg 42 | 99946, 5380fde29d07a002.jpg 43 | 20713, 5385c29cadf983c1.jpg 44 | 61909, 5391ae749d6f8f0e.jpg 45 | 88791, 5398d58c88f8a745.jpg 46 | 44813, 5401bdb6b90ab456.jpg 47 | 41126, 5414d0a488b8951e.jpg 48 | 33741, 5420bc7a85a7f34b.jpg 49 | 95805, 5433cf6ca3031270.jpg 50 | 14256, 5446e25c9e99a51c.jpg 51 | 15839, 5459f54a8749c0c2.jpg 52 | 78652, 5471ccf6bf31b5fb.jpg 53 | 15625, 5484dfe6803866dd.jpg 54 | 51012, 5489a4a4a0577f02.jpg 55 | 38116, 5490cbbea1330579.jpg 56 | 10272, 5518b2ac8488adcb.jpg 57 | 83082, 5545ffa4b34a72fe.jpg 58 | 23415, 5556b03681bee734.jpg 59 | 18049, 5564fe6ca76922cf.jpg 60 | 38797, 5569c3268f1b4002.jpg 61 | 47269, 5570ea40baf73911.jpg 62 | 103419, 5575aefe946179ee.jpg 63 | 38405, 5583fd3099344b37.jpg 64 | 54532, 5588c1ee8946c64a.jpg 65 | 36097, 5594adc29e442dc0.jpg 66 | 49983, 5604bd0690e0ba87.jpg 67 | 73239, 5610a8dc9c0ca3cd.jpg 68 | 70132, 5617cff6baf53ffd.jpg 69 | 37579, 5623bbcabea1957e.jpg 70 | 53055, 5642ba9284671eb4.jpg 71 | 92458, 5649e1acbefc0718.jpg 72 | 36892, 5661b958aff40bdf.jpg 73 | 104369, 5668e070a530c99b.jpg 74 | 56784, 5674cc4887929aed.jpg 75 | 54079, 5680b81caa47ce84.jpg 76 | 39648, 5687df36985666bf.jpg 77 | 47416, 5693cb0c9a2b715b.jpg 78 | 20840, 5703da50a5144526.jpg 79 | 36854, 5716ed40a4c6cf5c.jpg 80 | 25428, 5735ec06ab48ab61.jpg 81 | 72049, 5741d7dc852bacf7.jpg 82 | 38849, 5748fef68e0af6a7.jpg 83 | 81969, 5754eacab2aa2a33.jpg 84 | 100591, 5759af88b81cb95f.jpg 85 | 84406, 5767fdba85d382d5.jpg 86 | 58122, 5773e992ab08f450.jpg 87 | 22169, 5778ae4cb4bec4e0.jpg 88 | 105284, 5786fc80ac73cddd.jpg 89 | 42498, 5792e858800edc67.jpg 90 | 11568, 5797ad1294e0aa5d.jpg 91 | 85274, 5802f79a96fe1ccf.jpg 92 | 31040, 5807bc54a1b8d8a5.jpg 93 | 35555, 5813a82cb2d45ad2.jpg 94 | 63141, 5821f65e925287f4.jpg 95 | 53409, 5826bb1c91c57e0a.jpg 96 | 67956, 5832a6f0b4286712.jpg 97 | 87768, 5839ce0a984ad333.jpg 98 | 44363, 5845b9e298fe85a4.jpg 99 | 67094, 5851a5b68cc0e88b.jpg 100 | 53842, 5858ccd2bd1cfefd.jpg 101 | 65340, 5864b8a6ac215822.jpg -------------------------------------------------------------------------------- /CodeCraft2019/config3-exam-2/cross.txt: -------------------------------------------------------------------------------- 1 | #(id,roadId,roadId,roadId,roadId) 2 | (8, -1, 5451, 6662, 5742) 3 | (18, -1, -1, 5961, 6587) 4 | (23, -1, -1, 5389, 6069) 5 | (50, 6103, 5296, 6253, 5805) 6 | (65, 5790, 5151, 5383, 6898) 7 | (82, 6854, 5716, 6238, 5389) 8 | (109, 6011, 5951, 5291, 5008) 9 | (119, 6044, 6846, 5987, 5995) 10 | (128, 5853, 6112, 5268, 5639) 11 | (135, 6745, 5430, 6238, 5590) 12 | (143, -1, 6337, 6808, -1) 13 | (149, 6158, 5081, 5659, 6246) 14 | (154, 6293, 5131, 5967, 5438) 15 | (156, 5326, -1, -1, 5949) 16 | (163, 6456, 6544, 6022, 5461) 17 | (164, 6308, -1, -1, 5205) 18 | (176, 6642, 6349, 6350, 6769) 19 | (218, 5823, 5833, 6349, 6902) 20 | (246, 5085, 5081, 5713, 6319) 21 | (258, -1, -1, 6550, 5790) 22 | (294, 6022, 6165, 6412, 5120) 23 | (322, 6472, 6223, 5843, 6570) 24 | (351, 6667, 6117, 6424, 6805) 25 | (370, 6435, 6201, 5214, 5713) 26 | (375, -1, 5559, 6610, 6569) 27 | (389, 5650, 5131, 6112, 5292) 28 | (392, 6190, 5480, 6500, 6456) 29 | (418, 5868, 5309, 5234, 5259) 30 | (428, 6044, 6049, -1, -1) 31 | (429, -1, -1, 6577, 5833) 32 | (459, 6165, 6664, -1, -1) 33 | (463, 5085, 6148, 6026, 5972) 34 | (467, 5708, 5175, 5975, 5836) 35 | (477, -1, 5577, 6324, 5878) 36 | (490, 6098, 6745, 6828, 5313) 37 | (495, 5329, 5438, 6464, 6472) 38 | (499, 6924, 5291, 5418, 5250) 39 | (504, -1, -1, 6805, 5868) 40 | (510, 6213, 6312, 5590, 6035) 41 | (517, 5705, 6436, 6201, 5016) 42 | (553, 6234, 5515, -1, 6092) 43 | (556, 5326, 5418, 6381, -1) 44 | (565, 6090, 5329, 5596, 6049) 45 | (603, 5205, 5457, 5676, 6803) 46 | (615, 5711, 5748, 5128, 6307) 47 | (616, 6098, 5245, 6193, 5142) 48 | (653, 6905, 5094, 6011, 6501) 49 | (664, 6323, 6924, 5888, 6223) 50 | (668, 6148, 5648, 6788, 5128) 51 | (683, 5961, 6082, 6392, 5112) 52 | (685, 5346, 6919, 5461, 6823) 53 | (692, 5728, 6500, 5614, -1) 54 | (714, 5016, -1, -1, 5691) 55 | (777, 6780, 5062, -1, -1) 56 | (789, 6701, 5801, 5691, 5224) 57 | (796, 6444, 5705, 5801, 5676) 58 | (831, -1, 5823, 6824, -1) 59 | (834, 6650, 5412, -1, -1) 60 | (855, 6026, 5748, 5383, 6253) 61 | (906, 6376, 6739, 5862, 6444) 62 | (918, 6035, 5716, 6610, 6945) 63 | (928, 6172, -1, 6381, 5951) 64 | (947, 5013, 5479, 5604, 6769) 65 | (982, -1, -1, 6816, 5604) 66 | (1014, -1, 5742, 5108, 5577) 67 | (1028, 6928, 5313, 5465, 5112) 68 | (1032, 6069, 5430, 5142, 6650) 69 | (1044, -1, -1, 6203, 6682) 70 | (1113, 5972, 5296, 5911, 5659) 71 | (1152, 6662, 5648, 6319, 6279) 72 | (1179, -1, -1, 6170, 5243) 73 | (1180, -1, 6376, 5457, -1) 74 | (1193, 6117, 6389, 6190, 6919) 75 | (1205, 6808, 5091, 5559, -1) 76 | (1208, 5711, -1, -1, 6898) 77 | (1240, 5843, 6944, 6642, 6816) 78 | (1250, 5451, -1, 5829, 6788) 79 | (1253, 6046, 6337, 6308, 6960) 80 | (1254, -1, -1, 5259, 6082) 81 | (1258, 5888, 6509, 6902, 6944) 82 | (1263, 5151, 5323, 5853, 5805) 83 | (1291, 6432, 5911, 5367, 5014) 84 | (1318, 5323, 6550, 5243, 5292) 85 | (1326, 5933, 6828, 6312, 5366) 86 | (1327, -1, -1, 6905, 6999) 87 | (1337, -1, -1, 6569, 6854) 88 | (1339, 5218, -1, -1, 5515) 89 | (1356, 5437, 6436, 5862, 6324) 90 | (1384, 6577, 5218, 6462, 6350) 91 | (1425, 5387, 6667, -1, -1) 92 | (1438, 6664, 6544, 5728, -1) 93 | (1474, 6193, 5938, 6203, 5412) 94 | (1482, 6928, 5503, 5105, 5245) 95 | (1489, 6557, 5480, 5827, 6270) 96 | (1494, 6435, 6158, -1, -1) 97 | (1507, 6432, -1, -1, 6246) 98 | (1513, 5224, 5062, 5366, 5797) 99 | (1514, 6424, 5346, 5175, 5309) 100 | (1544, 6270, 5013, 6462, 6234) 101 | (1567, 5268, 6293, 6090, 5995) 102 | (1589, 6780, 6587, 5465, 5933) 103 | (1600, 5120, 6113, 5975, 6823) 104 | (1602, 6213, 6833, 6641, 5797) 105 | (1623, 6509, 5250, 5949, 6824) 106 | (1670, 6846, -1, -1, 5014) 107 | (1680, 5987, 5367, 6103, 5639) 108 | (1754, -1, -1, 6307, 5829) 109 | (1769, -1, -1, 5712, 6412) 110 | (1789, 5387, 5479, 5827, 6389) 111 | (1798, 5108, 6279, 5214, 5437) 112 | (1803, -1, 5614, 6557, 6092) 113 | (1816, -1, 5878, 6739, -1) 114 | (1817, 5938, 5105, 5836, 6830) 115 | (1859, 6643, 5967, 5036, 6501) 116 | (1884, 5650, 6170, 6999, 5036) 117 | (1889, 5712, 6682, 6830, 6113) 118 | (1919, 5596, 6570, -1, -1) 119 | (1948, 5503, 6392, 5234, 5708) 120 | (1957, -1, -1, 6172, 5094) 121 | (1973, 6945, 5091, 6046, 6833) 122 | (1985, 6643, 5008, 6323, 6464) 123 | (1997, 6701, 6641, 6960, 6803) -------------------------------------------------------------------------------- /CodeCraft2019/config3-exam-2/relation.txt: -------------------------------------------------------------------------------- 1 | # 车号,车牌文件名 2 | 40236, 30003e2894302355.jpg 3 | 36536, 30324fdea5e36bfe.jpg 4 | 74692, 30409e12875f83c0.jpg 5 | 81161, 30514ea491ead2fa.jpg 6 | 49381, 30704d6c9473f135.jpg 7 | 68930, 31100c0685a21a5f.jpg 8 | 96571, 31126e648f00f766.jpg 9 | 95715, 31231ef69cef7f53.jpg 10 | 54622, 31316d2895b2c28f.jpg 11 | 19154, 31421dba93f1d28f.jpg 12 | 72965, 31611c80b4c12893.jpg 13 | 98330, 31742f7080a91ff0.jpg 14 | 46947, 31801b488daa3705.jpg 15 | 28695, 31827da4b2162f89.jpg 16 | 30035, 31932e36a65cbdc6.jpg 17 | 40062, 32033d78a75f6501.jpg 18 | 40122, 32059fd8aa871fad.jpg 19 | 40906, 32118baeab639a72.jpg 20 | 70482, 32223c40a73cea89.jpg 21 | 43073, 32249e9cbaa1c16c.jpg 22 | 53382, 32308a749572046c.jpg 23 | 97023, 32354f2eb04dce1e.jpg 24 | 32436, 32413b06a707d131.jpg 25 | 66848, 32439d6498a2ed16.jpg 26 | 94652, 32544df6bd30551c.jpg 27 | 103206, 32629c28a2d09bf3.jpg 28 | 66847, 32734cbab9bbf708.jpg 29 | 78132, 32819aeeb5bc3f2e.jpg 30 | 82579, 32924b80a19122a4.jpg 31 | 47660, 33025ac2a81105a4.jpg 32 | 10496, 33071f80ae3649bf.jpg 33 | 16561, 33130b549a282c09.jpg 34 | 70684, 33156db49c9f7c70.jpg 35 | 103469, 33261e46bc30639f.jpg 36 | 39070, 33320a1c8adce51e.jpg 37 | 14986, 33346c78823a6439.jpg 38 | 50663, 33451d0ab5a0a2ce.jpg 39 | 57345, 33477f68af49127a.jpg 40 | 49947, 33536b408e69a5ff.jpg 41 | 17655, 33641bd2b0b66e7a.jpg 42 | 84771, 33667e2e9dbabab9.jpg 43 | 58368, 33726a06ad508c25.jpg 44 | 53041, 33772ec09930d771.jpg 45 | 35177, 33857cf68fadb940.jpg 46 | 41023, 33962d889189355f.jpg 47 | 24992, 33988fe4ade45133.jpg 48 | 71068, 34253b90a572f635.jpg 49 | 73741, 34279deeb1ba5c7b.jpg 50 | 77702, 34469cb490364802.jpg 51 | 19020, 34574d4696f2d0da.jpg 52 | 109278, 34659b78ae9814a3.jpg 53 | 65081, 34849a40a67ccc3f.jpg 54 | 50373, 34895efa8d46be83.jpg 55 | 71450, 34954ad299f7d283.jpg 56 | 75990, 35055a1291ad67d8.jpg 57 | 77315, 35160aa49f5b1307.jpg 58 | 16224, 35186d02be4524eb.jpg 59 | 35545, 35291d94af69aad6.jpg 60 | 35449, 35376bca93d841f8.jpg 61 | 86811, 35481c5caace9908.jpg 62 | 12732, 35566a90b895f7b0.jpg 63 | 50298, 35671b22bf02f7aa.jpg 64 | 78844, 35697d80b97e4705.jpg 65 | 20196, 35992cd8b1ba5933.jpg 66 | 59800, 36178a4cb2c65b5a.jpg 67 | 85280, 36689aca9712846b.jpg 68 | 107707, 36794b5cb6326225.jpg 69 | 97517, 36984a22bb127e8e.jpg 70 | 21616, 38004f92998b6c02.jpg 71 | 46218, 38810f66af8396ee.jpg 72 | 20527, 39101d6ea8a75a02.jpg 73 | 75557, 39127fcc9080b9dd.jpg 74 | 19330, 39127fcd8f3cdcd8.jpg 75 | 89916, 39317e92ac04fa20.jpg 76 | 70227, 39422f2493be48f2.jpg 77 | 62851, 39612deca138415c.jpg 78 | 101612, 39802cb0bc8d2e5e.jpg 79 | 102500, 5877cb989f887e12.jpg 80 | 76937, 5896ca5c8f58dcca.jpg 81 | 19112, 5912c57691aa05ca.jpg 82 | 104590, 5919ec908088a94b.jpg 83 | 38078, 5925d86496dc51e6.jpg 84 | 36602, 5931c43a89c54b71.jpg 85 | 79218, 5938eb5494b46724.jpg 86 | 12753, 5944d72c9bd22c73.jpg 87 | 44169, 5950c300bb5791eb.jpg 88 | 82218, 5957ea1c8931063c.jpg 89 | 20040, 5963d5f0a9f6e276.jpg 90 | 91458, 5976e8e2ac51e9fd.jpg 91 | 79973, 5982d4b6b1a6d5dd.jpg 92 | 74877, 5995e7a691af18d9.jpg 93 | 40279, 6000a6a482a46348.jpg 94 | 20079, 6007cdc0af92af87.jpg 95 | 16624, 6013b994a9e52340.jpg 96 | 69818, 6026cc86a1e3493e.jpg 97 | 31823, 6032b85c942611c7.jpg 98 | 40087, 6045cb4ab52bd24e.jpg 99 | 106880, 6051b722b12b4005.jpg 100 | 71789, 6058de3aa47983dd.jpg 101 | 61669, 6077dd00bc61e885.jpg -------------------------------------------------------------------------------- /CodeCraft2019/config_0/car.txt: -------------------------------------------------------------------------------- 1 | #(id,from,to,speed,planTime) 2 | (10000, 15, 35, 6, 1) 3 | (10001, 16, 34, 6, 1) 4 | (10002, 7, 31, 4, 1) 5 | (10003, 34, 7, 4, 1) 6 | (10004, 22, 2, 2, 1) 7 | (10005, 20, 2, 2, 1) 8 | (10006, 21, 2, 6, 1) 9 | (10007, 23, 2, 2, 1) 10 | (10008, 31, 1, 6, 1) 11 | (10009, 30, 8, 6, 1) 12 | (10010, 33, 2, 2, 1) 13 | (10011, 15, 33, 2, 1) 14 | (10012, 21, 2, 6, 1) 15 | (10013, 35, 12, 2, 1) 16 | (10014, 16, 36, 2, 1) 17 | (10015, 1, 28, 2, 1) 18 | (10016, 22, 1, 2, 1) 19 | (10017, 9, 32, 6, 1) 20 | (10018, 13, 31, 4, 1) 21 | (10019, 15, 35, 2, 1) 22 | (10020, 27, 5, 6, 1) 23 | (10021, 12, 35, 4, 1) 24 | (10022, 4, 30, 2, 1) 25 | (10023, 21, 2, 6, 1) 26 | (10024, 25, 5, 6, 1) 27 | (10025, 35, 16, 4, 1) 28 | (10026, 26, 7, 2, 1) 29 | (10027, 18, 36, 2, 1) 30 | (10028, 4, 35, 6, 1) 31 | (10029, 18, 36, 4, 1) 32 | (10030, 26, 2, 4, 1) 33 | (10031, 32, 5, 6, 1) 34 | (10032, 8, 34, 2, 1) 35 | (10033, 33, 6, 4, 1) 36 | (10034, 2, 23, 4, 1) 37 | (10035, 1, 19, 6, 1) 38 | (10036, 7, 32, 6, 1) 39 | (10037, 19, 1, 4, 1) 40 | (10038, 35, 6, 4, 1) 41 | (10039, 11, 36, 2, 1) 42 | (10040, 31, 6, 2, 1) 43 | (10041, 16, 34, 4, 1) 44 | (10042, 31, 9, 4, 1) 45 | (10043, 27, 9, 2, 1) 46 | (10044, 23, 2, 4, 1) 47 | (10045, 2, 29, 4, 1) 48 | (10046, 22, 1, 2, 1) 49 | (10047, 16, 34, 4, 1) 50 | (10048, 1, 31, 4, 1) 51 | (10049, 4, 23, 2, 1) 52 | (10050, 15, 34, 6, 1) 53 | (10051, 9, 30, 2, 1) 54 | (10052, 14, 32, 6, 1) 55 | (10053, 9, 30, 2, 1) 56 | (10054, 8, 35, 6, 1) 57 | (10055, 2, 22, 2, 1) 58 | (10056, 16, 35, 2, 1) 59 | (10057, 31, 10, 6, 1) 60 | (10058, 24, 4, 2, 1) 61 | (10059, 4, 29, 2, 1) 62 | (10060, 14, 36, 4, 1) 63 | (10061, 12, 34, 4, 1) 64 | (10062, 4, 22, 6, 1) 65 | (10063, 13, 33, 2, 1) 66 | (10064, 23, 1, 2, 1) 67 | (10065, 3, 31, 4, 1) 68 | (10066, 35, 7, 4, 1) 69 | (10067, 18, 36, 6, 1) 70 | (10068, 6, 33, 2, 1) 71 | (10069, 9, 32, 6, 1) 72 | (10070, 16, 36, 2, 1) 73 | (10071, 35, 16, 2, 1) 74 | (10072, 34, 2, 6, 1) 75 | (10073, 23, 2, 4, 1) 76 | (10074, 33, 14, 4, 1) 77 | (10075, 17, 36, 2, 1) 78 | (10076, 33, 2, 4, 1) 79 | (10077, 3, 27, 6, 1) 80 | (10078, 3, 32, 2, 1) 81 | (10079, 15, 34, 2, 1) 82 | (10080, 24, 2, 4, 1) 83 | (10081, 9, 28, 4, 1) 84 | (10082, 27, 1, 6, 1) 85 | (10083, 36, 6, 4, 1) 86 | (10084, 10, 30, 6, 1) 87 | (10085, 34, 12, 6, 1) 88 | (10086, 25, 3, 4, 1) 89 | (10087, 21, 1, 6, 1) 90 | (10088, 18, 36, 4, 1) 91 | (10089, 22, 3, 2, 1) 92 | (10090, 4, 23, 4, 1) 93 | (10091, 35, 5, 6, 1) 94 | (10092, 27, 7, 2, 1) 95 | (10093, 19, 1, 4, 1) 96 | (10094, 22, 4, 2, 1) 97 | (10095, 24, 6, 4, 1) 98 | (10096, 34, 14, 4, 1) 99 | (10097, 14, 35, 2, 1) 100 | (10098, 12, 30, 6, 1) 101 | (10099, 36, 12, 6, 1) 102 | (10100, 14, 32, 6, 1) 103 | (10101, 8, 31, 6, 1) 104 | (10102, 20, 2, 2, 1) 105 | (10103, 1, 36, 4, 1) 106 | (10104, 9, 33, 4, 1) 107 | (10105, 16, 36, 6, 1) 108 | (10106, 26, 7, 2, 1) 109 | (10107, 5, 33, 4, 1) 110 | (10108, 25, 7, 6, 1) 111 | (10109, 14, 32, 2, 1) 112 | (10110, 11, 30, 6, 1) 113 | (10111, 32, 10, 6, 1) 114 | (10112, 17, 36, 4, 1) 115 | (10113, 25, 5, 2, 1) 116 | (10114, 7, 30, 6, 1) 117 | (10115, 2, 26, 2, 1) 118 | (10116, 28, 2, 6, 1) 119 | (10117, 14, 33, 6, 1) 120 | (10118, 7, 26, 4, 1) 121 | (10119, 26, 1, 6, 1) 122 | (10120, 20, 2, 2, 1) 123 | (10121, 33, 7, 2, 1) 124 | (10122, 8, 31, 6, 1) 125 | (10123, 35, 11, 2, 1) 126 | (10124, 28, 5, 6, 1) 127 | (10125, 10, 35, 4, 1) 128 | (10126, 5, 35, 2, 1) 129 | (10127, 20, 2, 6, 1) -------------------------------------------------------------------------------- /CodeCraft2019/config_0/cross.txt: -------------------------------------------------------------------------------- 1 | #(id,roadId,roadId,roadId,roadId) 2 | (1, 5000, 5005, -1, -1) 3 | (2, 5001, 5006, 5000, -1) 4 | (3, 5002, 5007, 5001, -1) 5 | (4, 5003, 5008, 5002, -1) 6 | (5, 5004, 5009, 5003, -1) 7 | (6, -1, 5010, 5004, -1) 8 | (7, 5011, 5016, -1, 5005) 9 | (8, 5012, 5017, 5011, 5006) 10 | (9, 5013, 5018, 5012, 5007) 11 | (10, 5014, 5019, 5013, 5008) 12 | (11, 5015, 5020, 5014, 5009) 13 | (12, -1, 5021, 5015, 5010) 14 | (13, 5022, 5027, -1, 5016) 15 | (14, 5023, 5028, 5022, 5017) 16 | (15, 5024, 5029, 5023, 5018) 17 | (16, 5025, 5030, 5024, 5019) 18 | (17, 5026, 5031, 5025, 5020) 19 | (18, -1, 5032, 5026, 5021) 20 | (19, 5033, 5038, -1, 5027) 21 | (20, 5034, 5039, 5033, 5028) 22 | (21, 5035, 5040, 5034, 5029) 23 | (22, 5036, 5041, 5035, 5030) 24 | (23, 5037, 5042, 5036, 5031) 25 | (24, -1, 5043, 5037, 5032) 26 | (25, 5044, 5049, -1, 5038) 27 | (26, 5045, 5050, 5044, 5039) 28 | (27, 5046, 5051, 5045, 5040) 29 | (28, 5047, 5052, 5046, 5041) 30 | (29, 5048, 5053, 5047, 5042) 31 | (30, -1, 5054, 5048, 5043) 32 | (31, 5055, -1, -1, 5049) 33 | (32, 5056, -1, 5055, 5050) 34 | (33, 5057, -1, 5056, 5051) 35 | (34, 5058, -1, 5057, 5052) 36 | (35, 5059, -1, 5058, 5053) 37 | (36, -1, -1, 5059, 5054) -------------------------------------------------------------------------------- /CodeCraft2019/config_0/road.txt: -------------------------------------------------------------------------------- 1 | #(id,length,speed,channel,from,to,isDuplex) 2 | (5000, 10, 5, 1, 1, 2, 1) 3 | (5001, 10, 5, 1, 2, 3, 1) 4 | (5002, 10, 5, 1, 3, 4, 1) 5 | (5003, 10, 5, 1, 4, 5, 1) 6 | (5004, 10, 5, 1, 5, 6, 1) 7 | (5005, 10, 5, 1, 1, 7, 1) 8 | (5006, 10, 5, 1, 2, 8, 1) 9 | (5007, 10, 5, 1, 3, 9, 1) 10 | (5008, 10, 5, 1, 4, 10, 1) 11 | (5009, 10, 5, 1, 5, 11, 1) 12 | (5010, 10, 5, 1, 6, 12, 1) 13 | (5011, 10, 5, 1, 7, 8, 1) 14 | (5012, 10, 5, 1, 8, 9, 1) 15 | (5013, 10, 5, 1, 9, 10, 1) 16 | (5014, 10, 5, 1, 10, 11, 1) 17 | (5015, 10, 5, 1, 11, 12, 1) 18 | (5016, 10, 5, 1, 7, 13, 1) 19 | (5017, 10, 5, 1, 8, 14, 1) 20 | (5018, 10, 5, 1, 9, 15, 1) 21 | (5019, 10, 5, 1, 10, 16, 1) 22 | (5020, 10, 5, 1, 11, 17, 1) 23 | (5021, 10, 5, 1, 12, 18, 1) 24 | (5022, 10, 5, 1, 13, 14, 1) 25 | (5023, 10, 5, 1, 14, 15, 1) 26 | (5024, 10, 5, 1, 15, 16, 1) 27 | (5025, 10, 5, 1, 16, 17, 1) 28 | (5026, 10, 5, 1, 17, 18, 1) 29 | (5027, 10, 5, 1, 13, 19, 1) 30 | (5028, 10, 5, 1, 14, 20, 1) 31 | (5029, 10, 5, 1, 15, 21, 1) 32 | (5030, 10, 5, 1, 16, 22, 1) 33 | (5031, 10, 5, 1, 17, 23, 1) 34 | (5032, 10, 5, 1, 18, 24, 1) 35 | (5033, 10, 5, 1, 19, 20, 1) 36 | (5034, 10, 5, 1, 20, 21, 1) 37 | (5035, 10, 5, 1, 21, 22, 1) 38 | (5036, 10, 5, 1, 22, 23, 1) 39 | (5037, 10, 5, 1, 23, 24, 1) 40 | (5038, 10, 5, 1, 19, 25, 1) 41 | (5039, 10, 5, 1, 20, 26, 1) 42 | (5040, 10, 5, 1, 21, 27, 1) 43 | (5041, 10, 5, 1, 22, 28, 1) 44 | (5042, 10, 5, 1, 23, 29, 1) 45 | (5043, 10, 5, 1, 24, 30, 1) 46 | (5044, 10, 5, 1, 25, 26, 1) 47 | (5045, 10, 5, 1, 26, 27, 1) 48 | (5046, 10, 5, 1, 27, 28, 1) 49 | (5047, 10, 5, 1, 28, 29, 1) 50 | (5048, 10, 5, 1, 29, 30, 1) 51 | (5049, 10, 5, 1, 25, 31, 1) 52 | (5050, 10, 5, 1, 26, 32, 1) 53 | (5051, 10, 5, 1, 27, 33, 1) 54 | (5052, 10, 5, 1, 28, 34, 1) 55 | (5053, 10, 5, 1, 29, 35, 1) 56 | (5054, 10, 5, 1, 30, 36, 1) 57 | (5055, 10, 5, 1, 31, 32, 1) 58 | (5056, 10, 5, 1, 32, 33, 1) 59 | (5057, 10, 5, 1, 33, 34, 1) 60 | (5058, 10, 5, 1, 34, 35, 1) 61 | (5059, 10, 5, 1, 35, 36, 1) -------------------------------------------------------------------------------- /CodeCraft2019/config_1/car.txt: -------------------------------------------------------------------------------- 1 | #(id,from,to,speed,planTime) 2 | (10000, 15, 35, 6, 1) 3 | (10001, 16, 34, 6, 1) 4 | (10002, 7, 31, 4, 1) 5 | (10003, 34, 7, 4, 1) 6 | (10004, 22, 2, 2, 1) 7 | (10005, 20, 2, 2, 1) 8 | (10006, 21, 2, 6, 1) 9 | (10007, 23, 2, 2, 1) 10 | (10008, 31, 1, 6, 1) 11 | (10009, 30, 8, 6, 1) 12 | (10010, 33, 2, 2, 1) 13 | (10011, 15, 33, 2, 1) 14 | (10012, 21, 2, 6, 1) 15 | (10013, 35, 12, 2, 1) 16 | (10014, 16, 36, 2, 1) 17 | (10015, 1, 28, 2, 1) 18 | (10016, 22, 1, 2, 1) 19 | (10017, 9, 32, 6, 1) 20 | (10018, 13, 31, 4, 1) 21 | (10019, 15, 35, 2, 1) 22 | (10020, 27, 5, 6, 1) 23 | (10021, 12, 35, 4, 1) 24 | (10022, 4, 30, 2, 1) 25 | (10023, 21, 2, 6, 1) 26 | (10024, 25, 5, 6, 1) 27 | (10025, 35, 16, 4, 1) 28 | (10026, 26, 7, 2, 1) 29 | (10027, 18, 36, 2, 1) 30 | (10028, 4, 35, 6, 1) 31 | (10029, 18, 36, 4, 1) 32 | (10030, 26, 2, 4, 1) 33 | (10031, 32, 5, 6, 1) 34 | (10032, 8, 34, 2, 1) 35 | (10033, 33, 6, 4, 1) 36 | (10034, 2, 23, 4, 1) 37 | (10035, 1, 19, 6, 1) 38 | (10036, 7, 32, 6, 1) 39 | (10037, 19, 1, 4, 1) 40 | (10038, 35, 6, 4, 1) 41 | (10039, 11, 36, 2, 1) 42 | (10040, 31, 6, 2, 1) 43 | (10041, 16, 34, 4, 1) 44 | (10042, 31, 9, 4, 1) 45 | (10043, 27, 9, 2, 1) 46 | (10044, 23, 2, 4, 1) 47 | (10045, 2, 29, 4, 1) 48 | (10046, 22, 1, 2, 1) 49 | (10047, 16, 34, 4, 1) 50 | (10048, 1, 31, 4, 1) 51 | (10049, 4, 23, 2, 1) 52 | (10050, 15, 34, 6, 1) 53 | (10051, 9, 30, 2, 1) 54 | (10052, 14, 32, 6, 1) 55 | (10053, 9, 30, 2, 1) 56 | (10054, 8, 35, 6, 1) 57 | (10055, 2, 22, 2, 1) 58 | (10056, 16, 35, 2, 1) 59 | (10057, 31, 10, 6, 1) 60 | (10058, 24, 4, 2, 1) 61 | (10059, 4, 29, 2, 1) 62 | (10060, 14, 36, 4, 1) 63 | (10061, 12, 34, 4, 1) 64 | (10062, 4, 22, 6, 1) 65 | (10063, 13, 33, 2, 1) 66 | (10064, 23, 1, 2, 1) 67 | (10065, 3, 31, 4, 1) 68 | (10066, 35, 7, 4, 1) 69 | (10067, 18, 36, 6, 1) 70 | (10068, 6, 33, 2, 1) 71 | (10069, 9, 32, 6, 1) 72 | (10070, 16, 36, 2, 1) 73 | (10071, 35, 16, 2, 1) 74 | (10072, 34, 2, 6, 1) 75 | (10073, 23, 2, 4, 1) 76 | (10074, 33, 14, 4, 1) 77 | (10075, 17, 36, 2, 1) 78 | (10076, 33, 2, 4, 1) 79 | (10077, 3, 27, 6, 1) 80 | (10078, 3, 32, 2, 1) 81 | (10079, 15, 34, 2, 1) 82 | (10080, 24, 2, 4, 1) 83 | (10081, 9, 28, 4, 1) 84 | (10082, 27, 1, 6, 1) 85 | (10083, 36, 6, 4, 1) 86 | (10084, 10, 30, 6, 1) 87 | (10085, 34, 12, 6, 1) 88 | (10086, 25, 3, 4, 1) 89 | (10087, 21, 1, 6, 1) 90 | (10088, 18, 36, 4, 1) 91 | (10089, 22, 3, 2, 1) 92 | (10090, 4, 23, 4, 1) 93 | (10091, 35, 5, 6, 1) 94 | (10092, 27, 7, 2, 1) 95 | (10093, 19, 1, 4, 1) 96 | (10094, 22, 4, 2, 1) 97 | (10095, 24, 6, 4, 1) 98 | (10096, 34, 14, 4, 1) 99 | (10097, 14, 35, 2, 1) 100 | (10098, 12, 30, 6, 1) 101 | (10099, 36, 12, 6, 1) 102 | (10100, 14, 32, 6, 1) 103 | (10101, 8, 31, 6, 1) 104 | (10102, 20, 2, 2, 1) 105 | (10103, 1, 36, 4, 1) 106 | (10104, 9, 33, 4, 1) 107 | (10105, 16, 36, 6, 1) 108 | (10106, 26, 7, 2, 1) 109 | (10107, 5, 33, 4, 1) 110 | (10108, 25, 7, 6, 1) 111 | (10109, 14, 32, 2, 1) 112 | (10110, 11, 30, 6, 1) 113 | (10111, 32, 10, 6, 1) 114 | (10112, 17, 36, 4, 1) 115 | (10113, 25, 5, 2, 1) 116 | (10114, 7, 30, 6, 1) 117 | (10115, 2, 26, 2, 1) 118 | (10116, 28, 2, 6, 1) 119 | (10117, 14, 33, 6, 1) 120 | (10118, 7, 26, 4, 1) 121 | (10119, 26, 1, 6, 1) 122 | (10120, 20, 2, 2, 1) 123 | (10121, 33, 7, 2, 1) 124 | (10122, 8, 31, 6, 1) 125 | (10123, 35, 11, 2, 1) 126 | (10124, 28, 5, 6, 1) 127 | (10125, 10, 35, 4, 1) 128 | (10126, 5, 35, 2, 1) 129 | (10127, 20, 2, 6, 1) -------------------------------------------------------------------------------- /CodeCraft2019/config_1/cross.txt: -------------------------------------------------------------------------------- 1 | #(id,roadId,roadId,roadId,roadId) 2 | (1, 5000, 5005, -1, -1) 3 | (2, 5001, 5006, 5000, -1) 4 | (3, 5002, 5007, 5001, -1) 5 | (4, 5003, 5008, 5002, -1) 6 | (5, 5004, 5009, 5003, -1) 7 | (6, -1, 5010, 5004, -1) 8 | (7, 5011, 5016, -1, 5005) 9 | (8, 5012, 5017, 5011, 5006) 10 | (9, 5013, 5018, 5012, 5007) 11 | (10, 5014, 5019, 5013, 5008) 12 | (11, 5015, 5020, 5014, 5009) 13 | (12, -1, 5021, 5015, 5010) 14 | (13, 5022, 5027, -1, 5016) 15 | (14, 5023, 5028, 5022, 5017) 16 | (15, 5024, 5029, 5023, 5018) 17 | (16, 5025, 5030, 5024, 5019) 18 | (17, 5026, 5031, 5025, 5020) 19 | (18, -1, 5032, 5026, 5021) 20 | (19, 5033, 5038, -1, 5027) 21 | (20, 5034, 5039, 5033, 5028) 22 | (21, 5035, 5040, 5034, 5029) 23 | (22, 5036, 5041, 5035, 5030) 24 | (23, 5037, 5042, 5036, 5031) 25 | (24, -1, 5043, 5037, 5032) 26 | (25, 5044, 5049, -1, 5038) 27 | (26, 5045, 5050, 5044, 5039) 28 | (27, 5046, 5051, 5045, 5040) 29 | (28, 5047, 5052, 5046, 5041) 30 | (29, 5048, 5053, 5047, 5042) 31 | (30, -1, 5054, 5048, 5043) 32 | (31, 5055, -1, -1, 5049) 33 | (32, 5056, -1, 5055, 5050) 34 | (33, 5057, -1, 5056, 5051) 35 | (34, 5058, -1, 5057, 5052) 36 | (35, 5059, -1, 5058, 5053) 37 | (36, -1, -1, 5059, 5054) -------------------------------------------------------------------------------- /CodeCraft2019/config_1/road.txt: -------------------------------------------------------------------------------- 1 | #(id,length,speed,channel,from,to,isDuplex) 2 | (5000, 10, 5, 1, 1, 2, 1) 3 | (5001, 10, 5, 1, 2, 3, 1) 4 | (5002, 10, 5, 1, 3, 4, 1) 5 | (5003, 10, 5, 1, 4, 5, 1) 6 | (5004, 10, 5, 1, 5, 6, 1) 7 | (5005, 10, 5, 1, 1, 7, 1) 8 | (5006, 10, 5, 1, 2, 8, 1) 9 | (5007, 10, 5, 1, 3, 9, 1) 10 | (5008, 10, 5, 1, 4, 10, 1) 11 | (5009, 10, 5, 1, 5, 11, 1) 12 | (5010, 10, 5, 1, 6, 12, 1) 13 | (5011, 10, 5, 1, 7, 8, 1) 14 | (5012, 10, 5, 1, 8, 9, 1) 15 | (5013, 10, 5, 1, 9, 10, 1) 16 | (5014, 10, 5, 1, 10, 11, 1) 17 | (5015, 10, 5, 1, 11, 12, 1) 18 | (5016, 10, 5, 1, 7, 13, 1) 19 | (5017, 10, 5, 1, 8, 14, 1) 20 | (5018, 10, 5, 1, 9, 15, 1) 21 | (5019, 10, 5, 1, 10, 16, 1) 22 | (5020, 10, 5, 1, 11, 17, 1) 23 | (5021, 10, 5, 1, 12, 18, 1) 24 | (5022, 10, 5, 1, 13, 14, 1) 25 | (5023, 10, 5, 1, 14, 15, 1) 26 | (5024, 10, 5, 1, 15, 16, 1) 27 | (5025, 10, 5, 1, 16, 17, 1) 28 | (5026, 10, 5, 1, 17, 18, 1) 29 | (5027, 10, 5, 1, 13, 19, 1) 30 | (5028, 10, 5, 1, 14, 20, 1) 31 | (5029, 10, 5, 1, 15, 21, 1) 32 | (5030, 10, 5, 1, 16, 22, 1) 33 | (5031, 10, 5, 1, 17, 23, 1) 34 | (5032, 10, 5, 1, 18, 24, 1) 35 | (5033, 10, 5, 1, 19, 20, 1) 36 | (5034, 10, 5, 1, 20, 21, 1) 37 | (5035, 10, 5, 1, 21, 22, 1) 38 | (5036, 10, 5, 1, 22, 23, 1) 39 | (5037, 10, 5, 1, 23, 24, 1) 40 | (5038, 10, 5, 1, 19, 25, 1) 41 | (5039, 10, 5, 1, 20, 26, 1) 42 | (5040, 10, 5, 1, 21, 27, 1) 43 | (5041, 10, 5, 1, 22, 28, 1) 44 | (5042, 10, 5, 1, 23, 29, 1) 45 | (5043, 10, 5, 1, 24, 30, 1) 46 | (5044, 10, 5, 1, 25, 26, 1) 47 | (5045, 10, 5, 1, 26, 27, 1) 48 | (5046, 10, 5, 1, 27, 28, 1) 49 | (5047, 10, 5, 1, 28, 29, 1) 50 | (5048, 10, 5, 1, 29, 30, 1) 51 | (5049, 10, 5, 1, 25, 31, 1) 52 | (5050, 10, 5, 1, 26, 32, 1) 53 | (5051, 10, 5, 1, 27, 33, 1) 54 | (5052, 10, 5, 1, 28, 34, 1) 55 | (5053, 10, 5, 1, 29, 35, 1) 56 | (5054, 10, 5, 1, 30, 36, 1) 57 | (5055, 10, 5, 1, 31, 32, 1) 58 | (5056, 10, 5, 1, 32, 33, 1) 59 | (5057, 10, 5, 1, 33, 34, 1) 60 | (5058, 10, 5, 1, 34, 35, 1) 61 | (5059, 10, 5, 1, 35, 36, 1) -------------------------------------------------------------------------------- /CodeCraft2019/config_10/cross.txt: -------------------------------------------------------------------------------- 1 | #(id,roadId,roadId,roadId,roadId) 2 | (1, 5000, 5005, -1, -1) 3 | (2, 5001, 5006, 5000, -1) 4 | (3, 5002, 5007, 5001, -1) 5 | (4, 5003, 5008, 5002, -1) 6 | (5, 5004, 5009, 5003, -1) 7 | (6, -1, 5010, 5004, -1) 8 | (7, 5011, 5016, -1, 5005) 9 | (8, 5012, 5017, 5011, 5006) 10 | (9, 5013, 5018, 5012, 5007) 11 | (10, 5014, 5019, 5013, 5008) 12 | (11, 5015, 5020, 5014, 5009) 13 | (12, -1, 5021, 5015, 5010) 14 | (13, 5022, 5026, -1, 5016) 15 | (14, -1, 5027, 5022, 5017) 16 | (15, 5023, 5028, -1, 5018) 17 | (16, 5024, 5029, 5023, 5019) 18 | (17, 5025, 5030, 5024, 5020) 19 | (18, -1, 5031, 5025, 5021) 20 | (19, 5032, 5037, -1, 5026) 21 | (20, 5033, 5038, 5032, 5027) 22 | (21, 5034, 5039, 5033, 5028) 23 | (22, 5035, 5040, 5034, 5029) 24 | (23, 5036, 5041, 5035, 5030) 25 | (24, -1, 5042, 5036, 5031) 26 | (25, 5043, 5047, -1, 5037) 27 | (26, -1, 5048, 5043, 5038) 28 | (27, 5044, 5049, -1, 5039) 29 | (28, 5045, 5050, 5044, 5040) 30 | (29, 5046, 5051, 5045, 5041) 31 | (30, -1, 5052, 5046, 5042) 32 | (31, 5053, -1, -1, 5047) 33 | (32, 5054, -1, 5053, 5048) 34 | (33, 5055, -1, 5054, 5049) 35 | (34, 5056, -1, 5055, 5050) 36 | (35, 5057, -1, 5056, 5051) 37 | (36, -1, -1, 5057, 5052) -------------------------------------------------------------------------------- /CodeCraft2019/config_10/road.txt: -------------------------------------------------------------------------------- 1 | #(id,length,speed,channel,from,to,isDuplex) 2 | (5000, 20, 6, 2, 1, 2, 1) 3 | (5001, 20, 4, 2, 2, 3, 1) 4 | (5002, 10, 8, 2, 3, 4, 1) 5 | (5003, 20, 4, 1, 4, 5, 1) 6 | (5004, 20, 6, 2, 5, 6, 1) 7 | (5005, 15, 6, 3, 1, 7, 1) 8 | (5006, 10, 6, 1, 2, 8, 1) 9 | (5007, 10, 6, 3, 3, 9, 1) 10 | (5008, 20, 8, 2, 4, 10, 1) 11 | (5009, 15, 8, 1, 5, 11, 1) 12 | (5010, 20, 8, 2, 6, 12, 1) 13 | (5011, 20, 4, 2, 7, 8, 1) 14 | (5012, 10, 8, 3, 8, 9, 1) 15 | (5013, 20, 4, 2, 9, 10, 0) 16 | (5014, 15, 6, 1, 10, 11, 1) 17 | (5015, 20, 8, 1, 11, 12, 1) 18 | (5016, 20, 6, 1, 7, 13, 1) 19 | (5017, 15, 6, 3, 8, 14, 1) 20 | (5018, 20, 8, 3, 9, 15, 1) 21 | (5019, 20, 6, 2, 10, 16, 1) 22 | (5020, 20, 6, 3, 11, 17, 0) 23 | (5021, 15, 8, 3, 12, 18, 1) 24 | (5022, 10, 4, 2, 13, 14, 1) 25 | (5023, 10, 4, 1, 15, 16, 1) 26 | (5024, 10, 4, 2, 16, 17, 1) 27 | (5025, 20, 4, 3, 17, 18, 1) 28 | (5026, 15, 6, 2, 13, 19, 1) 29 | (5027, 10, 4, 2, 14, 20, 1) 30 | (5028, 10, 4, 3, 15, 21, 1) 31 | (5029, 15, 8, 2, 16, 22, 1) 32 | (5030, 15, 4, 1, 17, 23, 1) 33 | (5031, 20, 4, 1, 18, 24, 1) 34 | (5032, 15, 6, 3, 19, 20, 1) 35 | (5033, 20, 8, 3, 20, 21, 1) 36 | (5034, 15, 6, 2, 21, 22, 0) 37 | (5035, 15, 8, 2, 22, 23, 1) 38 | (5036, 10, 6, 2, 23, 24, 1) 39 | (5037, 10, 6, 2, 19, 25, 1) 40 | (5038, 20, 8, 1, 20, 26, 1) 41 | (5039, 10, 4, 3, 21, 27, 1) 42 | (5040, 15, 4, 2, 22, 28, 1) 43 | (5041, 20, 8, 1, 23, 29, 1) 44 | (5042, 10, 8, 2, 24, 30, 1) 45 | (5043, 15, 8, 3, 25, 26, 1) 46 | (5044, 10, 8, 2, 27, 28, 1) 47 | (5045, 20, 4, 2, 28, 29, 1) 48 | (5046, 10, 6, 1, 29, 30, 1) 49 | (5047, 15, 4, 3, 25, 31, 1) 50 | (5048, 15, 8, 1, 26, 32, 1) 51 | (5049, 15, 8, 3, 27, 33, 1) 52 | (5050, 10, 4, 2, 28, 34, 1) 53 | (5051, 10, 6, 3, 29, 35, 1) 54 | (5052, 20, 4, 1, 30, 36, 1) 55 | (5053, 10, 8, 1, 31, 32, 1) 56 | (5054, 20, 6, 3, 32, 33, 1) 57 | (5055, 20, 6, 3, 33, 34, 1) 58 | (5056, 20, 8, 1, 34, 35, 1) 59 | (5057, 20, 8, 3, 35, 36, 1) -------------------------------------------------------------------------------- /CodeCraft2019/config_2/cross.txt: -------------------------------------------------------------------------------- 1 | #(id,roadId,roadId,roadId,roadId) 2 | (1, 5000, 5005, -1, -1) 3 | (2, 5001, 5006, 5000, -1) 4 | (3, 5002, 5007, 5001, -1) 5 | (4, 5003, 5008, 5002, -1) 6 | (5, 5004, 5009, 5003, -1) 7 | (6, -1, 5010, 5004, -1) 8 | (7, 5011, 5016, -1, 5005) 9 | (8, 5012, 5017, 5011, 5006) 10 | (9, 5013, 5018, 5012, 5007) 11 | (10, 5014, 5019, 5013, 5008) 12 | (11, 5015, 5020, 5014, 5009) 13 | (12, -1, 5021, 5015, 5010) 14 | (13, 5022, 5027, -1, 5016) 15 | (14, 5023, 5028, 5022, 5017) 16 | (15, 5024, 5029, 5023, 5018) 17 | (16, 5025, 5030, 5024, 5019) 18 | (17, 5026, 5031, 5025, 5020) 19 | (18, -1, 5032, 5026, 5021) 20 | (19, 5033, 5038, -1, 5027) 21 | (20, 5034, 5039, 5033, 5028) 22 | (21, 5035, 5040, 5034, 5029) 23 | (22, 5036, 5041, 5035, 5030) 24 | (23, 5037, 5042, 5036, 5031) 25 | (24, -1, 5043, 5037, 5032) 26 | (25, 5044, 5049, -1, 5038) 27 | (26, 5045, 5050, 5044, 5039) 28 | (27, 5046, 5051, 5045, 5040) 29 | (28, 5047, 5052, 5046, 5041) 30 | (29, 5048, 5053, 5047, 5042) 31 | (30, -1, 5054, 5048, 5043) 32 | (31, 5055, -1, -1, 5049) 33 | (32, 5056, -1, 5055, 5050) 34 | (33, 5057, -1, 5056, 5051) 35 | (34, 5058, -1, 5057, 5052) 36 | (35, 5059, -1, 5058, 5053) 37 | (36, -1, -1, 5059, 5054) -------------------------------------------------------------------------------- /CodeCraft2019/config_2/road.txt: -------------------------------------------------------------------------------- 1 | #(id,length,speed,channel,from,to,isDuplex) 2 | (5000, 10, 5, 1, 1, 2, 1) 3 | (5001, 10, 5, 1, 2, 3, 1) 4 | (5002, 10, 5, 1, 3, 4, 1) 5 | (5003, 10, 5, 1, 4, 5, 1) 6 | (5004, 10, 5, 1, 5, 6, 1) 7 | (5005, 10, 5, 1, 1, 7, 1) 8 | (5006, 10, 5, 1, 2, 8, 1) 9 | (5007, 10, 5, 1, 3, 9, 1) 10 | (5008, 10, 5, 1, 4, 10, 1) 11 | (5009, 10, 5, 1, 5, 11, 1) 12 | (5010, 10, 5, 1, 6, 12, 1) 13 | (5011, 10, 5, 1, 7, 8, 1) 14 | (5012, 10, 5, 1, 8, 9, 1) 15 | (5013, 10, 5, 1, 9, 10, 1) 16 | (5014, 10, 5, 1, 10, 11, 1) 17 | (5015, 10, 5, 1, 11, 12, 1) 18 | (5016, 10, 5, 1, 7, 13, 1) 19 | (5017, 10, 5, 1, 8, 14, 1) 20 | (5018, 10, 5, 1, 9, 15, 1) 21 | (5019, 10, 5, 1, 10, 16, 1) 22 | (5020, 10, 5, 1, 11, 17, 1) 23 | (5021, 10, 5, 1, 12, 18, 1) 24 | (5022, 10, 5, 1, 13, 14, 1) 25 | (5023, 10, 5, 1, 14, 15, 1) 26 | (5024, 10, 5, 1, 15, 16, 1) 27 | (5025, 10, 5, 1, 16, 17, 1) 28 | (5026, 10, 5, 1, 17, 18, 1) 29 | (5027, 10, 5, 1, 13, 19, 1) 30 | (5028, 10, 5, 1, 14, 20, 1) 31 | (5029, 10, 5, 1, 15, 21, 1) 32 | (5030, 10, 5, 1, 16, 22, 1) 33 | (5031, 10, 5, 1, 17, 23, 1) 34 | (5032, 10, 5, 1, 18, 24, 1) 35 | (5033, 10, 5, 1, 19, 20, 1) 36 | (5034, 10, 5, 1, 20, 21, 1) 37 | (5035, 10, 5, 1, 21, 22, 1) 38 | (5036, 10, 5, 1, 22, 23, 1) 39 | (5037, 10, 5, 1, 23, 24, 1) 40 | (5038, 10, 5, 1, 19, 25, 1) 41 | (5039, 10, 5, 1, 20, 26, 1) 42 | (5040, 10, 5, 1, 21, 27, 1) 43 | (5041, 10, 5, 1, 22, 28, 1) 44 | (5042, 10, 5, 1, 23, 29, 1) 45 | (5043, 10, 5, 1, 24, 30, 1) 46 | (5044, 10, 5, 1, 25, 26, 1) 47 | (5045, 10, 5, 1, 26, 27, 1) 48 | (5046, 10, 5, 1, 27, 28, 1) 49 | (5047, 10, 5, 1, 28, 29, 1) 50 | (5048, 10, 5, 1, 29, 30, 1) 51 | (5049, 10, 5, 1, 25, 31, 1) 52 | (5050, 10, 5, 1, 26, 32, 1) 53 | (5051, 10, 5, 1, 27, 33, 1) 54 | (5052, 10, 5, 1, 28, 34, 1) 55 | (5053, 10, 5, 1, 29, 35, 1) 56 | (5054, 10, 5, 1, 30, 36, 1) 57 | (5055, 10, 5, 1, 31, 32, 1) 58 | (5056, 10, 5, 1, 32, 33, 1) 59 | (5057, 10, 5, 1, 33, 34, 1) 60 | (5058, 10, 5, 1, 34, 35, 1) 61 | (5059, 10, 5, 1, 35, 36, 1) -------------------------------------------------------------------------------- /CodeCraft2019/config_3/cross.txt: -------------------------------------------------------------------------------- 1 | #(id,roadId,roadId,roadId,roadId) 2 | (1, 5000, 5005, -1, -1) 3 | (2, 5001, 5006, 5000, -1) 4 | (3, 5002, 5007, 5001, -1) 5 | (4, 5003, 5008, 5002, -1) 6 | (5, 5004, 5009, 5003, -1) 7 | (6, -1, 5010, 5004, -1) 8 | (7, 5011, 5016, -1, 5005) 9 | (8, 5012, 5017, 5011, 5006) 10 | (9, 5013, 5018, 5012, 5007) 11 | (10, 5014, 5019, 5013, 5008) 12 | (11, 5015, 5020, 5014, 5009) 13 | (12, -1, 5021, 5015, 5010) 14 | (13, 5022, 5027, -1, 5016) 15 | (14, 5023, 5028, 5022, 5017) 16 | (15, 5024, 5029, 5023, 5018) 17 | (16, 5025, 5030, 5024, 5019) 18 | (17, 5026, 5031, 5025, 5020) 19 | (18, -1, 5032, 5026, 5021) 20 | (19, 5033, 5038, -1, 5027) 21 | (20, 5034, 5039, 5033, 5028) 22 | (21, 5035, 5040, 5034, 5029) 23 | (22, 5036, 5041, 5035, 5030) 24 | (23, 5037, 5042, 5036, 5031) 25 | (24, -1, 5043, 5037, 5032) 26 | (25, 5044, 5049, -1, 5038) 27 | (26, 5045, 5050, 5044, 5039) 28 | (27, 5046, 5051, 5045, 5040) 29 | (28, 5047, 5052, 5046, 5041) 30 | (29, 5048, 5053, 5047, 5042) 31 | (30, -1, 5054, 5048, 5043) 32 | (31, 5055, -1, -1, 5049) 33 | (32, 5056, -1, 5055, 5050) 34 | (33, 5057, -1, 5056, 5051) 35 | (34, 5058, -1, 5057, 5052) 36 | (35, 5059, -1, 5058, 5053) 37 | (36, -1, -1, 5059, 5054) -------------------------------------------------------------------------------- /CodeCraft2019/config_3/road.txt: -------------------------------------------------------------------------------- 1 | #(id,length,speed,channel,from,to,isDuplex) 2 | (5000, 10, 5, 1, 1, 2, 1) 3 | (5001, 20, 5, 1, 2, 3, 1) 4 | (5002, 20, 5, 1, 3, 4, 1) 5 | (5003, 20, 5, 1, 4, 5, 1) 6 | (5004, 20, 5, 1, 5, 6, 1) 7 | (5005, 20, 5, 1, 1, 7, 1) 8 | (5006, 10, 5, 1, 2, 8, 1) 9 | (5007, 10, 5, 1, 3, 9, 1) 10 | (5008, 20, 5, 1, 4, 10, 1) 11 | (5009, 20, 5, 1, 5, 11, 1) 12 | (5010, 20, 5, 1, 6, 12, 1) 13 | (5011, 20, 5, 1, 7, 8, 1) 14 | (5012, 10, 5, 1, 8, 9, 1) 15 | (5013, 10, 5, 1, 9, 10, 1) 16 | (5014, 20, 5, 1, 10, 11, 1) 17 | (5015, 10, 5, 1, 11, 12, 1) 18 | (5016, 10, 5, 1, 7, 13, 1) 19 | (5017, 10, 5, 1, 8, 14, 1) 20 | (5018, 10, 5, 1, 9, 15, 1) 21 | (5019, 10, 5, 1, 10, 16, 1) 22 | (5020, 20, 5, 1, 11, 17, 1) 23 | (5021, 10, 5, 1, 12, 18, 1) 24 | (5022, 10, 5, 1, 13, 14, 1) 25 | (5023, 10, 5, 1, 14, 15, 1) 26 | (5024, 20, 5, 1, 15, 16, 1) 27 | (5025, 20, 5, 1, 16, 17, 1) 28 | (5026, 20, 5, 1, 17, 18, 1) 29 | (5027, 10, 5, 1, 13, 19, 1) 30 | (5028, 10, 5, 1, 14, 20, 1) 31 | (5029, 20, 5, 1, 15, 21, 1) 32 | (5030, 10, 5, 1, 16, 22, 1) 33 | (5031, 10, 5, 1, 17, 23, 1) 34 | (5032, 10, 5, 1, 18, 24, 1) 35 | (5033, 20, 5, 1, 19, 20, 1) 36 | (5034, 10, 5, 1, 20, 21, 1) 37 | (5035, 10, 5, 1, 21, 22, 1) 38 | (5036, 10, 5, 1, 22, 23, 1) 39 | (5037, 20, 5, 1, 23, 24, 1) 40 | (5038, 20, 5, 1, 19, 25, 1) 41 | (5039, 10, 5, 1, 20, 26, 1) 42 | (5040, 10, 5, 1, 21, 27, 1) 43 | (5041, 10, 5, 1, 22, 28, 1) 44 | (5042, 10, 5, 1, 23, 29, 1) 45 | (5043, 20, 5, 1, 24, 30, 1) 46 | (5044, 10, 5, 1, 25, 26, 1) 47 | (5045, 20, 5, 1, 26, 27, 1) 48 | (5046, 10, 5, 1, 27, 28, 1) 49 | (5047, 10, 5, 1, 28, 29, 1) 50 | (5048, 10, 5, 1, 29, 30, 1) 51 | (5049, 20, 5, 1, 25, 31, 1) 52 | (5050, 10, 5, 1, 26, 32, 1) 53 | (5051, 20, 5, 1, 27, 33, 1) 54 | (5052, 10, 5, 1, 28, 34, 1) 55 | (5053, 20, 5, 1, 29, 35, 1) 56 | (5054, 10, 5, 1, 30, 36, 1) 57 | (5055, 20, 5, 1, 31, 32, 1) 58 | (5056, 10, 5, 1, 32, 33, 1) 59 | (5057, 10, 5, 1, 33, 34, 1) 60 | (5058, 20, 5, 1, 34, 35, 1) 61 | (5059, 10, 5, 1, 35, 36, 1) -------------------------------------------------------------------------------- /CodeCraft2019/config_4/cross.txt: -------------------------------------------------------------------------------- 1 | #(id,roadId,roadId,roadId,roadId) 2 | (1, 5000, 5005, -1, -1) 3 | (2, 5001, 5006, 5000, -1) 4 | (3, 5002, 5007, 5001, -1) 5 | (4, 5003, 5008, 5002, -1) 6 | (5, 5004, 5009, 5003, -1) 7 | (6, -1, 5010, 5004, -1) 8 | (7, 5011, 5016, -1, 5005) 9 | (8, 5012, 5017, 5011, 5006) 10 | (9, 5013, 5018, 5012, 5007) 11 | (10, 5014, 5019, 5013, 5008) 12 | (11, 5015, 5020, 5014, 5009) 13 | (12, -1, 5021, 5015, 5010) 14 | (13, 5022, 5027, -1, 5016) 15 | (14, 5023, 5028, 5022, 5017) 16 | (15, 5024, 5029, 5023, 5018) 17 | (16, 5025, 5030, 5024, 5019) 18 | (17, 5026, 5031, 5025, 5020) 19 | (18, -1, 5032, 5026, 5021) 20 | (19, 5033, 5038, -1, 5027) 21 | (20, 5034, 5039, 5033, 5028) 22 | (21, 5035, 5040, 5034, 5029) 23 | (22, 5036, 5041, 5035, 5030) 24 | (23, 5037, 5042, 5036, 5031) 25 | (24, -1, 5043, 5037, 5032) 26 | (25, 5044, 5049, -1, 5038) 27 | (26, 5045, 5050, 5044, 5039) 28 | (27, 5046, 5051, 5045, 5040) 29 | (28, 5047, 5052, 5046, 5041) 30 | (29, 5048, 5053, 5047, 5042) 31 | (30, -1, 5054, 5048, 5043) 32 | (31, 5055, -1, -1, 5049) 33 | (32, 5056, -1, 5055, 5050) 34 | (33, 5057, -1, 5056, 5051) 35 | (34, 5058, -1, 5057, 5052) 36 | (35, 5059, -1, 5058, 5053) 37 | (36, -1, -1, 5059, 5054) -------------------------------------------------------------------------------- /CodeCraft2019/config_4/road.txt: -------------------------------------------------------------------------------- 1 | #(id,length,speed,channel,from,to,isDuplex) 2 | (5000, 10, 5, 1, 1, 2, 1) 3 | (5001, 20, 5, 1, 2, 3, 1) 4 | (5002, 10, 5, 1, 3, 4, 1) 5 | (5003, 20, 5, 1, 4, 5, 1) 6 | (5004, 20, 5, 1, 5, 6, 1) 7 | (5005, 10, 5, 1, 1, 7, 1) 8 | (5006, 20, 5, 1, 2, 8, 1) 9 | (5007, 10, 5, 1, 3, 9, 1) 10 | (5008, 20, 5, 1, 4, 10, 1) 11 | (5009, 10, 5, 1, 5, 11, 1) 12 | (5010, 20, 5, 1, 6, 12, 1) 13 | (5011, 10, 5, 1, 7, 8, 1) 14 | (5012, 10, 5, 1, 8, 9, 1) 15 | (5013, 10, 5, 1, 9, 10, 1) 16 | (5014, 20, 5, 1, 10, 11, 1) 17 | (5015, 10, 5, 1, 11, 12, 1) 18 | (5016, 10, 5, 1, 7, 13, 1) 19 | (5017, 20, 5, 1, 8, 14, 1) 20 | (5018, 10, 5, 1, 9, 15, 1) 21 | (5019, 20, 5, 1, 10, 16, 1) 22 | (5020, 20, 5, 1, 11, 17, 1) 23 | (5021, 20, 5, 1, 12, 18, 1) 24 | (5022, 20, 5, 1, 13, 14, 1) 25 | (5023, 10, 5, 1, 14, 15, 1) 26 | (5024, 10, 5, 1, 15, 16, 1) 27 | (5025, 10, 5, 1, 16, 17, 1) 28 | (5026, 10, 5, 1, 17, 18, 1) 29 | (5027, 20, 5, 1, 13, 19, 1) 30 | (5028, 10, 5, 1, 14, 20, 1) 31 | (5029, 10, 5, 1, 15, 21, 1) 32 | (5030, 20, 5, 1, 16, 22, 1) 33 | (5031, 10, 5, 1, 17, 23, 1) 34 | (5032, 10, 5, 1, 18, 24, 1) 35 | (5033, 10, 5, 1, 19, 20, 1) 36 | (5034, 10, 5, 1, 20, 21, 1) 37 | (5035, 20, 5, 1, 21, 22, 1) 38 | (5036, 20, 5, 1, 22, 23, 1) 39 | (5037, 20, 5, 1, 23, 24, 1) 40 | (5038, 10, 5, 1, 19, 25, 1) 41 | (5039, 20, 5, 1, 20, 26, 1) 42 | (5040, 20, 5, 1, 21, 27, 1) 43 | (5041, 20, 5, 1, 22, 28, 1) 44 | (5042, 20, 5, 1, 23, 29, 1) 45 | (5043, 20, 5, 1, 24, 30, 1) 46 | (5044, 10, 5, 1, 25, 26, 1) 47 | (5045, 10, 5, 1, 26, 27, 1) 48 | (5046, 20, 5, 1, 27, 28, 1) 49 | (5047, 10, 5, 1, 28, 29, 1) 50 | (5048, 20, 5, 1, 29, 30, 1) 51 | (5049, 10, 5, 1, 25, 31, 1) 52 | (5050, 20, 5, 1, 26, 32, 1) 53 | (5051, 10, 5, 1, 27, 33, 1) 54 | (5052, 20, 5, 1, 28, 34, 1) 55 | (5053, 10, 5, 1, 29, 35, 1) 56 | (5054, 20, 5, 1, 30, 36, 1) 57 | (5055, 20, 5, 1, 31, 32, 1) 58 | (5056, 20, 5, 1, 32, 33, 1) 59 | (5057, 20, 5, 1, 33, 34, 1) 60 | (5058, 10, 5, 1, 34, 35, 1) 61 | (5059, 10, 5, 1, 35, 36, 1) -------------------------------------------------------------------------------- /CodeCraft2019/config_5/cross.txt: -------------------------------------------------------------------------------- 1 | #(id,roadId,roadId,roadId,roadId) 2 | (1, 5000, 5005, -1, -1) 3 | (2, 5001, 5006, 5000, -1) 4 | (3, 5002, 5007, 5001, -1) 5 | (4, 5003, 5008, 5002, -1) 6 | (5, 5004, 5009, 5003, -1) 7 | (6, -1, 5010, 5004, -1) 8 | (7, 5011, 5016, -1, 5005) 9 | (8, 5012, 5017, 5011, 5006) 10 | (9, 5013, 5018, 5012, 5007) 11 | (10, 5014, 5019, 5013, 5008) 12 | (11, 5015, 5020, 5014, 5009) 13 | (12, -1, 5021, 5015, 5010) 14 | (13, 5022, 5027, -1, 5016) 15 | (14, 5023, 5028, 5022, 5017) 16 | (15, 5024, 5029, 5023, 5018) 17 | (16, 5025, 5030, 5024, 5019) 18 | (17, 5026, 5031, 5025, 5020) 19 | (18, -1, 5032, 5026, 5021) 20 | (19, 5033, 5038, -1, 5027) 21 | (20, 5034, 5039, 5033, 5028) 22 | (21, 5035, 5040, 5034, 5029) 23 | (22, 5036, 5041, 5035, 5030) 24 | (23, 5037, 5042, 5036, 5031) 25 | (24, -1, 5043, 5037, 5032) 26 | (25, 5044, 5049, -1, 5038) 27 | (26, 5045, 5050, 5044, 5039) 28 | (27, 5046, 5051, 5045, 5040) 29 | (28, 5047, 5052, 5046, 5041) 30 | (29, 5048, 5053, 5047, 5042) 31 | (30, -1, 5054, 5048, 5043) 32 | (31, 5055, -1, -1, 5049) 33 | (32, 5056, -1, 5055, 5050) 34 | (33, 5057, -1, 5056, 5051) 35 | (34, 5058, -1, 5057, 5052) 36 | (35, 5059, -1, 5058, 5053) 37 | (36, -1, -1, 5059, 5054) -------------------------------------------------------------------------------- /CodeCraft2019/config_5/road.txt: -------------------------------------------------------------------------------- 1 | #(id,length,speed,channel,from,to,isDuplex) 2 | (5000, 10, 8, 1, 1, 2, 1) 3 | (5001, 20, 8, 1, 2, 3, 1) 4 | (5002, 10, 4, 1, 3, 4, 1) 5 | (5003, 20, 4, 1, 4, 5, 1) 6 | (5004, 20, 6, 1, 5, 6, 1) 7 | (5005, 20, 4, 1, 1, 7, 1) 8 | (5006, 20, 8, 1, 2, 8, 1) 9 | (5007, 10, 8, 1, 3, 9, 1) 10 | (5008, 10, 4, 1, 4, 10, 1) 11 | (5009, 20, 8, 1, 5, 11, 1) 12 | (5010, 10, 8, 1, 6, 12, 1) 13 | (5011, 10, 6, 1, 7, 8, 1) 14 | (5012, 20, 4, 1, 8, 9, 1) 15 | (5013, 10, 8, 1, 9, 10, 1) 16 | (5014, 20, 8, 1, 10, 11, 1) 17 | (5015, 10, 8, 1, 11, 12, 1) 18 | (5016, 10, 4, 1, 7, 13, 1) 19 | (5017, 10, 6, 1, 8, 14, 1) 20 | (5018, 20, 6, 1, 9, 15, 1) 21 | (5019, 20, 6, 1, 10, 16, 1) 22 | (5020, 10, 8, 1, 11, 17, 1) 23 | (5021, 10, 6, 1, 12, 18, 1) 24 | (5022, 20, 4, 1, 13, 14, 1) 25 | (5023, 20, 6, 1, 14, 15, 1) 26 | (5024, 20, 4, 1, 15, 16, 1) 27 | (5025, 20, 8, 1, 16, 17, 1) 28 | (5026, 10, 4, 1, 17, 18, 1) 29 | (5027, 20, 8, 1, 13, 19, 1) 30 | (5028, 20, 4, 1, 14, 20, 1) 31 | (5029, 10, 8, 1, 15, 21, 1) 32 | (5030, 10, 6, 1, 16, 22, 1) 33 | (5031, 20, 6, 1, 17, 23, 1) 34 | (5032, 20, 8, 1, 18, 24, 1) 35 | (5033, 20, 8, 1, 19, 20, 1) 36 | (5034, 10, 8, 1, 20, 21, 1) 37 | (5035, 20, 8, 1, 21, 22, 1) 38 | (5036, 10, 6, 1, 22, 23, 1) 39 | (5037, 20, 8, 1, 23, 24, 1) 40 | (5038, 20, 6, 1, 19, 25, 1) 41 | (5039, 20, 6, 1, 20, 26, 1) 42 | (5040, 20, 4, 1, 21, 27, 1) 43 | (5041, 20, 4, 1, 22, 28, 1) 44 | (5042, 20, 4, 1, 23, 29, 1) 45 | (5043, 10, 6, 1, 24, 30, 1) 46 | (5044, 10, 6, 1, 25, 26, 1) 47 | (5045, 20, 8, 1, 26, 27, 1) 48 | (5046, 20, 6, 1, 27, 28, 1) 49 | (5047, 20, 6, 1, 28, 29, 1) 50 | (5048, 20, 6, 1, 29, 30, 1) 51 | (5049, 20, 8, 1, 25, 31, 1) 52 | (5050, 10, 8, 1, 26, 32, 1) 53 | (5051, 10, 4, 1, 27, 33, 1) 54 | (5052, 20, 4, 1, 28, 34, 1) 55 | (5053, 10, 4, 1, 29, 35, 1) 56 | (5054, 20, 4, 1, 30, 36, 1) 57 | (5055, 20, 6, 1, 31, 32, 1) 58 | (5056, 20, 6, 1, 32, 33, 1) 59 | (5057, 10, 4, 1, 33, 34, 1) 60 | (5058, 20, 6, 1, 34, 35, 1) 61 | (5059, 20, 4, 1, 35, 36, 1) -------------------------------------------------------------------------------- /CodeCraft2019/config_6/cross.txt: -------------------------------------------------------------------------------- 1 | #(id,roadId,roadId,roadId,roadId) 2 | (1, 5000, 5005, -1, -1) 3 | (2, 5001, 5006, 5000, -1) 4 | (3, 5002, 5007, 5001, -1) 5 | (4, 5003, 5008, 5002, -1) 6 | (5, 5004, 5009, 5003, -1) 7 | (6, -1, 5010, 5004, -1) 8 | (7, 5011, 5016, -1, 5005) 9 | (8, 5012, 5017, 5011, 5006) 10 | (9, 5013, 5018, 5012, 5007) 11 | (10, 5014, 5019, 5013, 5008) 12 | (11, 5015, 5020, 5014, 5009) 13 | (12, -1, 5021, 5015, 5010) 14 | (13, 5022, 5027, -1, 5016) 15 | (14, 5023, 5028, 5022, 5017) 16 | (15, 5024, 5029, 5023, 5018) 17 | (16, 5025, 5030, 5024, 5019) 18 | (17, 5026, 5031, 5025, 5020) 19 | (18, -1, 5032, 5026, 5021) 20 | (19, 5033, 5038, -1, 5027) 21 | (20, 5034, 5039, 5033, 5028) 22 | (21, 5035, 5040, 5034, 5029) 23 | (22, 5036, 5041, 5035, 5030) 24 | (23, 5037, 5042, 5036, 5031) 25 | (24, -1, 5043, 5037, 5032) 26 | (25, 5044, 5049, -1, 5038) 27 | (26, 5045, 5050, 5044, 5039) 28 | (27, 5046, 5051, 5045, 5040) 29 | (28, 5047, 5052, 5046, 5041) 30 | (29, 5048, 5053, 5047, 5042) 31 | (30, -1, 5054, 5048, 5043) 32 | (31, 5055, -1, -1, 5049) 33 | (32, 5056, -1, 5055, 5050) 34 | (33, 5057, -1, 5056, 5051) 35 | (34, 5058, -1, 5057, 5052) 36 | (35, 5059, -1, 5058, 5053) 37 | (36, -1, -1, 5059, 5054) -------------------------------------------------------------------------------- /CodeCraft2019/config_6/road.txt: -------------------------------------------------------------------------------- 1 | #(id,length,speed,channel,from,to,isDuplex) 2 | (5000, 20, 4, 1, 1, 2, 1) 3 | (5001, 20, 8, 1, 2, 3, 1) 4 | (5002, 20, 8, 2, 3, 4, 1) 5 | (5003, 20, 8, 1, 4, 5, 1) 6 | (5004, 20, 4, 2, 5, 6, 1) 7 | (5005, 10, 8, 1, 1, 7, 1) 8 | (5006, 10, 8, 2, 2, 8, 1) 9 | (5007, 10, 8, 2, 3, 9, 1) 10 | (5008, 20, 4, 2, 4, 10, 1) 11 | (5009, 20, 4, 1, 5, 11, 1) 12 | (5010, 20, 4, 2, 6, 12, 1) 13 | (5011, 10, 4, 2, 7, 8, 1) 14 | (5012, 10, 4, 1, 8, 9, 1) 15 | (5013, 20, 6, 2, 9, 10, 1) 16 | (5014, 20, 4, 2, 10, 11, 1) 17 | (5015, 20, 4, 2, 11, 12, 1) 18 | (5016, 20, 4, 2, 7, 13, 1) 19 | (5017, 20, 6, 1, 8, 14, 1) 20 | (5018, 20, 8, 2, 9, 15, 1) 21 | (5019, 10, 8, 2, 10, 16, 1) 22 | (5020, 20, 6, 1, 11, 17, 1) 23 | (5021, 10, 4, 1, 12, 18, 1) 24 | (5022, 10, 4, 2, 13, 14, 1) 25 | (5023, 10, 6, 1, 14, 15, 1) 26 | (5024, 10, 6, 2, 15, 16, 1) 27 | (5025, 20, 6, 1, 16, 17, 1) 28 | (5026, 10, 8, 2, 17, 18, 1) 29 | (5027, 10, 8, 1, 13, 19, 1) 30 | (5028, 10, 6, 2, 14, 20, 1) 31 | (5029, 20, 6, 2, 15, 21, 1) 32 | (5030, 10, 4, 2, 16, 22, 1) 33 | (5031, 20, 8, 2, 17, 23, 1) 34 | (5032, 20, 4, 1, 18, 24, 1) 35 | (5033, 10, 6, 2, 19, 20, 1) 36 | (5034, 20, 6, 1, 20, 21, 1) 37 | (5035, 20, 8, 2, 21, 22, 1) 38 | (5036, 20, 4, 2, 22, 23, 1) 39 | (5037, 10, 6, 2, 23, 24, 1) 40 | (5038, 10, 8, 2, 19, 25, 1) 41 | (5039, 20, 4, 2, 20, 26, 1) 42 | (5040, 10, 8, 1, 21, 27, 1) 43 | (5041, 20, 4, 2, 22, 28, 1) 44 | (5042, 10, 4, 1, 23, 29, 1) 45 | (5043, 10, 4, 2, 24, 30, 1) 46 | (5044, 10, 8, 2, 25, 26, 1) 47 | (5045, 20, 4, 1, 26, 27, 1) 48 | (5046, 10, 6, 1, 27, 28, 1) 49 | (5047, 10, 8, 2, 28, 29, 1) 50 | (5048, 10, 8, 2, 29, 30, 1) 51 | (5049, 10, 8, 1, 25, 31, 1) 52 | (5050, 20, 4, 1, 26, 32, 1) 53 | (5051, 10, 8, 2, 27, 33, 1) 54 | (5052, 10, 8, 1, 28, 34, 1) 55 | (5053, 20, 4, 2, 29, 35, 1) 56 | (5054, 20, 8, 1, 30, 36, 1) 57 | (5055, 20, 6, 2, 31, 32, 1) 58 | (5056, 20, 4, 1, 32, 33, 1) 59 | (5057, 10, 8, 1, 33, 34, 1) 60 | (5058, 20, 8, 1, 34, 35, 1) 61 | (5059, 20, 4, 2, 35, 36, 1) -------------------------------------------------------------------------------- /CodeCraft2019/config_7/cross.txt: -------------------------------------------------------------------------------- 1 | #(id,roadId,roadId,roadId,roadId) 2 | (1, 5000, 5005, -1, -1) 3 | (2, 5001, 5006, 5000, -1) 4 | (3, 5002, 5007, 5001, -1) 5 | (4, 5003, 5008, 5002, -1) 6 | (5, 5004, 5009, 5003, -1) 7 | (6, -1, 5010, 5004, -1) 8 | (7, 5011, 5016, -1, 5005) 9 | (8, 5012, 5017, 5011, 5006) 10 | (9, 5013, 5018, 5012, 5007) 11 | (10, 5014, 5019, 5013, 5008) 12 | (11, 5015, 5020, 5014, 5009) 13 | (12, -1, 5021, 5015, 5010) 14 | (13, 5022, 5027, -1, 5016) 15 | (14, 5023, 5028, 5022, 5017) 16 | (15, 5024, 5029, 5023, 5018) 17 | (16, 5025, 5030, 5024, 5019) 18 | (17, 5026, 5031, 5025, 5020) 19 | (18, -1, 5032, 5026, 5021) 20 | (19, 5033, 5038, -1, 5027) 21 | (20, 5034, 5039, 5033, 5028) 22 | (21, 5035, 5040, 5034, 5029) 23 | (22, 5036, 5041, 5035, 5030) 24 | (23, 5037, 5042, 5036, 5031) 25 | (24, -1, 5043, 5037, 5032) 26 | (25, 5044, 5049, -1, 5038) 27 | (26, 5045, 5050, 5044, 5039) 28 | (27, 5046, 5051, 5045, 5040) 29 | (28, 5047, 5052, 5046, 5041) 30 | (29, 5048, 5053, 5047, 5042) 31 | (30, -1, 5054, 5048, 5043) 32 | (31, 5055, -1, -1, 5049) 33 | (32, 5056, -1, 5055, 5050) 34 | (33, 5057, -1, 5056, 5051) 35 | (34, 5058, -1, 5057, 5052) 36 | (35, 5059, -1, 5058, 5053) 37 | (36, -1, -1, 5059, 5054) -------------------------------------------------------------------------------- /CodeCraft2019/config_7/road.txt: -------------------------------------------------------------------------------- 1 | #(id,length,speed,channel,from,to,isDuplex) 2 | (5000, 20, 4, 1, 1, 2, 1) 3 | (5001, 10, 8, 2, 2, 3, 1) 4 | (5002, 20, 8, 1, 3, 4, 1) 5 | (5003, 20, 8, 2, 4, 5, 1) 6 | (5004, 10, 6, 1, 5, 6, 1) 7 | (5005, 20, 4, 1, 1, 7, 1) 8 | (5006, 20, 8, 1, 2, 8, 1) 9 | (5007, 10, 4, 1, 3, 9, 1) 10 | (5008, 20, 6, 1, 4, 10, 1) 11 | (5009, 10, 6, 1, 5, 11, 1) 12 | (5010, 10, 6, 1, 6, 12, 1) 13 | (5011, 20, 8, 1, 7, 8, 1) 14 | (5012, 20, 4, 1, 8, 9, 1) 15 | (5013, 10, 4, 2, 9, 10, 0) 16 | (5014, 10, 8, 1, 10, 11, 1) 17 | (5015, 10, 8, 2, 11, 12, 1) 18 | (5016, 20, 8, 2, 7, 13, 1) 19 | (5017, 20, 4, 2, 8, 14, 1) 20 | (5018, 20, 6, 1, 9, 15, 1) 21 | (5019, 10, 4, 1, 10, 16, 1) 22 | (5020, 20, 4, 2, 11, 17, 0) 23 | (5021, 20, 4, 2, 12, 18, 1) 24 | (5022, 10, 4, 2, 13, 14, 1) 25 | (5023, 20, 6, 1, 14, 15, 1) 26 | (5024, 20, 6, 1, 15, 16, 1) 27 | (5025, 20, 8, 1, 16, 17, 1) 28 | (5026, 20, 6, 2, 17, 18, 1) 29 | (5027, 10, 6, 2, 13, 19, 1) 30 | (5028, 20, 4, 2, 14, 20, 1) 31 | (5029, 20, 4, 2, 15, 21, 1) 32 | (5030, 20, 6, 1, 16, 22, 1) 33 | (5031, 10, 8, 1, 17, 23, 1) 34 | (5032, 20, 6, 2, 18, 24, 1) 35 | (5033, 10, 6, 2, 19, 20, 1) 36 | (5034, 10, 8, 2, 20, 21, 1) 37 | (5035, 20, 6, 1, 21, 22, 0) 38 | (5036, 10, 4, 1, 22, 23, 1) 39 | (5037, 10, 8, 2, 23, 24, 1) 40 | (5038, 20, 6, 1, 19, 25, 1) 41 | (5039, 20, 6, 1, 20, 26, 1) 42 | (5040, 10, 4, 2, 21, 27, 1) 43 | (5041, 10, 8, 1, 22, 28, 1) 44 | (5042, 20, 4, 1, 23, 29, 1) 45 | (5043, 20, 4, 2, 24, 30, 1) 46 | (5044, 20, 8, 2, 25, 26, 1) 47 | (5045, 20, 8, 1, 26, 27, 1) 48 | (5046, 10, 6, 1, 27, 28, 1) 49 | (5047, 20, 8, 1, 28, 29, 1) 50 | (5048, 20, 6, 1, 29, 30, 1) 51 | (5049, 20, 4, 1, 25, 31, 1) 52 | (5050, 20, 8, 1, 26, 32, 1) 53 | (5051, 20, 6, 2, 27, 33, 1) 54 | (5052, 10, 4, 2, 28, 34, 1) 55 | (5053, 10, 6, 2, 29, 35, 1) 56 | (5054, 10, 8, 1, 30, 36, 1) 57 | (5055, 10, 4, 1, 31, 32, 1) 58 | (5056, 20, 4, 1, 32, 33, 1) 59 | (5057, 20, 6, 1, 33, 34, 1) 60 | (5058, 20, 4, 2, 34, 35, 1) 61 | (5059, 20, 4, 1, 35, 36, 1) -------------------------------------------------------------------------------- /CodeCraft2019/config_8/cross.txt: -------------------------------------------------------------------------------- 1 | #(id,roadId,roadId,roadId,roadId) 2 | (1, 5000, 5005, -1, -1) 3 | (2, 5001, 5006, 5000, -1) 4 | (3, 5002, 5007, 5001, -1) 5 | (4, 5003, 5008, 5002, -1) 6 | (5, 5004, 5009, 5003, -1) 7 | (6, -1, 5010, 5004, -1) 8 | (7, 5011, 5016, -1, 5005) 9 | (8, 5012, 5017, 5011, 5006) 10 | (9, 5013, 5018, 5012, 5007) 11 | (10, 5014, 5019, 5013, 5008) 12 | (11, 5015, 5020, 5014, 5009) 13 | (12, -1, 5021, 5015, 5010) 14 | (13, 5022, 5027, -1, 5016) 15 | (14, 5023, 5028, 5022, 5017) 16 | (15, 5024, 5029, 5023, 5018) 17 | (16, 5025, 5030, 5024, 5019) 18 | (17, 5026, 5031, 5025, 5020) 19 | (18, -1, 5032, 5026, 5021) 20 | (19, 5033, 5038, -1, 5027) 21 | (20, 5034, 5039, 5033, 5028) 22 | (21, 5035, 5040, 5034, 5029) 23 | (22, 5036, 5041, 5035, 5030) 24 | (23, 5037, 5042, 5036, 5031) 25 | (24, -1, 5043, 5037, 5032) 26 | (25, 5044, 5049, -1, 5038) 27 | (26, 5045, 5050, 5044, 5039) 28 | (27, 5046, 5051, 5045, 5040) 29 | (28, 5047, 5052, 5046, 5041) 30 | (29, 5048, 5053, 5047, 5042) 31 | (30, -1, 5054, 5048, 5043) 32 | (31, 5055, -1, -1, 5049) 33 | (32, 5056, -1, 5055, 5050) 34 | (33, 5057, -1, 5056, 5051) 35 | (34, 5058, -1, 5057, 5052) 36 | (35, 5059, -1, 5058, 5053) 37 | (36, -1, -1, 5059, 5054) -------------------------------------------------------------------------------- /CodeCraft2019/config_8/road.txt: -------------------------------------------------------------------------------- 1 | #(id,length,speed,channel,from,to,isDuplex) 2 | (5000, 20, 4, 2, 1, 2, 1) 3 | (5001, 20, 4, 2, 2, 3, 1) 4 | (5002, 20, 4, 2, 3, 4, 1) 5 | (5003, 20, 4, 1, 4, 5, 1) 6 | (5004, 20, 6, 1, 5, 6, 1) 7 | (5005, 10, 6, 1, 1, 7, 1) 8 | (5006, 20, 4, 2, 2, 8, 1) 9 | (5007, 20, 4, 2, 3, 9, 1) 10 | (5008, 10, 8, 2, 4, 10, 1) 11 | (5009, 20, 8, 1, 5, 11, 1) 12 | (5010, 20, 4, 2, 6, 12, 1) 13 | (5011, 10, 8, 2, 7, 8, 1) 14 | (5012, 10, 4, 2, 8, 9, 1) 15 | (5013, 10, 6, 2, 9, 10, 0) 16 | (5014, 20, 6, 1, 10, 11, 1) 17 | (5015, 20, 4, 2, 11, 12, 1) 18 | (5016, 20, 6, 2, 7, 13, 1) 19 | (5017, 10, 4, 2, 8, 14, 1) 20 | (5018, 20, 6, 1, 9, 15, 1) 21 | (5019, 10, 4, 2, 10, 16, 1) 22 | (5020, 10, 8, 2, 11, 17, 0) 23 | (5021, 20, 8, 2, 12, 18, 1) 24 | (5022, 10, 4, 1, 13, 14, 1) 25 | (5023, 20, 6, 1, 14, 15, 1) 26 | (5024, 20, 8, 2, 15, 16, 1) 27 | (5025, 20, 8, 2, 16, 17, 1) 28 | (5026, 20, 6, 2, 17, 18, 1) 29 | (5027, 20, 4, 2, 13, 19, 1) 30 | (5028, 20, 8, 2, 14, 20, 1) 31 | (5029, 10, 6, 1, 15, 21, 1) 32 | (5030, 10, 6, 1, 16, 22, 1) 33 | (5031, 10, 4, 2, 17, 23, 1) 34 | (5032, 10, 6, 1, 18, 24, 1) 35 | (5033, 10, 4, 2, 19, 20, 1) 36 | (5034, 20, 6, 1, 20, 21, 1) 37 | (5035, 20, 6, 1, 21, 22, 0) 38 | (5036, 20, 4, 1, 22, 23, 1) 39 | (5037, 20, 4, 2, 23, 24, 1) 40 | (5038, 10, 8, 2, 19, 25, 1) 41 | (5039, 20, 6, 1, 20, 26, 1) 42 | (5040, 20, 8, 1, 21, 27, 1) 43 | (5041, 10, 8, 1, 22, 28, 1) 44 | (5042, 20, 4, 1, 23, 29, 1) 45 | (5043, 20, 8, 1, 24, 30, 1) 46 | (5044, 10, 6, 1, 25, 26, 1) 47 | (5045, 20, 6, 1, 26, 27, 1) 48 | (5046, 10, 4, 1, 27, 28, 1) 49 | (5047, 10, 6, 2, 28, 29, 1) 50 | (5048, 10, 8, 1, 29, 30, 1) 51 | (5049, 10, 4, 2, 25, 31, 1) 52 | (5050, 10, 4, 2, 26, 32, 1) 53 | (5051, 10, 6, 1, 27, 33, 1) 54 | (5052, 10, 4, 1, 28, 34, 1) 55 | (5053, 20, 4, 2, 29, 35, 1) 56 | (5054, 20, 8, 2, 30, 36, 1) 57 | (5055, 20, 6, 2, 31, 32, 1) 58 | (5056, 10, 8, 2, 32, 33, 1) 59 | (5057, 10, 8, 2, 33, 34, 1) 60 | (5058, 20, 6, 1, 34, 35, 1) 61 | (5059, 10, 4, 1, 35, 36, 1) -------------------------------------------------------------------------------- /CodeCraft2019/config_9/cross.txt: -------------------------------------------------------------------------------- 1 | #(id,roadId,roadId,roadId,roadId) 2 | (1, 5000, 5005, -1, -1) 3 | (2, 5001, 5006, 5000, -1) 4 | (3, 5002, 5007, 5001, -1) 5 | (4, 5003, 5008, 5002, -1) 6 | (5, 5004, 5009, 5003, -1) 7 | (6, -1, 5010, 5004, -1) 8 | (7, 5011, 5016, -1, 5005) 9 | (8, 5012, 5017, 5011, 5006) 10 | (9, 5013, 5018, 5012, 5007) 11 | (10, 5014, 5019, 5013, 5008) 12 | (11, 5015, 5020, 5014, 5009) 13 | (12, -1, 5021, 5015, 5010) 14 | (13, 5022, 5027, -1, 5016) 15 | (14, 5023, 5028, 5022, 5017) 16 | (15, 5024, 5029, 5023, 5018) 17 | (16, 5025, 5030, 5024, 5019) 18 | (17, 5026, 5031, 5025, 5020) 19 | (18, -1, 5032, 5026, 5021) 20 | (19, 5033, 5038, -1, 5027) 21 | (20, 5034, 5039, 5033, 5028) 22 | (21, 5035, 5040, 5034, 5029) 23 | (22, 5036, 5041, 5035, 5030) 24 | (23, 5037, 5042, 5036, 5031) 25 | (24, -1, 5043, 5037, 5032) 26 | (25, 5044, 5049, -1, 5038) 27 | (26, 5045, 5050, 5044, 5039) 28 | (27, 5046, 5051, 5045, 5040) 29 | (28, 5047, 5052, 5046, 5041) 30 | (29, 5048, 5053, 5047, 5042) 31 | (30, -1, 5054, 5048, 5043) 32 | (31, 5055, -1, -1, 5049) 33 | (32, 5056, -1, 5055, 5050) 34 | (33, 5057, -1, 5056, 5051) 35 | (34, 5058, -1, 5057, 5052) 36 | (35, 5059, -1, 5058, 5053) 37 | (36, -1, -1, 5059, 5054) -------------------------------------------------------------------------------- /CodeCraft2019/config_9/road.txt: -------------------------------------------------------------------------------- 1 | #(id,length,speed,channel,from,to,isDuplex) 2 | (5000, 20, 6, 3, 1, 2, 1) 3 | (5001, 10, 6, 1, 2, 3, 1) 4 | (5002, 20, 4, 3, 3, 4, 1) 5 | (5003, 10, 6, 3, 4, 5, 1) 6 | (5004, 10, 8, 1, 5, 6, 1) 7 | (5005, 10, 4, 2, 1, 7, 1) 8 | (5006, 20, 8, 1, 2, 8, 1) 9 | (5007, 10, 4, 2, 3, 9, 1) 10 | (5008, 10, 6, 2, 4, 10, 1) 11 | (5009, 20, 4, 3, 5, 11, 1) 12 | (5010, 20, 4, 3, 6, 12, 1) 13 | (5011, 15, 4, 2, 7, 8, 1) 14 | (5012, 15, 8, 1, 8, 9, 1) 15 | (5013, 20, 6, 1, 9, 10, 0) 16 | (5014, 20, 8, 2, 10, 11, 1) 17 | (5015, 15, 8, 2, 11, 12, 1) 18 | (5016, 20, 4, 1, 7, 13, 1) 19 | (5017, 15, 6, 3, 8, 14, 1) 20 | (5018, 15, 4, 3, 9, 15, 1) 21 | (5019, 20, 6, 1, 10, 16, 1) 22 | (5020, 20, 4, 3, 11, 17, 0) 23 | (5021, 10, 4, 1, 12, 18, 1) 24 | (5022, 10, 4, 1, 13, 14, 1) 25 | (5023, 10, 4, 3, 14, 15, 1) 26 | (5024, 10, 8, 2, 15, 16, 1) 27 | (5025, 10, 8, 1, 16, 17, 1) 28 | (5026, 10, 8, 3, 17, 18, 1) 29 | (5027, 10, 6, 2, 13, 19, 1) 30 | (5028, 10, 8, 1, 14, 20, 1) 31 | (5029, 10, 8, 3, 15, 21, 1) 32 | (5030, 15, 6, 1, 16, 22, 1) 33 | (5031, 20, 4, 2, 17, 23, 1) 34 | (5032, 15, 8, 3, 18, 24, 1) 35 | (5033, 20, 4, 2, 19, 20, 1) 36 | (5034, 20, 6, 1, 20, 21, 1) 37 | (5035, 15, 6, 1, 21, 22, 0) 38 | (5036, 10, 4, 1, 22, 23, 1) 39 | (5037, 20, 8, 2, 23, 24, 1) 40 | (5038, 15, 4, 1, 19, 25, 1) 41 | (5039, 10, 8, 2, 20, 26, 1) 42 | (5040, 15, 4, 3, 21, 27, 1) 43 | (5041, 15, 6, 3, 22, 28, 1) 44 | (5042, 20, 8, 2, 23, 29, 1) 45 | (5043, 10, 8, 1, 24, 30, 1) 46 | (5044, 15, 8, 2, 25, 26, 1) 47 | (5045, 20, 4, 2, 26, 27, 1) 48 | (5046, 20, 6, 1, 27, 28, 1) 49 | (5047, 20, 8, 3, 28, 29, 1) 50 | (5048, 10, 6, 1, 29, 30, 1) 51 | (5049, 20, 4, 2, 25, 31, 1) 52 | (5050, 20, 6, 3, 26, 32, 1) 53 | (5051, 10, 6, 2, 27, 33, 1) 54 | (5052, 10, 6, 1, 28, 34, 1) 55 | (5053, 10, 4, 3, 29, 35, 1) 56 | (5054, 15, 6, 1, 30, 36, 1) 57 | (5055, 10, 8, 1, 31, 32, 1) 58 | (5056, 10, 4, 1, 32, 33, 1) 59 | (5057, 15, 6, 1, 33, 34, 1) 60 | (5058, 15, 4, 2, 34, 35, 1) 61 | (5059, 10, 4, 1, 35, 36, 1) -------------------------------------------------------------------------------- /CodeCraft2019/run-framework.h: -------------------------------------------------------------------------------- 1 | #ifndef RUN_FRAMEWORK_H 2 | #define RUN_FRAMEWORK_H 3 | 4 | #include "scheduler.h" 5 | 6 | /* for find a best answer */ 7 | class RunFramework 8 | { 9 | public: 10 | RunFramework(); 11 | void Initialize(); 12 | bool HandleTerminateAssert(); 13 | void Run(int argc, char* argv[]); 14 | void RunImpl(Scheduler* scheduler); 15 | 16 | //implements 17 | void RunStableVersion(); 18 | void RunFindABetterAnswer(); 19 | 20 | private: 21 | bool IsNoMoreTime() const; 22 | 23 | double m_maxTime; 24 | double m_safeInterval; 25 | int m_bestAnswer; 26 | 27 | //variables of implements 28 | bool m_isStableOutputed; 29 | 30 | /* arguments for floyd */ 31 | int m_floydLengthWeight; 32 | int m_floydLooserCarsNumOnRoadLimit; 33 | }; 34 | 35 | #endif -------------------------------------------------------------------------------- /CodeCraft2019/scenario/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 查找当前目录下的所有源文件 2 | aux_source_directory(. DIR_SCENARIO_SRCS) 3 | 4 | # 指定生成目标 5 | add_library(scenario SHARED ${DIR_SCENARIO_SRCS}) 6 | -------------------------------------------------------------------------------- /CodeCraft2019/scenario/car.cpp: -------------------------------------------------------------------------------- 1 | #include "car.h" 2 | #include "assert.h" 3 | #include "cross.h" 4 | 5 | Car::Car() 6 | { 7 | ASSERT(false); 8 | } 9 | 10 | Car::Car(const int& origin, const int& id, const int& fromCrossId, const int& toCrossId, const int& maxSpeed, const int& planTime, const bool& isVip, const bool& isPreset) 11 | : m_originId(origin), m_id(id), m_fromCrossId(fromCrossId), m_toCrossId(toCrossId), m_maxSpeed(maxSpeed), m_planTime(planTime) 12 | , m_isVip(isVip), m_isPreset(isPreset) 13 | , m_fromCross(0), m_toCross(0) 14 | { } 15 | 16 | Car::~Car() 17 | { } 18 | 19 | void Car::SetFromCrossId(const int& id) 20 | { 21 | m_fromCrossId = id; 22 | 23 | } 24 | void Car::SetToCrossId(const int& id) 25 | { 26 | m_toCrossId = id; 27 | } 28 | 29 | void Car::SetMaxSpeed(const int& speed) 30 | { 31 | m_maxSpeed = speed; 32 | } 33 | 34 | void Car::SetFromCross(Cross* cross) 35 | { 36 | ASSERT(cross->GetId() == m_fromCrossId); 37 | m_fromCross = cross; 38 | } 39 | 40 | void Car::SetToCross(Cross* cross) 41 | { 42 | ASSERT(cross->GetId() == m_toCrossId); 43 | m_toCross = cross; 44 | } -------------------------------------------------------------------------------- /CodeCraft2019/scenario/car.h: -------------------------------------------------------------------------------- 1 | #ifndef CAR_H 2 | #define CAR_H 3 | 4 | class Cross; 5 | 6 | class Car 7 | { 8 | private: 9 | int m_originId; 10 | int m_id; 11 | int m_fromCrossId; 12 | int m_toCrossId; 13 | int m_maxSpeed; 14 | int m_planTime; 15 | bool m_isVip; 16 | bool m_isPreset; 17 | 18 | Cross* m_fromCross; 19 | Cross* m_toCross; 20 | 21 | public: 22 | Car(); 23 | Car(const int& origin, const int& id, const int& fromCrossId, const int& toCrossId, const int& maxSpeed, const int& planTime, const bool& isVip, const bool& isPreset); 24 | ~Car(); 25 | 26 | inline const int& GetOriginId() const; 27 | inline const int& GetId() const; 28 | inline const int& GetFromCrossId() const; 29 | inline const int& GetToCrossId() const; 30 | inline const int& GetMaxSpeed() const; 31 | inline const int& GetPlanTime() const; 32 | inline const bool& GetIsVip() const; 33 | inline const bool& GetIsPreset() const; 34 | 35 | void SetFromCrossId(const int& id); 36 | void SetToCrossId(const int& id); 37 | void SetMaxSpeed(const int& speed); 38 | void SetFromCross(Cross* cross); 39 | void SetToCross(Cross* cross); 40 | inline Cross* GetFromCross() const; 41 | inline Cross* GetToCross() const; 42 | 43 | };//class Car 44 | 45 | #include 46 | inline std::ostream& operator << (std::ostream& os, const Car& car); 47 | 48 | 49 | 50 | 51 | 52 | /* 53 | * [inline functions] 54 | * it's not good to write code here, but we really need inline! 55 | */ 56 | 57 | #include "assert.h" 58 | 59 | inline const int& Car::GetOriginId() const 60 | { 61 | return m_originId; 62 | } 63 | 64 | inline const int& Car::GetId() const 65 | { 66 | return m_id; 67 | } 68 | 69 | inline const int& Car::GetFromCrossId() const 70 | { 71 | return m_fromCrossId; 72 | } 73 | 74 | inline const int& Car::GetToCrossId() const 75 | { 76 | return m_toCrossId; 77 | } 78 | 79 | inline const int& Car::GetMaxSpeed() const 80 | { 81 | return m_maxSpeed; 82 | } 83 | 84 | inline const int& Car::GetPlanTime() const 85 | { 86 | return m_planTime; 87 | } 88 | 89 | inline const bool& Car::GetIsVip() const 90 | { 91 | return m_isVip; 92 | } 93 | 94 | inline const bool& Car::GetIsPreset() const 95 | { 96 | return m_isPreset; 97 | } 98 | 99 | inline Cross* Car::GetFromCross() const 100 | { 101 | ASSERT(m_fromCross != 0); 102 | return m_fromCross; 103 | } 104 | 105 | inline Cross* Car::GetToCross() const 106 | { 107 | ASSERT(m_toCross != 0); 108 | return m_toCross; 109 | } 110 | 111 | inline std::ostream& operator << (std::ostream& os, const Car& car) 112 | { 113 | return (os << (car.GetIsPreset() ? "preset " : "") 114 | << (car.GetIsVip() ? "VIP " : "") 115 | << "car [" << car.GetOriginId() << "(" << car.GetId() << ")" << "]"); 116 | } 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /CodeCraft2019/scenario/config.cpp: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | #include "assert.h" 3 | 4 | std::string Config::PathCar; 5 | std::string Config::PathCross; 6 | std::string Config::PathRoad; 7 | std::string Config::PathPreset; 8 | std::string Config::PathResult; 9 | const double Config::TimeLimit(900); 10 | 11 | Config::Config() 12 | { 13 | ASSERT(false); 14 | } 15 | 16 | void Config::Initialize(int argc, char* argv[]) 17 | { 18 | ASSERT_MSG(argc >= 6, "argc=" << argc); 19 | PathCar = argv[1]; 20 | PathRoad = argv[2]; 21 | PathCross = argv[3]; 22 | PathPreset = argv[4]; 23 | PathResult = argv[5]; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /CodeCraft2019/scenario/config.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_H 2 | #define CONFIG_H 3 | 4 | #include 5 | 6 | class Config 7 | { 8 | private: 9 | Config(); 10 | virtual ~Config() = 0; 11 | 12 | public: 13 | static void Initialize(int argc, char* argv[]); 14 | static std::string PathCar; 15 | static std::string PathCross; 16 | static std::string PathRoad; 17 | static std::string PathPreset; 18 | static std::string PathResult; 19 | static const double TimeLimit; 20 | 21 | };//class Config 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /CodeCraft2019/scenario/cross.cpp: -------------------------------------------------------------------------------- 1 | #include "cross.h" 2 | #include "assert.h" 3 | #include "road.h" 4 | 5 | Cross::Cross() 6 | { 7 | ASSERT(false); 8 | } 9 | 10 | Cross::Cross(const int& origin, const int& id, const int& northRoadId, const int& eastRoadId, const int& southRoadId, const int& westRoadId) 11 | : m_originId(origin), m_id(id), m_northRoadId(northRoadId), m_eastRoadId(eastRoadId), m_southRoadId(southRoadId), m_westRoadId(westRoadId) 12 | , m_north(0), m_east(0), m_south(0), m_west(0) 13 | { 14 | if (m_northRoadId >= 0) m_directions[m_northRoadId] = NORTH; 15 | if (m_eastRoadId >= 0) m_directions[m_eastRoadId] = EAST; 16 | if (m_southRoadId >= 0) m_directions[m_southRoadId] = SOUTH; 17 | if (m_westRoadId >= 0) m_directions[m_westRoadId] = WEST; 18 | } 19 | 20 | Cross::~Cross() 21 | { } 22 | 23 | const Cross::DirectionType& Cross::GetDirection(const int& id) const 24 | { 25 | auto find = m_directions.find(id); 26 | ASSERT(find != m_directions.end()); 27 | return find->second; 28 | } 29 | 30 | Cross::TurnType Cross::GetTurnDirection(const int& from, const int& to) const 31 | { 32 | switch ((int)GetDirection(to) - (int)GetDirection(from)) 33 | { 34 | case 1: 35 | case -3: 36 | return Cross::LEFT; 37 | case -1: 38 | case 3: 39 | return Cross::RIGHT; 40 | case 2: 41 | case -2: 42 | return Cross::DIRECT; 43 | default: 44 | break; 45 | } 46 | ASSERT_MSG(false, "from " << from << "(" << GetDirection(from) << ") to " << to << "(" << GetDirection(to) << ")"); 47 | return Cross::DIRECT; 48 | } 49 | 50 | Cross::DirectionType Cross::GetTurnDestinationDirection(const int& from, const Cross::TurnType& turn) const 51 | { 52 | int dir = (int)GetDirection(from); 53 | switch (turn) 54 | { 55 | case LEFT: dir += 1; break; 56 | case DIRECT: dir += 2; break; 57 | case RIGHT: dir -=1; break; 58 | default: 59 | ASSERT(false); 60 | } 61 | if (dir < 0) 62 | dir += DirectionType_Size; 63 | if (dir >= DirectionType_Size) 64 | dir %= DirectionType_Size; 65 | return (DirectionType)dir; 66 | } 67 | 68 | Road* Cross::GetTurnDestination(const int& from, const Cross::TurnType& turn) const 69 | { 70 | return GetRoad(GetTurnDestinationDirection(from, turn)); 71 | } 72 | 73 | int Cross::GetTurnDestinationId(const int& from, const Cross::TurnType& turn) const 74 | { 75 | return GetRoadId(GetTurnDestinationDirection(from, turn)); 76 | } 77 | 78 | void Cross::SetNorthRoadId(const int& id) 79 | { 80 | m_northRoadId = id; 81 | m_directions[id] = NORTH; 82 | } 83 | 84 | void Cross::SetEasthRoadId(const int& id) 85 | { 86 | m_eastRoadId = id; 87 | m_directions[id] = EAST; 88 | } 89 | 90 | void Cross::SetSouthRoadId(const int& id) 91 | { 92 | m_southRoadId = id; 93 | m_directions[id] = SOUTH; 94 | } 95 | 96 | void Cross::SetWestRoadId(const int& id) 97 | { 98 | m_westRoadId = id; 99 | m_directions[id] = WEST; 100 | } 101 | 102 | void Cross::SetNorthRoad(Road* road) 103 | { 104 | ASSERT(road->GetId() == m_northRoadId); 105 | m_north = road; 106 | } 107 | 108 | void Cross::SetEasthRoad(Road* road) 109 | { 110 | ASSERT(road->GetId() == m_eastRoadId); 111 | m_east = road; 112 | } 113 | 114 | void Cross::SetSouthRoad(Road* road) 115 | { 116 | ASSERT(road->GetId() == m_southRoadId); 117 | m_south = road; 118 | } 119 | 120 | void Cross::SetWestRoad(Road* road) 121 | { 122 | ASSERT(road->GetId() == m_westRoadId); 123 | m_west = road; 124 | } 125 | -------------------------------------------------------------------------------- /CodeCraft2019/scenario/road.cpp: -------------------------------------------------------------------------------- 1 | #include "road.h" 2 | #include "cross.h" 3 | 4 | Road::Road() 5 | { 6 | ASSERT(false); 7 | } 8 | 9 | Road::Road(const int& origin, const int& id, const int& length, const int& limit, const int& lanes, const int& startCrossId, const int& endCrossId, const bool& isTwoWay) 10 | : m_originId(origin), m_id(id), m_length(length), m_limit(limit), m_lanes(lanes), m_startCrossId(startCrossId), m_endCrossId(endCrossId), m_isTwoWay(isTwoWay) 11 | , m_startCross(0), m_endCross(0) 12 | { } 13 | 14 | Road::~Road() 15 | { } 16 | 17 | void Road::SetLimit(const int& limit) 18 | { 19 | m_limit = limit; 20 | } 21 | 22 | void Road::SetLength(const int& length) 23 | { 24 | m_length = length; 25 | } 26 | 27 | void Road::SetStartCrossId(const int& id) 28 | { 29 | m_startCrossId = id; 30 | } 31 | 32 | void Road::SetEndCrossId(const int& id) 33 | { 34 | m_endCrossId = id; 35 | } 36 | 37 | void Road::SetStartCross(Cross* cross) 38 | { 39 | ASSERT(cross->GetId() == m_startCrossId); 40 | m_startCross = cross; 41 | } 42 | 43 | void Road::SetEndCross(Cross* cross) 44 | { 45 | ASSERT(cross->GetId() == m_endCrossId); 46 | m_endCross = cross; 47 | } 48 | -------------------------------------------------------------------------------- /CodeCraft2019/scenario/road.h: -------------------------------------------------------------------------------- 1 | #ifndef ROAD_H 2 | #define ROAD_H 3 | 4 | #include 5 | 6 | class Cross; 7 | 8 | class Road 9 | { 10 | private: 11 | int m_originId; 12 | int m_id; 13 | int m_length; 14 | int m_limit; 15 | int m_lanes; 16 | int m_startCrossId; 17 | int m_endCrossId; 18 | bool m_isTwoWay; 19 | 20 | Cross* m_startCross; 21 | Cross* m_endCross; 22 | 23 | public: 24 | Road(); 25 | Road(const int& origin, const int& id, const int& length, const int& limit, const int& lanes, const int& startCrossId, const int& endCrossId, const bool& isTwoWay); 26 | ~Road(); 27 | 28 | inline const int& GetOriginId() const; 29 | inline const int& GetId() const; 30 | inline const int& GetLength() const; 31 | inline const int& GetLimit() const; 32 | inline const int& GetLanes() const; 33 | inline const int& GetStartCrossId() const; 34 | inline const int& GetEndCrossId() const; 35 | inline const bool& GetIsTwoWay() const; 36 | 37 | void SetLimit(const int& limit); 38 | void SetLength(const int& length); 39 | void SetStartCrossId(const int& id); 40 | void SetEndCrossId(const int& id); 41 | void SetStartCross(Cross* cross); 42 | void SetEndCross(Cross* cross); 43 | Cross* GetStartCross() const; 44 | Cross* GetEndCross() const; 45 | Cross* GetPeerCross(const Cross* peer) const; 46 | bool CanStartFrom(const int& crossId) const; 47 | bool CanReachTo(const int& crossId) const; 48 | bool IsFromOrTo(const int& crossId) const; 49 | 50 | };//class Road 51 | 52 | 53 | 54 | 55 | 56 | /* 57 | * [inline functions] 58 | * it's not good to write code here, but we really need inline! 59 | */ 60 | 61 | #include "assert.h" 62 | 63 | inline const int& Road::GetOriginId() const 64 | { 65 | return m_originId; 66 | } 67 | 68 | inline const int& Road::GetId() const 69 | { 70 | return m_id; 71 | } 72 | 73 | inline const int& Road::GetLength() const 74 | { 75 | return m_length; 76 | } 77 | 78 | inline const int& Road::GetLimit() const 79 | { 80 | return m_limit; 81 | } 82 | 83 | inline const int& Road::GetLanes() const 84 | { 85 | return m_lanes; 86 | } 87 | 88 | inline const int& Road::GetStartCrossId() const 89 | { 90 | return m_startCrossId; 91 | } 92 | 93 | inline const int& Road::GetEndCrossId() const 94 | { 95 | return m_endCrossId; 96 | } 97 | 98 | inline const bool& Road::GetIsTwoWay() const 99 | { 100 | return m_isTwoWay; 101 | } 102 | 103 | inline Cross* Road::GetStartCross() const 104 | { 105 | ASSERT(m_startCross != 0); 106 | return m_startCross; 107 | } 108 | 109 | inline Cross* Road::GetEndCross() const 110 | { 111 | ASSERT(m_endCross != 0); 112 | return m_endCross; 113 | } 114 | 115 | inline Cross* Road::GetPeerCross(const Cross* peer) const 116 | { 117 | ASSERT(peer != 0); 118 | bool opposite = m_endCross == peer; 119 | ASSERT(opposite || m_startCross == peer); 120 | return opposite ? m_startCross : m_endCross; 121 | } 122 | 123 | inline bool Road::CanStartFrom(const int& crossId) const 124 | { 125 | return crossId == m_startCrossId || (m_isTwoWay && crossId == m_endCrossId); 126 | } 127 | 128 | inline bool Road::CanReachTo(const int& crossId) const 129 | { 130 | return crossId == m_endCrossId || (m_isTwoWay && crossId == m_startCrossId); 131 | } 132 | 133 | inline bool Road::IsFromOrTo(const int& crossId) const 134 | { 135 | bool ret = m_startCrossId == crossId; 136 | ASSERT(ret || m_endCrossId == crossId); 137 | return ret; 138 | } 139 | 140 | #endif 141 | -------------------------------------------------------------------------------- /CodeCraft2019/scenario/scenario.h: -------------------------------------------------------------------------------- 1 | #ifndef SCENARIO_H 2 | #define SCENARIO_H 3 | 4 | #include 5 | #include 6 | #include "car.h" 7 | #include "cross.h" 8 | #include "road.h" 9 | #include 10 | #include "map-array.h" 11 | #include "memory-pool.h" 12 | 13 | typedef unsigned int uint; 14 | 15 | class Scenario 16 | { 17 | private: 18 | std::vector m_cars; 19 | std::vector m_crosses; 20 | std::vector m_roads; 21 | std::vector m_garageSize; 22 | std::vector m_garageInnerIndex; 23 | 24 | std::map m_carsIndexMap; 25 | std::map m_crossesIndexMap; 26 | std::map m_roadsIndexMap; 27 | 28 | int m_vipCarsN; 29 | int m_presetCarsN; 30 | 31 | Scenario(); 32 | static Scenario Instance; 33 | 34 | bool HandleCar(std::istream& is); 35 | bool HandleCross(std::istream& is); 36 | bool HandleRoad(std::istream& is); 37 | bool HandleAnswer(std::istream& is); 38 | void DoInitialize(); 39 | void DoMoreInitialize(); 40 | 41 | public: 42 | ~Scenario(); 43 | 44 | static void Initialize(); 45 | static void Reset(); 46 | inline static const std::vector& Cars(); 47 | inline static const std::vector& Crosses(); 48 | inline static const std::vector& Roads(); 49 | inline static const int& GetVipCarsN(); 50 | inline static const int& GetPresetCarsN(); 51 | 52 | static const int& GetGarageSize(const int& id); 53 | static const int& GetGarageInnerIndex(const int& carId); 54 | static const int& MapCarOriginToIndex(const int& origin); 55 | static const int& MapCrossOriginToIndex(const int& origin); 56 | static const int& MapRoadOriginToIndex(const int& origin); 57 | 58 | };//class Scenario 59 | 60 | 61 | 62 | 63 | 64 | /* 65 | * [inline functions] 66 | * it's not good to write code here, but we really need inline! 67 | */ 68 | 69 | inline const std::vector& Scenario::Cars() 70 | { 71 | return Instance.m_cars; 72 | } 73 | 74 | inline const std::vector& Scenario::Crosses() 75 | { 76 | return Instance.m_crosses; 77 | } 78 | 79 | inline const std::vector& Scenario::Roads() 80 | { 81 | return Instance.m_roads; 82 | } 83 | 84 | inline const int& Scenario::GetVipCarsN() 85 | { 86 | return Instance.m_vipCarsN; 87 | } 88 | 89 | inline const int& Scenario::GetPresetCarsN() 90 | { 91 | return Instance.m_presetCarsN; 92 | } 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /CodeCraft2019/scheduler/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 查找当前目录下的所有源文件 2 | aux_source_directory(. DIR_SCHEDULER_SRCS) 3 | 4 | # 指定生成目标 5 | add_library(scheduler SHARED ${DIR_SCHEDULER_SRCS}) 6 | -------------------------------------------------------------------------------- /CodeCraft2019/scheduler/dead-lock-solver.h: -------------------------------------------------------------------------------- 1 | #ifndef DEAD_LOCK_SOLVER_H 2 | #define DEAD_LOCK_SOLVER_H 3 | 4 | #include "sim-scenario.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "memory-pool.h" 10 | #include "callback.h" 11 | 12 | class DeadLockSolver 13 | { 14 | public: 15 | DeadLockSolver(); 16 | void Initialize(const int& time, SimScenario& scenario); 17 | bool HandleDeadLock(int& time, SimScenario& scenario); 18 | bool IsCarTraceLockedInBackup(SimCar* car) const; //interface for keep trace, check it if you want to change path of car 19 | bool IsGarageLockedInBackup(const int& time) const; //check it when handle car get out garage 20 | const int& GetDeadLockTime() const; 21 | bool NeedUpdate(const int& time) const; 22 | void Backup(const int& time, const SimScenario& scenario); 23 | 24 | void SetSelectedRoadCallback(const Callback::Handle3, SimScenario&, const std::vector&, SimCar*>& cb); //return selection & is car trace handled 25 | void SetOperationDelaySingleRoad(const bool& enable); 26 | void SetCanChangedPresetN(const int& presetN); 27 | 28 | private: 29 | int DoHandleDeadLock(int& time, SimScenario& scenario); 30 | void UpdateFirstLockOnTime(const int& time); //update first lock on time to smaller one 31 | bool OperationDelay(const int& time, SimScenario& scenario, std::list& deadLockCars); 32 | bool OperationChangeTrace(const int& time, SimScenario& scenario, std::list& cars); 33 | 34 | MemoryPool m_memoryPool; 35 | std::map m_backups; //backup of scenario, used for time leap 36 | 37 | int m_deadLockTime; //the time of dead lock 38 | int m_firstLockOnTime; //the time of world line changed after operations, El Psy Congroo! used for time leap 39 | int* m_deadLockTraceIndexes; //for recover to dead lock, need to keep the trace 40 | int m_depth; //depth of dead lock solver 41 | bool m_actived; //flag: is this solver solving the dead lock? 42 | DeadLockSolver* m_subSolver; //create a sub solver when dead lock occurs in smaller time than before 43 | 44 | bool m_isSingleRoadDelay; 45 | int m_canChangedPresetN; 46 | std::map< int, std::set > m_deadLockMemory; //car id -> used next road id 47 | Callback::Handle3, SimScenario&, const std::vector&, SimCar*> m_selectedRoadCallback; //for selecting new road to break dead lock 48 | 49 | };//class DeadLockSolver 50 | 51 | #endif -------------------------------------------------------------------------------- /CodeCraft2019/scheduler/garage-counter.h: -------------------------------------------------------------------------------- 1 | #ifndef GARAGE_COUNTER 2 | #define GARAGE_COUNTER 3 | 4 | #include "sim-scenario.h" 5 | #include "callback.h" 6 | 7 | /* for keeping number of cars in garage in balance */ 8 | class GarageCounter 9 | { 10 | public: 11 | void Initialize(SimScenario& scenario); 12 | void Update(const int& time, SimScenario& scenario); 13 | void HandleBeforeGarageDispatch(const int& time, SimScenario& scenario); 14 | bool CanDispatch(const int& time, SimScenario& scenario, SimCar* car) const; 15 | void NotifyDispatch(const int& garageId); 16 | 17 | private: 18 | bool m_isScheduling; 19 | 20 | int GetCangoCarsN(const int& time, const int& garageId) const; 21 | 22 | /* quantity limit */ 23 | std::vector m_dispatchCarsNInEachTime; 24 | std::vector m_carsN; 25 | std::vector m_leftCarsN; 26 | 27 | /* evaluation */ 28 | std::vector< std::list > m_bestCars; 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /CodeCraft2019/scheduler/load-state.cpp: -------------------------------------------------------------------------------- 1 | #include "load-state.h" 2 | #include "assert.h" 3 | #include "log.h" 4 | #include "scenario.h" 5 | 6 | LoadState::TimeSlice::TimeSlice() 7 | : Time(-1), Load(0) 8 | { } 9 | 10 | LoadState::TimeSlice::TimeSlice(const int& time, const int& load) 11 | : Time(time), Load(load) 12 | { } 13 | 14 | void LoadState::Update(const int& time, SimScenario& scenario) 15 | { 16 | if (time <= 0) 17 | return ; 18 | if (m_timeLoad.size() > 0) 19 | ASSERT(m_timeLoad.back().Time == time - 1); 20 | m_timeLoad.push_back(TimeSlice(time, scenario.GetOnRoadCarsN())); 21 | for (uint i = 0; i < scenario.Roads().size(); ++i) 22 | { 23 | SimRoad* road = scenario.Roads()[i]; 24 | int lanes = road->GetRoad()->GetLanes(); 25 | int load = 0; 26 | int loadOpposite = 0; 27 | for (int i = 0; i < lanes * 2; ++i) 28 | { 29 | bool opposite = i >= lanes; 30 | if (opposite && !road->GetRoad()->GetIsTwoWay()) 31 | break; 32 | (opposite ? loadOpposite : load) += road->GetCars((i % lanes) + 1, opposite).size(); 33 | } 34 | m_spaceLoad[std::make_pair(road->GetRoad()->GetId(), false)] += load; 35 | m_spaceLoad[std::make_pair(road->GetRoad()->GetId(), true)] += loadOpposite; 36 | } 37 | } 38 | 39 | void LoadState::Print(SimScenario& scenario) const 40 | { 41 | ASSERT(m_timeLoad.size() > 0); 42 | const int& time = m_timeLoad.back().Time; 43 | LOG ("Space load : "); 44 | int capacityTotal = 0; 45 | for (uint i = 0; i < scenario.Roads().size(); ++i) 46 | { 47 | SimRoad* road = scenario.Roads()[i]; 48 | int lanes = road->GetRoad()->GetLanes(); 49 | int capacity = lanes * road->GetRoad()->GetLength(); 50 | capacityTotal += road->GetRoad()->GetIsTwoWay() ? capacity * 2 : capacity; 51 | { //print 52 | auto find0 = m_spaceLoad.find(std::make_pair(road->GetRoad()->GetId(), false)); 53 | ASSERT(find0 != m_spaceLoad.end()); 54 | LOG ("road " << road->GetRoad()->GetId() 55 | << " from " << road->GetRoad()->GetStartCrossId() 56 | << " to " << road->GetRoad()->GetEndCrossId() 57 | << " lanes " << lanes 58 | << " capacity " << capacity 59 | << " load " << (find0->second * 1.0 / time / capacity) 60 | ); 61 | } 62 | if (!road->GetRoad()->GetIsTwoWay()) 63 | continue; 64 | { //print opposite 65 | auto find1 = m_spaceLoad.find(std::make_pair(road->GetRoad()->GetId(), true)); 66 | ASSERT(find1 != m_spaceLoad.end()); 67 | LOG ("road " << road->GetRoad()->GetId() 68 | << " from " << road->GetRoad()->GetEndCrossId() 69 | << " to " << road->GetRoad()->GetStartCrossId() 70 | << " lanes " << lanes 71 | << " capacity " << capacity 72 | << " load " << (find1->second * 1.0 / time / capacity) 73 | ); 74 | } 75 | } 76 | LOG ("Time load (" << time << ") : "); 77 | for (auto ite = m_timeLoad.begin(); ite != m_timeLoad.end(); ite++) 78 | { 79 | LOG ("time " << ite->Time 80 | << " load " << (ite->Load * 1.0 / capacityTotal) 81 | ); 82 | } 83 | } -------------------------------------------------------------------------------- /CodeCraft2019/scheduler/load-state.h: -------------------------------------------------------------------------------- 1 | #ifndef LOAD_STATE_H 2 | #define LOAD_STATE_H 3 | 4 | #include "sim-scenario.h" 5 | #include 6 | #include "pmap.h" 7 | 8 | class LoadState 9 | { 10 | public: 11 | struct TimeSlice 12 | { 13 | TimeSlice(); 14 | TimeSlice(const int& time, const int& load); 15 | int Time; 16 | int Load; 17 | };//struct TimeSlice 18 | 19 | void Update(const int& time, SimScenario& scenario); //can not drop back or jump skip any time 20 | void Print(SimScenario& scenario) const; 21 | 22 | private: 23 | std::list m_timeLoad; 24 | std::pmap m_spaceLoad; //road id & is opposite -> load state 25 | 26 | };//class LoadState 27 | 28 | #endif -------------------------------------------------------------------------------- /CodeCraft2019/scheduler/scheduler-answer.cpp: -------------------------------------------------------------------------------- 1 | #include "scheduler-answer.h" 2 | #include "file-reader.h" 3 | #include "assert.h" 4 | #include "config.h" 5 | #include "log.h" 6 | #include "simulator.h" 7 | 8 | void SchedulerAnswer::DoInitialize(SimScenario& scenario) 9 | { 10 | Simulator::SetEnableCheater(false); 11 | m_scenario = &scenario; 12 | LOG("read information of answer from " << Config::PathResult); 13 | FileReader reader; 14 | bool result = reader.Read(Config::PathResult.c_str(), Callback::Create(&SchedulerAnswer::HandleAnswer, this)); 15 | ASSERT(result); 16 | } 17 | 18 | bool SchedulerAnswer::HandleAnswer(std::istream& is) 19 | { 20 | char c; 21 | is >> c; 22 | if (c == '#') 23 | return true; 24 | if (c != '(') 25 | ASSERT(false); 26 | int argv[2]; 27 | for (int i = 0; i < 2; ++i) 28 | { 29 | argv[i] = -1; 30 | is >> argv[i] >> c; 31 | ASSERT_MSG(c == ',', "char=" << c << " position=" << i); 32 | } 33 | ASSERT(argv[0] >= 0 && argv[1] >= 0); 34 | int id = Scenario::MapCarOriginToIndex(argv[0]); 35 | SimCar* car = m_scenario->Cars()[id]; 36 | 37 | ASSERT(car != 0); 38 | if (car->GetCar()->GetIsPreset()) 39 | { 40 | if (argv[1] == car->GetRealTime()) //path changed 41 | { 42 | car->SetCanChangePath(true); 43 | } 44 | else //time changed 45 | { 46 | car->SetCanChangeRealTime(true); 47 | car->SetRealTime(argv[1]); 48 | } 49 | car->GetTrace().Clear(); 50 | } 51 | else 52 | { 53 | car->SetRealTime(argv[1]); 54 | } 55 | int path; 56 | while (true) 57 | { 58 | path = -1; 59 | is >> path >> c; 60 | ASSERT(c == ',' || c == ')'); 61 | ASSERT(path >= 0); 62 | car->GetTrace().AddToTail(Scenario::MapRoadOriginToIndex(path)); 63 | if (c == ')') 64 | break; 65 | } 66 | 67 | return true; 68 | } 69 | -------------------------------------------------------------------------------- /CodeCraft2019/scheduler/scheduler-answer.h: -------------------------------------------------------------------------------- 1 | #ifndef SCHEDULER_ANSWER_H 2 | #define SCHEDULER_ANSWER_H 3 | 4 | #include "scheduler.h" 5 | #include 6 | 7 | class SchedulerAnswer : public Scheduler 8 | { 9 | protected: 10 | virtual void DoInitialize(SimScenario& scenario) override; 11 | 12 | private: 13 | SimScenario* m_scenario; 14 | bool HandleAnswer(std::istream& is); 15 | 16 | };//class SchedulerAnswer 17 | 18 | #endif -------------------------------------------------------------------------------- /CodeCraft2019/scheduler/scheduler-floyd.h: -------------------------------------------------------------------------------- 1 | #ifndef SCHEDULER_FLOYD_H 2 | #define SCHEDULER_FLOYD_H 3 | 4 | #include "scheduler.h" 5 | #include 6 | #include "dead-lock-solver.h" 7 | #include "garage-counter.h" 8 | 9 | class SchedulerFloyd : public Scheduler 10 | { 11 | public: 12 | SchedulerFloyd(); 13 | 14 | void SetLengthWeight(double v); 15 | void SetCarNumWeight(double v); 16 | void SetLanesNumWeight(double v); 17 | void SetCarLimit(double v); 18 | void SetPresetVipTracePreloadWeight(double v); 19 | void SetLastPresetVipCarEstimateArriveTime(int v); 20 | void SetIsEnableVipWeight(bool v); 21 | void SetIsOptimalForLastVipCar(bool v); 22 | void SetIsLimitedByRoadSizeCount(bool v); 23 | void SetIsFasterAtEndStep(bool v); 24 | void SetIsLessCarAfterDeadLock(bool v); 25 | void SetIsDropBackByDijkstra(bool v); 26 | void SetIsVipCarDispatchFree(bool v); 27 | void SetVipCarOptimalStartTime(int v); 28 | void HandleSimCarScheduled(const SimCar* car); 29 | void SetLooserCarsNumOnRoadLimit(int v); 30 | protected: 31 | virtual void DoInitialize(SimScenario& scenario) override; 32 | virtual void DoUpdate(int& time, SimScenario& scenario) override; 33 | virtual void DoHandleBeforeGarageDispatch(const int& time, SimScenario& scenario) override; 34 | virtual void DoHandleGetoutGarage(const int& time, SimScenario& scenario, SimCar* car) override; 35 | virtual void DoHandleBecomeFirstPriority(const int& time, SimScenario& scenario, SimCar* car) override; 36 | virtual void DoHandleResult(int& time, SimScenario& scenario, Simulator::UpdateResult& result) override; 37 | 38 | private: 39 | /* algorithm floyde */ 40 | std::vector< std::vector > m_weightCrossToCross; 41 | std::vector< std::vector > m_connectionCrossToCross; 42 | std::vector< std::vector< std::vector > > m_minPathCrossToCross; 43 | 44 | /* time weight */ 45 | std::vector< std::vector< std::pair > > m_timeWeightForRoad; 46 | void UpdateTimeWeight(SimCar* car); 47 | bool UpdateCarTraceByDijkstraWithTimeWeight(const int& time, const SimScenario& scenario, const std::vector& validFirstHop, SimCar* car) const; 48 | 49 | std::vector< std::pair > m_appointOnRoadCounter; 50 | 51 | /* for dispatching cars */ 52 | std::set m_notArrivedProtectedCars; 53 | //std::vector< std::pair > aver; 54 | std::vector< std::pair > m_garageMinSpeed; 55 | std::vector< std::pair > m_garageTraceSizeLimit; 56 | std::vector m_garagePlanCarNum; 57 | GarageCounter m_garageDispatchCounter; 58 | 59 | /* for solving dead lock */ 60 | DeadLockSolver m_deadLockSolver; 61 | void HandleGoOnNewRoad(const SimCar* car, Road* oldRoad); 62 | std::pair SelectBestRoad(SimScenario& scenario, const std::vector& list, SimCar* car); 63 | 64 | /* private interfaces */ 65 | void HandlePresetCars(SimScenario& scenario, const int& canChangesN); 66 | void CalculateWeight(SimScenario& scenario); 67 | void RefreshNotArrivedPresetCars(SimScenario& scenario); 68 | bool UpdateCarTraceByDijkstra(const int& time, const SimScenario& scenario, SimCar* car) const; 69 | bool UpdateCarTraceByDijkstra(const int& time, const SimScenario& scenario, const std::vector& validFirstHop, SimCar* car) const; 70 | 71 | 72 | int m_updateInterval; 73 | 74 | /* weight */ 75 | double m_lengthWeight; 76 | double m_carNumWeight; 77 | double m_lanesNumWeight; 78 | 79 | /* dispatch limit */ 80 | double m_carLimit; 81 | double m_carLimitLooser; 82 | double m_carLimitTighter; 83 | double m_presetVipTracePreloadWeight; 84 | int m_looserCarsNumOnRoadLimit; 85 | int m_lastVipCarRealTime; 86 | int m_lastPresetVipCarEstimateArriveTime; 87 | int m_vipCarOptimalStartTime; 88 | int m_vipCarTraceProtectedStartTime; 89 | 90 | /* switchers */ 91 | bool m_isEnableVipWeight; 92 | bool m_isOptimalForLastVipCar; 93 | bool m_isLimitedByRoadSizeCount; 94 | bool m_isFasterAtEndStep; 95 | bool m_isLessCarAfterDeadLock; 96 | bool m_isDropBackByDijkstra; 97 | bool m_isVipCarDispatchFree; 98 | 99 | /* temporary variables */ 100 | double m_roadCapacityAverage; 101 | int m_carsNumOnRoadLimit; 102 | 103 | };//class SchedulerFloyd 104 | 105 | #endif -------------------------------------------------------------------------------- /CodeCraft2019/scheduler/scheduler-time-weight.h: -------------------------------------------------------------------------------- 1 | #ifndef SCHEDULER_TIMEWEIGHT_H 2 | #define SCHEDULER_TIMEWEIGHT_H 3 | 4 | #include "scheduler.h" 5 | #include 6 | #include 7 | #include "dead-lock-solver.h" 8 | 9 | class SchedulerTimeWeight : public Scheduler 10 | { 11 | public: 12 | SchedulerTimeWeight(); 13 | 14 | protected: 15 | virtual void DoInitialize(SimScenario& scenario) override; 16 | virtual void DoUpdate(int& time, SimScenario& scenario) override; 17 | virtual void DoHandleResult(int& time, SimScenario& scenario, Simulator::UpdateResult& result) override; 18 | virtual void DoHandleBecomeFirstPriority(const int& time, SimScenario& scenario, SimCar* car) override; 19 | 20 | private: 21 | /* factor array */ 22 | static void InitilizeConfidence(); 23 | //static std::vector< std::vector< std::vector > > m_confidence; //confidence(deltaT, a, b) : binomial(N = a, k = b) 24 | static std::vector< std::vector< std::vector > > m_collectionWeight; //interface for update w'(a, b, delataT( <= b)) 25 | //static std::vector< std::pair > m_significantRange; //deltaT -> start, length 26 | static int m_maxValidRange; 27 | 28 | int m_updateInterval; 29 | std::vector< std::vector > m_carList; 30 | DeadLockSolver m_deadLockSolver; 31 | std::pair SelectBestRoad(SimScenario& scenario, const std::vector& list, SimCar* car); 32 | 33 | /* time weight */ 34 | int m_carWeightStartTime; 35 | std::vector< std::vector< std::pair > > m_carWeight; 36 | std::vector m_roadWeight; //basic weight 37 | std::vector m_roadCapacity; //capacity limit 38 | std::vector< std::pair > m_threshold; //number of lane -> ignore threshold & ban threshold 39 | std::vector< std::vector > m_expectedWeight; //decide if need change trace 40 | std::vector< std::vector< std::pair< std::list, int> > > m_bestTrace; //start -> end : trace & length 41 | 42 | void InitializeBestTraceByFloyd(); 43 | void InitializeCarTraceByBeastTrace(SimScenario& scenario); 44 | void InitializeCarTraceByDijkstra(SimScenario& scenario); 45 | bool IsAppropriateToDispatch(const int& time, SimCar* car, SimScenario& scenario) const; 46 | 47 | void UpdateTimeWeight(const int& time, SimScenario& scenario); 48 | void UpdateTimeWeightByRoadAndTime(const int& time, const int& roadId, const bool& dir, int startTime, int leaveTime, const bool& isDecrease); 49 | void UpdateTimeWeightForEachCar(const int& time, SimCar* car, const bool& isDecrease = false); 50 | void UpdateCurrentWeightByScenario(const int& time, SimScenario& scenario); 51 | bool UpdateCarTraceByDijkstraWithTimeWeight(const int& time, SimScenario& scenario, SimCar* car, const std::vector& banedFirstHop = std::vector()) const; 52 | 53 | }; 54 | 55 | #endif -------------------------------------------------------------------------------- /CodeCraft2019/scheduler/scheduler.h: -------------------------------------------------------------------------------- 1 | #ifndef SCHEDULER_H 2 | #define SCHEDULER_H 3 | 4 | #include "sim-scenario.h" 5 | #include "simulator.h" 6 | #include "map-array.h" 7 | #include "memory-pool.h" 8 | #include "timer.h" 9 | #include "load-state.h" 10 | #include 11 | 12 | class Scheduler 13 | { 14 | protected: 15 | Scheduler(); 16 | 17 | public: 18 | virtual ~Scheduler(); 19 | void EnableTrace(const std::string& traceFile); 20 | 21 | void Initialize(SimScenario& scenario); 22 | void Update(int& time, SimScenario& scenario); //before simulator update 23 | void HandleBeforeGarageDispatch(const int& time, SimScenario& scenario); 24 | void HandleGetoutGarage(const int& time, SimScenario& scenario, SimCar* car); 25 | void HandleBecomeFirstPriority(const int& time, SimScenario& scenario, SimCar* car); 26 | void HandleResult(int& time, SimScenario& scenario, Simulator::UpdateResult& result); //after simulator update 27 | 28 | protected: 29 | virtual void DoInitialize(SimScenario& scenario); 30 | virtual void DoUpdate(int& time, SimScenario& scenario); 31 | virtual void DoHandleBeforeGarageDispatch(const int& time, SimScenario& scenario); 32 | virtual void DoHandleGetoutGarage(const int& time, SimScenario& scenario, SimCar* car); 33 | virtual void DoHandleBecomeFirstPriority(const int& time, SimScenario& scenario, SimCar* car); 34 | virtual void DoHandleResult(int& time, SimScenario& scenario, Simulator::UpdateResult& result); 35 | 36 | MemoryPool m_memoryPool; 37 | 38 | private: 39 | /* for statistic */ 40 | LoadState m_loadState; 41 | 42 | std::ofstream* m_traceFile; 43 | 44 | };//class Scheduler 45 | 46 | #endif -------------------------------------------------------------------------------- /CodeCraft2019/simulation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 查找当前目录下的所有源文件 2 | aux_source_directory(. DIR_SIMULATION_SRCS) 3 | 4 | # 指定生成目标 5 | add_library(simulation SHARED ${DIR_SIMULATION_SRCS}) 6 | -------------------------------------------------------------------------------- /CodeCraft2019/simulation/score-calculator.cpp: -------------------------------------------------------------------------------- 1 | #include "score-calculator.h" 2 | #include "scenario.h" 3 | #include 4 | #include "assert.h" 5 | #include "log.h" 6 | 7 | struct ScoreStatistic 8 | { 9 | int FirstPlanTime, LastPlanTime; 10 | int MinSpeed, MaxSpeed; 11 | std::set StartDistribution, EndDistribution; 12 | 13 | ScoreStatistic(); 14 | void Update(const Car* car); 15 | bool IsValid() const; 16 | 17 | };//struct ScoreStatistic 18 | 19 | ScoreStatistic::ScoreStatistic() 20 | : FirstPlanTime(-1), LastPlanTime(-1) 21 | , MinSpeed(-1), MaxSpeed(-1) 22 | { } 23 | 24 | void ScoreStatistic::Update(const Car* car) 25 | { 26 | const int& planTime = car->GetPlanTime(); 27 | const int& speed = car->GetMaxSpeed(); 28 | if (FirstPlanTime < 0 || planTime < FirstPlanTime) 29 | FirstPlanTime = planTime; 30 | if (LastPlanTime < 0 || planTime > LastPlanTime) 31 | LastPlanTime = planTime; 32 | if (MinSpeed < 0 || speed < MinSpeed) 33 | MinSpeed = speed; 34 | if (MaxSpeed < 0 || speed > MaxSpeed) 35 | MaxSpeed = speed; 36 | StartDistribution.insert(car->GetFromCrossId()); 37 | EndDistribution.insert(car->GetToCrossId()); 38 | } 39 | 40 | bool ScoreStatistic::IsValid() const 41 | { 42 | return FirstPlanTime >= 0 && LastPlanTime >= 0 43 | && MinSpeed > 0 && MaxSpeed > 0 44 | && StartDistribution.size() > 0 && EndDistribution.size() > 0; 45 | } 46 | 47 | ScoreCalculator::ScoreResult::ScoreResult() 48 | : Score(-1), Total(-1), Vip(false) 49 | { } 50 | 51 | ScoreCalculator::ScoreCalculator() 52 | { } 53 | 54 | ScoreCalculator ScoreCalculator::Instance; 55 | 56 | double inline Division(const double& a, const double& b) 57 | { 58 | return int(a / b * 1e5) / 1e5; 59 | } 60 | 61 | ScoreCalculator::ScoreResult ScoreCalculator::DoCalculate(const SimScenario& scenario) const 62 | { 63 | ScoreResult result; 64 | ScoreStatistic all, vip; 65 | for (auto ite = Scenario::Cars().begin(); ite != Scenario::Cars().end(); ++ite) 66 | { 67 | const Car* car = *ite; 68 | if (car->GetIsVip()) 69 | { 70 | result.Vip = true; 71 | vip.Update(car); 72 | } 73 | all.Update(car); 74 | } 75 | ASSERT(all.IsValid()); 76 | ASSERT(!result.Vip || vip.IsValid()); 77 | double factor = 0 78 | + Division(Division(all.MaxSpeed, all.MinSpeed), Division(vip.MaxSpeed, vip.MinSpeed)) 79 | + Division(Division(all.LastPlanTime, all.FirstPlanTime), Division(vip.LastPlanTime, vip.FirstPlanTime)) 80 | + Division(all.StartDistribution.size(), vip.StartDistribution.size()) 81 | + Division(all.EndDistribution.size(), vip.EndDistribution.size()); 82 | double factorA = Division(Scenario::Cars().size(), Scenario::GetVipCarsN()) * 0.05 + factor * 0.2375; 83 | double factorB = Division(Scenario::Cars().size(), Scenario::GetVipCarsN()) * 0.8 + factor * 0.05; 84 | result.Score = factorA * scenario.GetVipScheduledTime() + scenario.GetScheduledTime() + 0.5; 85 | result.Total = factorB * scenario.GetVipTotalCompleteTime() + scenario.GetTotalCompleteTime() + 0.5; 86 | LOG("factor o = " << factor << ", a = " << factorA << ", b = " << factorB); 87 | LOG("vip result : score " << scenario.GetVipScheduledTime() 88 | << " total " << scenario.GetVipTotalCompleteTime()); 89 | LOG("origin result : score " << scenario.GetScheduledTime() 90 | << " total " << scenario.GetTotalCompleteTime()); 91 | LOG("final result : score " << result.Score 92 | << " total " << result.Total); 93 | return result; 94 | } 95 | 96 | ScoreCalculator::ScoreResult ScoreCalculator::Calculate(const SimScenario& scenario) 97 | { 98 | return Instance.DoCalculate(scenario); 99 | } -------------------------------------------------------------------------------- /CodeCraft2019/simulation/score-calculator.h: -------------------------------------------------------------------------------- 1 | #ifndef SCORE_CALCULATOR_H 2 | #define SCORE_CALCULATOR_H 3 | 4 | #include "sim-scenario.h" 5 | 6 | class ScoreCalculator 7 | { 8 | public: 9 | struct ScoreResult 10 | { 11 | int Score; 12 | int Total; 13 | bool Vip; //contain VIP car 14 | 15 | ScoreResult(); 16 | 17 | };//struct Socre 18 | 19 | private: 20 | ScoreCalculator(); 21 | static ScoreCalculator Instance; 22 | 23 | ScoreResult DoCalculate(const SimScenario& scenario) const; 24 | 25 | public: 26 | static ScoreResult Calculate(const SimScenario& scenario); 27 | 28 | };//class ScoreCalculator 29 | 30 | #endif -------------------------------------------------------------------------------- /CodeCraft2019/simulation/sim-road.cpp: -------------------------------------------------------------------------------- 1 | #include "sim-road.h" 2 | #include "assert.h" 3 | #include "sim-scenario.h" 4 | #include 5 | 6 | SimRoad::SimRoad() 7 | { 8 | ASSERT(false); 9 | } 10 | 11 | SimRoad::SimRoad(Road* road) 12 | : m_road(road), m_carN(0) 13 | { 14 | ASSERT(road != 0); 15 | m_carSize = road->GetLanes() * (road->GetIsTwoWay() ? 2 : 1); 16 | m_cars.resize(m_carSize); 17 | for (int i = 0; i < m_carSize; ++i) 18 | m_cars[i].reserve(m_road->GetLength()); 19 | } 20 | 21 | void SimRoad::Reset() 22 | { 23 | for (int i = 0; i < m_carSize; ++i) 24 | m_cars[i].clear(); 25 | m_carN = 0; 26 | } 27 | 28 | void SimRoad::RunIn(Car* car, const int& lane, const bool& opposite) 29 | { 30 | GetCarsImpl(lane, opposite).push_back(car); 31 | ++m_carN; 32 | } 33 | 34 | Car* SimRoad::RunOut(const int& lane, const bool& opposite) 35 | { 36 | auto& cars = GetCarsImpl(lane, opposite); 37 | ASSERT(cars.size() > 0); 38 | Car* ret = *cars.begin(); 39 | cars.erase(cars.begin()); 40 | --m_carN; 41 | return ret; 42 | } -------------------------------------------------------------------------------- /CodeCraft2019/simulation/sim-road.h: -------------------------------------------------------------------------------- 1 | #ifndef SIM_ROAD_H 2 | #define SIM_ROAD_H 3 | 4 | #include "road.h" 5 | #include "car.h" 6 | #include 7 | 8 | class SimScenario; 9 | 10 | class SimRoad 11 | { 12 | private: 13 | Road* m_road; 14 | int m_carSize; 15 | int m_carN; 16 | std::vector< std::vector > m_cars; //lane -> car list 17 | 18 | /* implements */ 19 | inline const std::vector& GetCarsImpl(const int& lane) const; 20 | inline const std::vector& GetCarsOppositeImpl(const int& lane) const; 21 | inline const std::vector& GetCarsImpl(const int& lane, bool opposite) const; 22 | inline std::vector& GetCarsImpl(const int& lane, bool opposite); 23 | 24 | public: 25 | SimRoad(); 26 | SimRoad(Road* road); 27 | 28 | void Reset(); 29 | inline Road* GetRoad() const; 30 | 31 | /* const interfaces */ 32 | inline const int& GetCarN() const; 33 | inline const std::vector& GetCars(const int& lane) const; //lane : [1~number of lanes] 34 | inline const std::vector& GetCarsOpposite(const int& lane) const; 35 | inline const std::vector& GetCars(const int& lane, bool opposite) const; //opposite : [true] means end->start; [false] means start->end 36 | inline const std::vector& GetCarsTo(const int& lane, const int& crossId) const; 37 | inline const std::vector& GetCarsFrom(const int& lane, const int& crossId) const; 38 | 39 | /* functions for running a car & changing the list */ 40 | void RunIn(Car* car, const int& lane, const bool& opposite); 41 | Car* RunOut(const int& lane, const bool& opposite); 42 | 43 | };//class SimRoad 44 | 45 | 46 | 47 | 48 | 49 | /* 50 | * [inline functions] 51 | * it's not good to write code here, but we really need inline! 52 | */ 53 | 54 | #include "assert.h" 55 | 56 | inline Road* SimRoad::GetRoad() const 57 | { 58 | return m_road; 59 | } 60 | 61 | inline const int& SimRoad::GetCarN() const 62 | { 63 | return m_carN; 64 | } 65 | 66 | inline const std::vector& SimRoad::GetCarsImpl(const int& lane) const 67 | { 68 | ASSERT(lane > 0 && lane <= m_road->GetLanes()); 69 | ASSERT(lane <= m_carSize); 70 | return m_cars[lane - 1]; 71 | } 72 | 73 | inline const std::vector& SimRoad::GetCarsOppositeImpl(const int& lane) const 74 | { 75 | ASSERT(lane > 0 && lane <= m_road->GetLanes()); 76 | ASSERT(m_road->GetLanes() + lane <= m_carSize); 77 | return m_cars[m_road->GetLanes() + lane - 1]; 78 | } 79 | 80 | inline const std::vector& SimRoad::GetCarsImpl(const int& lane, bool opposite) const 81 | { 82 | return opposite ? GetCarsOppositeImpl(lane) : GetCarsImpl(lane); 83 | } 84 | 85 | inline std::vector& SimRoad::GetCarsImpl(const int& lane, bool opposite) 86 | { 87 | if (opposite) 88 | { 89 | ASSERT(lane > 0 && lane <= m_road->GetLanes()); 90 | ASSERT(m_road->GetLanes() + lane <= m_carSize); 91 | return m_cars[m_road->GetLanes() + lane - 1]; 92 | } 93 | ASSERT(lane > 0 && lane <= m_road->GetLanes()); 94 | ASSERT(lane <= m_carSize); 95 | return m_cars[lane - 1]; 96 | } 97 | 98 | inline const std::vector& SimRoad::GetCars(const int& lane) const 99 | { 100 | return GetCarsImpl(lane); 101 | } 102 | 103 | inline const std::vector& SimRoad::GetCarsOpposite(const int& lane) const 104 | { 105 | return GetCarsOppositeImpl(lane); 106 | } 107 | 108 | inline const std::vector& SimRoad::GetCars(const int& lane, bool opposite) const 109 | { 110 | return opposite ? GetCarsOppositeImpl(lane) : GetCarsImpl(lane); 111 | } 112 | 113 | inline const std::vector& SimRoad::GetCarsTo(const int& lane, const int& crossId) const 114 | { 115 | return GetCars(lane, m_road->IsFromOrTo(crossId)); 116 | } 117 | 118 | inline const std::vector& SimRoad::GetCarsFrom(const int& lane, const int& crossId) const 119 | { 120 | return GetCars(lane, !m_road->IsFromOrTo(crossId)); 121 | } 122 | 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /CodeCraft2019/simulation/sim-scenario.h: -------------------------------------------------------------------------------- 1 | #ifndef SIM_SCENARIO_H 2 | #define SIM_SCENARIO_H 3 | 4 | #include "sim-car.h" 5 | #include "sim-road.h" 6 | #include 7 | #include 8 | #include "scenario.h" 9 | 10 | class SimScenario 11 | { 12 | protected: 13 | std::vector< std::vector > m_simGarages; //indexed by cross id 14 | std::vector m_simRoads; 15 | std::vector m_simCars; 16 | unsigned int m_reachCarsN; 17 | unsigned int m_carOnRoadN; 18 | unsigned int m_carInGarageN; 19 | /* for calculating score */ 20 | int m_scheduledTime; 21 | int m_totalCompleteTime; 22 | int m_vipFirstPlanTime; 23 | int m_vipLastReachTime; 24 | int m_vipTotalCompleteTime; 25 | 26 | public: 27 | SimScenario(bool onlyPreset = false); 28 | virtual ~SimScenario(); 29 | SimScenario(const SimScenario& o); 30 | SimScenario& operator = (const SimScenario& o); 31 | 32 | const int& GetScheduledTime() const; 33 | const int& GetTotalCompleteTime() const; 34 | int GetVipScheduledTime() const; 35 | const int& GetVipTotalCompleteTime() const; 36 | 37 | inline const std::vector< std::vector >& Garages() const; 38 | inline const std::vector& Roads() const; 39 | inline const std::vector& Cars() const; 40 | inline const unsigned int& GetCarInGarageN() const; 41 | inline const unsigned int& GetReachCarsN() const; 42 | inline int GetOnRoadCarsN() const; 43 | 44 | void NotifyCarGetoutOnRoad(const int& time, const SimCar* car); 45 | void NotifyCarReachGoal(const int& time, const SimCar* car); 46 | bool IsComplete() const; 47 | 48 | SimCar* AddCar(Car* car); 49 | void RemoveCar(SimCar* car); 50 | //void ReplaceGarage(const std::vector< std::vector >& garage); 51 | void ResetScenario(); 52 | 53 | void SaveToFile() const; 54 | void SaveToFile(const char* file) const; 55 | 56 | private: 57 | void Clear(); 58 | 59 | };//class SimScenario 60 | 61 | 62 | 63 | 64 | 65 | /* 66 | * [inline functions] 67 | * it's not good to write code here, but we really need inline! 68 | */ 69 | 70 | inline const std::vector< std::vector >& SimScenario::Garages() const 71 | { 72 | return m_simGarages; 73 | } 74 | 75 | inline const std::vector& SimScenario::Roads() const 76 | { 77 | return m_simRoads; 78 | } 79 | 80 | inline const std::vector& SimScenario::Cars() const 81 | { 82 | return m_simCars; 83 | } 84 | 85 | inline const unsigned int& SimScenario::GetCarInGarageN() const 86 | { 87 | return m_carInGarageN; 88 | } 89 | 90 | inline const unsigned int& SimScenario::GetReachCarsN() const 91 | { 92 | return m_reachCarsN; 93 | } 94 | 95 | inline int SimScenario::GetOnRoadCarsN() const 96 | { 97 | return m_carOnRoadN; 98 | } 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /CodeCraft2019/simulation/simulator.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMULATOR_H 2 | #define SIMULATOR_H 3 | 4 | #include "sim-scenario.h" 5 | #include 6 | 7 | class Scheduler; 8 | 9 | class Simulator 10 | { 11 | public: 12 | struct UpdateResult 13 | { 14 | bool Conflict; 15 | 16 | };//struct UpdateResult 17 | 18 | private: 19 | Simulator(); 20 | 21 | Scheduler* m_scheduler; 22 | 23 | int m_scheduledCarsN; //counter 24 | int m_reachedCarsN; //counter 25 | bool m_conflictFlag; //for checking conflict, reset in each schedule cycle 26 | std::vector< std::vector > m_carsInGarage; //cross id -> vector of garage cars 27 | std::vector< std::vector > m_vipCarsInGarage; //cross id -> vector of garage cars 28 | std::vector< std::pair > m_firstPriorities; 29 | 30 | /* for handle callback */ 31 | void HandleUpdateState(const SimCar::SimState& state); 32 | 33 | /* for notify scheduler */ 34 | void NotifyFirstPriority(const int& time, SimScenario& scenario, SimCar* car) const; 35 | 36 | /* for notify simulator itself */ 37 | void NotifyScheduleStart(); 38 | void NotifyScheduleCycleStart(); 39 | bool GetIsDeadLock(SimScenario& scenario) const; 40 | bool GetIsCompleted(SimScenario& scenario) const; 41 | 42 | /* internal functions */ 43 | int GetPositionInNextRoad(const int& time, SimScenario& scenario, SimCar* car) const; 44 | SimCar* PeekFirstPriorityCarOnRoad(const int& time, SimScenario& scenario, const SimRoad* road, const int& crossId) const; 45 | bool PassCrossOrJustForward(const int& time, SimScenario& scenario, SimCar* car); 46 | bool GetCarOutFromGarage(const int& time, SimScenario& scenario, SimCar* car) const; 47 | void GetOutFromGarage(const int& time, SimScenario& scenario) const; 48 | void InitializeCarsInGarage(const int& time, SimScenario& scenario); 49 | void GetVipOutFromGarage(const int& time, SimScenario& scenario, const int& crossId = -1, const int& roadId = -1); 50 | 51 | /* cheater */ 52 | bool m_isEnableCheater; 53 | 54 | public: 55 | static Simulator Instance; 56 | 57 | void SetScheduler(Scheduler* scheduler); 58 | UpdateResult Update(const int& time, SimScenario& scenario); 59 | 60 | std::pair CanCarGetOutFromGarage(const int& time, SimScenario& scenario, SimCar* car) const; 61 | std::list GetDeadLockCars(const int& time, SimScenario& scenario) const; 62 | 63 | /* static functions */ 64 | static void SetEnableCheater(const bool& enable); 65 | 66 | /* for logging */ 67 | void PrintCrossState(const int& time, SimScenario& scenario, Cross* cross) const; 68 | void PrintDeadLock(const int& time, SimScenario& scenario) const; 69 | 70 | };//class Simulator 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /CodeCraft2019/simulation/tactics.cpp: -------------------------------------------------------------------------------- 1 | #include "tactics.h" 2 | #include "scenario.h" 3 | 4 | Tactics Tactics::Instance; 5 | 6 | Tactics::Tactics() 7 | { } 8 | 9 | void Tactics::Initialize() 10 | { 11 | m_traces.clear(); 12 | m_realTimes.clear(); 13 | m_traces.resize(Scenario::Cars().size()); 14 | m_realTimes.resize(Scenario::Cars().size(), -1); 15 | } 16 | 17 | std::vector& Tactics::GetTraces() 18 | { 19 | return m_traces; 20 | } 21 | 22 | std::vector& Tactics::GetRealTimes() 23 | { 24 | return m_realTimes; 25 | } -------------------------------------------------------------------------------- /CodeCraft2019/simulation/tactics.h: -------------------------------------------------------------------------------- 1 | #ifndef TACTICS_H 2 | #define TACTICS_H 3 | 4 | #include "trace.h" 5 | #include 6 | 7 | class Tactics 8 | { 9 | private: 10 | Tactics(); 11 | 12 | std::vector m_traces; 13 | std::vector m_realTimes; 14 | 15 | public: 16 | static Tactics Instance; //singlton 17 | 18 | void Initialize(); 19 | std::vector& GetTraces(); 20 | std::vector& GetRealTimes(); 21 | 22 | };//class Tactic 23 | 24 | #endif -------------------------------------------------------------------------------- /CodeCraft2019/simulation/trace.cpp: -------------------------------------------------------------------------------- 1 | #include "trace.h" 2 | #include "assert.h" 3 | 4 | Trace::Trace() 5 | { 6 | m_container.push_back(-1); 7 | m_end = 0; 8 | } 9 | 10 | Trace::Trace(const Trace& o) 11 | { 12 | *this = o; 13 | } 14 | 15 | Trace& Trace::operator = (const Trace& o) 16 | { 17 | m_container = o.m_container; 18 | m_container.push_back(-1); 19 | m_end = o.m_end; 20 | return *this; 21 | } 22 | 23 | void Trace::RemoveFromTail() 24 | { 25 | ASSERT(m_end != 0); 26 | --m_end; 27 | m_container[m_end] = -1; 28 | } 29 | 30 | void Trace::AddToTail(int id) 31 | { 32 | ASSERT(id >= 0); 33 | m_container[m_end] = id; 34 | ++m_end; 35 | if (m_end == m_container.size()) 36 | { 37 | m_container.push_back(-1); 38 | } 39 | } 40 | 41 | void Trace::Clear(const std::size_t& untill) 42 | { 43 | while (m_end != untill) 44 | { 45 | RemoveFromTail(); 46 | } 47 | } 48 | 49 | void Trace::Clear() 50 | { 51 | Clear(0); 52 | } 53 | -------------------------------------------------------------------------------- /CodeCraft2019/simulation/trace.h: -------------------------------------------------------------------------------- 1 | #ifndef TRACE_H 2 | #define TRACE_H 3 | 4 | #include 5 | 6 | class Trace 7 | { 8 | public: 9 | typedef std::vector Container; 10 | typedef Container::iterator Node; 11 | typedef Container::const_iterator NodeConst; 12 | 13 | private: 14 | Container m_container; 15 | std::size_t m_end; 16 | 17 | public: 18 | Trace(); 19 | Trace(const Trace& o); 20 | Trace& operator = (const Trace& o); 21 | 22 | inline Node Head(); 23 | inline Node Tail(); 24 | inline NodeConst Head() const; 25 | inline NodeConst Tail() const; 26 | 27 | const std::size_t& Size() const; 28 | void RemoveFromTail(); 29 | void AddToTail(int id); 30 | void Clear(const std::size_t& untill); 31 | void Clear(); 32 | 33 | inline int& operator [] (const std::size_t& index); 34 | inline const int& operator [] (const std::size_t& index) const; 35 | 36 | };//class Trace 37 | 38 | #include 39 | 40 | template inline 41 | std::_List_iterator<_T> operator + (const std::_List_iterator<_T>& ite, int n) 42 | { 43 | auto copy = ite; 44 | bool opposite = n < 0; 45 | if (opposite) n = -n; 46 | while(--n >= 0) 47 | opposite ? --copy : ++copy; 48 | return copy; 49 | } 50 | 51 | template inline 52 | std::_List_iterator<_T> operator - (const std::_List_iterator<_T>& ite, int n) 53 | { 54 | return ite + -n; 55 | } 56 | 57 | 58 | 59 | 60 | 61 | /* 62 | * [inline functions] 63 | * it's not good to write code here, but we really need inline! 64 | */ 65 | 66 | inline Trace::Node Trace::Head() 67 | { 68 | return m_container.begin(); 69 | } 70 | 71 | inline Trace::Node Trace::Tail() 72 | { 73 | return m_container.begin() + m_end; 74 | } 75 | 76 | inline Trace::NodeConst Trace::Head() const 77 | { 78 | return m_container.begin(); 79 | } 80 | 81 | inline Trace::NodeConst Trace::Tail() const 82 | { 83 | return m_container.begin() + m_end; 84 | } 85 | 86 | inline const std::size_t& Trace::Size() const 87 | { 88 | return m_end; 89 | } 90 | 91 | inline int& Trace::operator [] (const std::size_t& index) 92 | { 93 | return m_container[index]; 94 | } 95 | 96 | inline const int& Trace::operator [] (const std::size_t& index) const 97 | { 98 | return m_container[index]; 99 | } 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /CodeCraft2019/tester/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 查找当前目录下的所有源文件 2 | aux_source_directory(. DIR_TESTER_SRCS) 3 | 4 | # 指定生成目标 5 | add_library(tester SHARED ${DIR_TESTER_SRCS}) 6 | -------------------------------------------------------------------------------- /CodeCraft2019/tester/map-generator.h: -------------------------------------------------------------------------------- 1 | #ifndef MAP_GENERATOR_H 2 | #define MAP_GENERATOR_H 3 | 4 | #include 5 | #include "scenario.h" 6 | 7 | class SimCar; 8 | 9 | class MapGenerator 10 | { 11 | public: 12 | MapGenerator(); 13 | void Generate(int argc, char *argv[]); 14 | 15 | void SetWidth(int width); 16 | void SetHeight(int height); 17 | void SetCarsN(int n); 18 | void SetSingleWayProbability(double prob); 19 | void SetNoWayProbability(double prob); 20 | void SetVipProbability(double prob); 21 | void SetPresetProbability(double prob); 22 | void SetPresetMaxRealTime(int time); 23 | 24 | private: 25 | void GenerateMap(); 26 | bool CheckPathValid() const; 27 | void SaveToFile() const; 28 | 29 | int m_width; 30 | int m_height; 31 | int m_carsN; 32 | double m_singleWayProb; 33 | double m_noWayProb; 34 | double m_vipProb; 35 | double m_presetProb; 36 | int m_presetMaxRealTime; 37 | 38 | std::map m_crosses; 39 | std::map m_roads; 40 | std::map m_cars; 41 | std::map m_preset; 42 | 43 | };//class MapGenerator 44 | 45 | #endif -------------------------------------------------------------------------------- /CodeCraft2019/tester/sim-scenario-tester.h: -------------------------------------------------------------------------------- 1 | #ifndef SIM_SCENARIO_TESTER_H 2 | #define SIM_SCENARIO_TESTER_H 3 | 4 | #include "sim-scenario.h" 5 | 6 | class SimScenariotTester : public SimScenario 7 | { 8 | public: 9 | SimScenariotTester(); 10 | 11 | static double GeneProb, BlockProb, WaitingProb; 12 | 13 | };//class SimScenariotTester 14 | 15 | #endif -------------------------------------------------------------------------------- /CodeCraft2019/util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 查找当前目录下的所有源文件 2 | aux_source_directory(. DIR_UTIL_SRCS) 3 | 4 | # 指定生成目标 5 | add_library(util SHARED ${DIR_UTIL_SRCS}) 6 | -------------------------------------------------------------------------------- /CodeCraft2019/util/assert.h: -------------------------------------------------------------------------------- 1 | #ifndef MY_ASSERT_H 2 | #define MY_ASSERT_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define ASSERT_ON 9 | 10 | #ifdef ASSERT_ON 11 | 12 | #define ASSERT_MSG(condition, message) \ 13 | do \ 14 | { \ 15 | if (!(condition)) \ 16 | { \ 17 | std::cerr << "assert failed. cond=\"" << \ 18 | # condition << "\", " << message \ 19 | << " file=" << __FILE__ << ", line=" << \ 20 | __LINE__ << "\n"; \ 21 | throw int(0); \ 22 | } \ 23 | } \ 24 | while (false) 25 | #else 26 | #define ASSERT_MSG(...) 27 | #endif 28 | 29 | #define ASSERT(condition) ASSERT_MSG(condition, "") 30 | 31 | #endif // MY_ASSERT_H 32 | -------------------------------------------------------------------------------- /CodeCraft2019/util/copy-object.h: -------------------------------------------------------------------------------- 1 | #ifndef COPY_OBJECT_H 2 | #define COPY_OBJECT_H 3 | 4 | #include "assert.h" 5 | #include 6 | 7 | #ifdef TYPE_ID_NAME 8 | #error TYPE_ID_NAME is alreay defined 9 | #endif //#ifdef TYPE_ID_NAME 10 | #define TYPE_ID_NAME(item) (std::string(typeid(item).name())) 11 | 12 | /* 13 | * base type to perform COPY function 14 | */ 15 | class CopyableObject { 16 | public: 17 | virtual ~CopyableObject() { } 18 | virtual CopyableObject* Copy() const = 0; 19 | 20 | protected: 21 | virtual void DoCopyTo(CopyableObject* copy) const { }; 22 | 23 | /* 24 | * copy [src](type _SRC) to create a new variable with type _TARGET 25 | * even it is is shallow copy, it's enough for classes that don't include any pointer 26 | */ 27 | template 28 | static _T_TARGET* ShallowCopy(const _T_SRC* src) 29 | { 30 | _T_TARGET* pointer = dynamic_cast<_T_TARGET*>(const_cast<_T_SRC*>(src)); 31 | /* 32 | ASSERT_MSG(pointer != NULL, "can not convert " << TYPE_ID_NAME(_T_SRC) 33 | << " to " << TYPE_ID_NAME(_T_TARGET) 34 | << ", please check the first template type of CopyableTemplate when using"); 35 | */ 36 | _T_TARGET* copy = new _T_TARGET(*pointer); 37 | return copy; 38 | } 39 | 40 | public: 41 | template 42 | _T* CopyWithType() const 43 | { 44 | _T* instance = dynamic_cast<_T*>(Copy()); 45 | ASSERT(instance != NULL); 46 | return instance; 47 | } 48 | };//class CopyableObject 49 | 50 | #undef TYPE_ID_NAME 51 | 52 | /* 53 | * the template to define API of COPY function 54 | * _T_THIS means your new class' name 55 | * _T_BASE means your new class' parent class type (default to CopyableObject) 56 | */ 57 | template 58 | class CopyableTemplate : public _T_BASE 59 | { 60 | protected: 61 | virtual void DoCopy(_T_THIS* copy) const { } 62 | virtual void DoCopyTo(CopyableObject* copy) const override 63 | { 64 | _T_BASE::DoCopyTo(copy); 65 | DoCopy(dynamic_cast<_T_THIS*>(copy)); 66 | } 67 | 68 | public: 69 | virtual ~CopyableTemplate() { } 70 | friend _T_THIS; 71 | 72 | virtual CopyableObject* Copy() const override 73 | { 74 | //_T_THIS* instance = new _THIS(); 75 | _T_THIS* instance = CopyableObject::ShallowCopy<_T_THIS>(this); 76 | CopyableTemplate* copy = dynamic_cast(instance); 77 | ASSERT(instance != NULL); 78 | DoCopyTo(copy); 79 | return copy; 80 | } 81 | 82 | _T_THIS* CopyObject() const 83 | { 84 | return CopyableObject::CopyWithType<_T_THIS>(); 85 | } 86 | };//class CopyableTemplate 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /CodeCraft2019/util/define.h: -------------------------------------------------------------------------------- 1 | #ifndef DEFINE_H 2 | #define DEFINE_H 3 | 4 | #define FOREACH(cls, begin, end, var, content) \ 5 | do { \ 6 | for (int _tmp_foreach_val = (int)begin; _tmp_foreach_val <= (int)end; ++_tmp_foreach_val) \ 7 | { \ 8 | cls var = (cls)_tmp_foreach_val; \ 9 | content \ 10 | } \ 11 | } while(false) 12 | 13 | #define ID(o) (o).GetOriginId() << "(" << (o).GetId() << ")" 14 | 15 | static const int InfValue(0x3fffffff); 16 | #define Inf InfValue 17 | #define Is_Inf(v) (v > InfValue - 1) 18 | 19 | #endif -------------------------------------------------------------------------------- /CodeCraft2019/util/file-reader.cpp: -------------------------------------------------------------------------------- 1 | #include "file-reader.h" 2 | //#include "assert.h" 3 | #include 4 | #include 5 | 6 | FileReader::FileReader() 7 | { } 8 | 9 | bool FileReader::Read(const char* file, Callback::Handle1 callback) const 10 | { 11 | std::ifstream ifs(file); 12 | if (!ifs.is_open()) 13 | return false; 14 | char line[1000]; 15 | while(ifs.getline(line, sizeof(line)).gcount()) 16 | { 17 | std::stringstream ss; 18 | ss << line; 19 | if (!callback.Invoke(ss)) 20 | break; 21 | } 22 | ifs.clear(); 23 | ifs.close(); 24 | return true; 25 | } 26 | -------------------------------------------------------------------------------- /CodeCraft2019/util/file-reader.h: -------------------------------------------------------------------------------- 1 | #ifndef FILE_READER_H 2 | #define FILE_READER_H 3 | 4 | #include 5 | #include "callback.h" 6 | 7 | class FileReader 8 | { 9 | public: 10 | FileReader(); 11 | bool Read(const char* file, Callback::Handle1 callback) const; 12 | 13 | };//class FileReader 14 | 15 | 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /CodeCraft2019/util/log.cpp: -------------------------------------------------------------------------------- 1 | #include "log.h" 2 | 3 | Log::Log() 4 | : m_default(Log::DISABLE) 5 | { } 6 | 7 | Log Log::Instance; 8 | 9 | void Log::Default(Log::LogLevel level) 10 | { 11 | Instance.m_default = level; 12 | } 13 | 14 | void Log::Set(std::string name, Log::LogLevel level) 15 | { 16 | Instance.m_map[name] = level; 17 | } 18 | 19 | Log::LogLevel Log::Get(std::string name) 20 | { 21 | if (Instance.m_map.find(name) != Instance.m_map.end()) 22 | { 23 | return Instance.m_map[name]; 24 | } 25 | return Instance.m_default; 26 | } 27 | 28 | void Log::Enable(std::string name) 29 | { 30 | Set(name, ENABLE); 31 | } 32 | 33 | void Log::Disable(std::string name) 34 | { 35 | Set(name, DISABLE); 36 | } 37 | 38 | #include 39 | #include "assert.h" 40 | std::ostream* Log::GetOutstream() 41 | { 42 | //return &std::cout; 43 | static bool init = false; 44 | static std::ofstream ofs("log.txt"); 45 | if (!init) 46 | { 47 | if (!ofs.is_open()) 48 | { 49 | std::cout << "initiliaze log stream failed" << std::endl; 50 | ASSERT(false); 51 | } 52 | init = true; 53 | } 54 | return &ofs; 55 | } 56 | -------------------------------------------------------------------------------- /CodeCraft2019/util/log.h: -------------------------------------------------------------------------------- 1 | #ifndef LOG_H 2 | #define LOG_H 3 | 4 | #define LOG_ON 5 | 6 | #if defined(__linux__) 7 | #include 8 | #else 9 | #include 10 | #include 11 | class abi 12 | { 13 | public: 14 | virtual ~abi() = 0; 15 | static const char* __cxa_demangle(const char* str, void* p1, void* p2, void* p3) 16 | { 17 | auto size = strlen(str); 18 | char* ret = (char*)malloc(size + 1); 19 | strncpy(ret, str, size); 20 | ret[size] = 0; 21 | return ret; 22 | } 23 | }; 24 | #endif //#if defined(__linux__) 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | class Log { 31 | public: 32 | enum LogLevel { 33 | DISABLE, 34 | ENABLE, 35 | };//enum LogLevel 36 | 37 | private: 38 | Log(); 39 | static Log Instance; 40 | 41 | LogLevel m_default; 42 | std::map m_map; 43 | 44 | public: 45 | template 46 | static std::string GetName() 47 | { 48 | const char* name = abi::__cxa_demangle(typeid(_T).name(), NULL, NULL, NULL); 49 | std::string ret(name); 50 | free(const_cast(name)); 51 | return ret; 52 | } 53 | template 54 | static std::string GetName(const _T& o) 55 | { 56 | return GetName<_T>(); 57 | } 58 | 59 | static void Default(LogLevel level); 60 | static void Set(std::string name, LogLevel level); 61 | static LogLevel Get(std::string name); 62 | static void Enable(std::string name); 63 | static void Disable(std::string name); 64 | 65 | template 66 | static void Set(LogLevel level) 67 | { 68 | Set(GetName<_T>(), level); 69 | } 70 | 71 | template 72 | static LogLevel Get() 73 | { 74 | return Get(GetName<_T>()); 75 | } 76 | 77 | template 78 | static void Enable() 79 | { 80 | Enable(GetName<_T>()); 81 | } 82 | 83 | template 84 | static void Disable() 85 | { 86 | Disable(GetName<_T>()); 87 | } 88 | 89 | static std::ostream* GetOutstream(); 90 | 91 | };//class Log 92 | 93 | #ifdef LOG_ON 94 | #define LOG_IS_ENABLE (Log::Get(Log::GetName(*this)) == Log::ENABLE) 95 | 96 | #define LOG_IMPL(info, msg) \ 97 | do { \ 98 | if (LOG_IS_ENABLE) \ 99 | { \ 100 | std::ostream* os = Log::GetOutstream(); \ 101 | if (os != 0) \ 102 | (*os) << info << ' ' \ 103 | /*<< Log::GetName(*this) << "::"*/ \ 104 | << __FUNCTION__ << ' ' \ 105 | << msg << std::endl; \ 106 | } \ 107 | } while(false) 108 | 109 | #define LOG(msg) LOG_IMPL("", msg) 110 | 111 | #else 112 | 113 | #define LOG_IS_ENABLE false 114 | #define LOG(...) 115 | 116 | #endif 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /CodeCraft2019/util/map-array.h: -------------------------------------------------------------------------------- 1 | #ifndef MAP_ARRAY_H 2 | #define MAP_ARRAY_H 3 | 4 | #include 5 | #include "copy-object.h" 6 | 7 | template 8 | class Indexer : public CopyableTemplate< Indexer > 9 | { 10 | public: 11 | virtual ~Indexer(); 12 | const static int NoneIndex; //return NoneIndex means invalid key 13 | virtual void Input(const TK& key, const int& index); //input 14 | virtual int Output(const TK& key) const; //output 15 | 16 | };//class Indexer 17 | 18 | template 19 | class IndexerDefault : public CopyableTemplate< IndexerDefault, Indexer > 20 | { 21 | public: 22 | virtual void Input(const TK& key, const int& index) override; 23 | virtual int Output(const TK& key) const override; 24 | 25 | protected: 26 | std::map m_map; 27 | 28 | };//class IndexerDefault 29 | 30 | template 31 | class MapArray 32 | { 33 | public: 34 | typedef Indexer IndexerType; 35 | MapArray(); 36 | MapArray(const int& size); 37 | MapArray(const int& size, const bool& isCreate); 38 | MapArray(const int& size, const IndexerType& indexer); 39 | virtual ~MapArray(); 40 | 41 | void ReplaceDataByIndex(const int& index, TV* data); 42 | void ReplaceIndexer(const IndexerType& indexer); 43 | const IndexerType& GetIndexer() const; 44 | const int& Size() const; 45 | void Map(const TK& key, const int& index); 46 | TV* Find(const TK& key) const; 47 | 48 | TV& operator [] (const TK& key); 49 | const TV& operator [] (const TK& key) const; 50 | 51 | private: 52 | void InitializeData(); 53 | 54 | bool m_isManageMemory; 55 | TV** m_datas; 56 | int m_size; 57 | IndexerType* m_indexer; 58 | 59 | };//class MapArray 60 | 61 | template 62 | class IndexerEnhanced : public CopyableTemplate< IndexerEnhanced, IndexerDefault > 63 | { 64 | public: 65 | virtual void Input(const TK& key, const int& index) override; 66 | virtual int Output(const TK& key) const override; 67 | int GetDiffer() const; 68 | bool GetIsConstantDiffer() const; 69 | 70 | protected: 71 | bool m_isConstantDiffer; 72 | int m_differ; 73 | 74 | };//class IndexerEnhanced 75 | 76 | template 77 | class IndexerMirror : public CopyableTemplate< IndexerMirror, Indexer > 78 | { 79 | public: 80 | IndexerMirror(const Indexer& mirror); 81 | virtual void Input(const TK& key, const int& index) override; 82 | virtual int Output(const TK& key) const override; 83 | 84 | protected: 85 | const Indexer& m_mirror; 86 | 87 | };//class IndexerMirror 88 | 89 | #include "map-array.cpp" 90 | 91 | #endif -------------------------------------------------------------------------------- /CodeCraft2019/util/memory-pool.cpp: -------------------------------------------------------------------------------- 1 | #include "memory-pool.h" 2 | 3 | MemoryPool::MemoryPool() 4 | : head(0), last(0) 5 | { } 6 | 7 | MemoryPool::~MemoryPool() 8 | { 9 | Release(); 10 | } 11 | 12 | MemoryPool::MemoryBlock* MemoryPool::CreateMemoryBlock() 13 | { 14 | MemoryBlock* ret = new MemoryBlock(); 15 | if (head == 0) 16 | { 17 | head = ret; 18 | last = ret; 19 | } 20 | else 21 | { 22 | last->next = ret; 23 | last = ret; 24 | } 25 | ret->ptr = 0; 26 | ret->next = 0; 27 | return ret; 28 | } 29 | 30 | void MemoryPool::Release() 31 | { 32 | while(head != 0) 33 | { 34 | MemoryBlock* peek = head; 35 | head = head->next; 36 | peek->function(peek->ptr); 37 | delete peek; 38 | } 39 | last = head; 40 | } 41 | 42 | MemoryPool MemoryPool::Instance; 43 | -------------------------------------------------------------------------------- /CodeCraft2019/util/memory-pool.h: -------------------------------------------------------------------------------- 1 | #ifndef MEMORY_POOL_H 2 | #define MEMORY_POOL_H 3 | 4 | class MemoryPool 5 | { 6 | private: 7 | template 8 | static void Delete(void* &ptr) 9 | { 10 | delete (_T*)ptr; 11 | ptr = 0; 12 | } 13 | template 14 | static void DeleteArray(void* &ptr) 15 | { 16 | delete[] (_T*)ptr; 17 | ptr = 0; 18 | } 19 | typedef void (*DeleteFunction)(void*&); 20 | 21 | struct MemoryBlock 22 | { 23 | void* ptr; 24 | DeleteFunction function; 25 | MemoryBlock* next; 26 | };//struct MemoryBlock 27 | 28 | MemoryBlock* head; 29 | MemoryBlock* last; 30 | 31 | MemoryBlock* CreateMemoryBlock(); 32 | 33 | public: 34 | MemoryPool(); 35 | ~MemoryPool(); 36 | 37 | template 38 | _T* Manage(_T* ptr) 39 | { 40 | MemoryBlock* mem = CreateMemoryBlock(); 41 | mem->ptr = ptr; 42 | mem->function = &Delete<_T>; 43 | return ptr; 44 | } 45 | 46 | template 47 | _T* ManageArray(_T* ptr) 48 | { 49 | MemoryBlock* mem = CreateMemoryBlock(); 50 | mem->ptr = ptr; 51 | mem->function = &DeleteArray<_T>; 52 | return ptr; 53 | } 54 | 55 | template 56 | _T* New() 57 | { 58 | return Manage(new _T()); 59 | } 60 | 61 | template 62 | _T* NewArray(int size) 63 | { 64 | return ManageArray(new _T[size]); 65 | } 66 | 67 | 68 | void Release(); 69 | 70 | static MemoryPool Instance; 71 | 72 | };//class MemoryPool 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /CodeCraft2019/util/pmap.h: -------------------------------------------------------------------------------- 1 | #ifndef PMAP_H 2 | #define PMAP_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace std { 9 | 10 | /* if complier doesn't support pair as key in map, we need use this (e.g. in VS2012) */ 11 | 12 | #define NO_CXX11_LESS_FEATURE 13 | 14 | #ifdef NO_CXX11_LESS_FEATURE 15 | 16 | template 17 | struct pair_less 18 | : public binary_function, pair, bool> 19 | { 20 | bool operator() (const pair& l, const pair& r) const 21 | { 22 | if (l.first == r.first) 23 | return l.second < r.second; 24 | return l.first < r.first; 25 | } 26 | };//struct pair_less 27 | 28 | template 29 | class pmap : public map< pair, TV, pair_less > { }; 30 | 31 | #undef NO_CXX11_LESS_FEATURE 32 | 33 | #else 34 | 35 | template 36 | using pmap = map< pair, TV /* , pair_less */ >; 37 | 38 | #endif 39 | 40 | };//namespace std 41 | 42 | #endif -------------------------------------------------------------------------------- /CodeCraft2019/util/quick-map.h: -------------------------------------------------------------------------------- 1 | #ifndef QUICK_MAP_H 2 | #define QUICK_MAP_H 3 | 4 | #include 5 | #include "map-array.h" 6 | #include "callback.h" 7 | #include "assert.h" 8 | 9 | template 10 | class QuickMap 11 | { 12 | public: 13 | typedef typename std::map<_TK, _TV>::iterator iterator; 14 | typedef typename std::map<_TK, _TV>::const_iterator const_iterator; 15 | 16 | QuickMap() : m_size(0), m_ites(0), m_indexer(0) { } 17 | 18 | QuickMap(const unsigned int& size, const IndexerEnhanced<_TK>* indexer) 19 | : m_size(size), m_indexer(indexer->CopyObject()) { Initilize(); } 20 | 21 | QuickMap(const unsigned int& size, const std::map<_TK, _TV>& src, const IndexerEnhanced<_TK>* indexer) 22 | : m_size(size), m_map(src), m_indexer(indexer->CopyObject()) { Initilize(); } 23 | 24 | template 25 | QuickMap(const unsigned int& size, const std::map<_TK, _TSRC>& src, const IndexerEnhanced<_TK>* indexer) 26 | : m_size(size), m_indexer(indexer->CopyObject()) 27 | { 28 | m_ites = m_size > 0 ? (new iterator[m_size]) : 0; 29 | for (unsigned int i = 0; i < m_size; i++) 30 | m_ites[i] = m_map.end(); 31 | for (typename std::map<_TK, _TSRC>::const_iterator ite = src.begin(); ite != src.end(); ++ite) 32 | { 33 | std::pair result = m_map.insert(std::make_pair(ite->first, _TV(ite->second))); 34 | ASSERT(result.second); 35 | m_ites[m_indexer->Output(ite->first)] = result.first; 36 | } 37 | } 38 | 39 | QuickMap(const QuickMap& o) 40 | : m_size(0), m_ites(0), m_indexer(0) { *this = o; } 41 | 42 | QuickMap& operator = (const QuickMap& o) 43 | { 44 | Dispose(); 45 | m_size = o.m_size; 46 | m_map = o.m_map; 47 | m_indexer = o.m_indexer->CopyObject(); 48 | Initilize(); 49 | return *this; 50 | } 51 | 52 | ~QuickMap() { Dispose(); } 53 | 54 | iterator begin() { return m_map.begin(); } 55 | const_iterator begin() const { return m_map.begin(); } 56 | iterator end() { return m_map.end(); } 57 | const_iterator end() const { return m_map.end(); } 58 | 59 | //#define ITERATOR_VALID(ite) (ite##._Getcont() != 0) 60 | //#define INVALID_ITERATOR iterator() 61 | #define ITERATOR_VALID(ite) (ite != end()) 62 | #define INVALID_ITERATOR end() 63 | _TV& operator [] (const _TK& index) const 64 | { 65 | auto& ret = m_ites[m_indexer->Output(index)]; 66 | ASSERT(ITERATOR_VALID(ret)); 67 | return ret->second; 68 | } 69 | 70 | iterator find (const _TK& index) 71 | { 72 | auto& ret = m_ites[m_indexer->Output(index)]; 73 | return ITERATOR_VALID(ret) ? ret : end(); 74 | } 75 | 76 | const_iterator find (const _TK& index) const 77 | { 78 | auto& ret = m_ites[m_indexer->Output(index)]; 79 | return ITERATOR_VALID(ret) ? ret : end(); 80 | } 81 | 82 | iterator erase (const const_iterator& ite) 83 | { 84 | m_ites[m_indexer->Output(ite->first)] = INVALID_ITERATOR; 85 | return m_map.erase(ite); 86 | } 87 | 88 | std::pair insert (const _TK& index, const _TV& v) 89 | { 90 | auto result = m_map.insert(std::make_pair(index, v)); 91 | if (result.second) 92 | m_ites[m_indexer->Output(index)] = result.first; 93 | return result; 94 | } 95 | 96 | void clear() 97 | { 98 | for (auto ite = m_map.begin(); ite != m_map.end(); ++ite) 99 | m_ites[m_indexer->Output(ite->first)] = m_map.end(); 100 | m_map.clear(); 101 | } 102 | #undef ITERATOR_VALID 103 | 104 | typename std::map<_TK, _TV>::size_type size() const { return m_map.size(); } 105 | 106 | private: 107 | void Initilize() 108 | { 109 | m_ites = m_size > 0 ? (new iterator[m_size]) : 0; 110 | for (unsigned int i = 0; i < m_size; i++) 111 | m_ites[i] = m_map.end(); 112 | for (auto ite = m_map.begin(); ite != m_map.end(); ++ite) 113 | m_ites[m_indexer->Output(ite->first)] = ite; 114 | } 115 | 116 | void Dispose() 117 | { 118 | if (m_ites != 0) 119 | delete[] m_ites; 120 | if (m_indexer != 0) 121 | delete m_indexer; 122 | } 123 | 124 | unsigned int m_size; 125 | std::map<_TK, _TV> m_map; 126 | iterator* m_ites; 127 | IndexerEnhanced<_TK>* m_indexer; 128 | 129 | };//class QuickMap 130 | 131 | #endif -------------------------------------------------------------------------------- /CodeCraft2019/util/random-stream.cpp: -------------------------------------------------------------------------------- 1 | #include "random-stream.h" 2 | 3 | #define RANDOM_A 214013L 4 | #define RANDOM_C 2531011L 5 | #define RANDOM_M 0x7fff 6 | 7 | const unsigned int RandomStream::MaxValue(RANDOM_M); 8 | 9 | RandomStream::RandomStream(unsigned int seed) 10 | : m_x(seed % MaxValue) 11 | { } 12 | 13 | void RandomStream::SetValue(unsigned int v) 14 | { 15 | m_x = v % MaxValue; 16 | } 17 | 18 | unsigned int RandomStream::NextValue() 19 | { 20 | return (m_x = ((m_x * RANDOM_A + RANDOM_C) >> 16) & RANDOM_M); 21 | } 22 | 23 | #undef RANDOM_A 24 | #undef RANDOM_C 25 | #undef RANDOM_M 26 | -------------------------------------------------------------------------------- /CodeCraft2019/util/random-stream.h: -------------------------------------------------------------------------------- 1 | #ifndef RANDOM_STREAM_H 2 | #define RANDOM_STREAM_H 3 | 4 | class RandomStream 5 | { 6 | public: 7 | RandomStream(unsigned int seed = 0); 8 | void SetValue(unsigned int v); 9 | unsigned int NextValue(); 10 | 11 | static const unsigned int MaxValue; 12 | 13 | private: 14 | unsigned long long m_x; 15 | 16 | }; 17 | 18 | #endif -------------------------------------------------------------------------------- /CodeCraft2019/util/random.cpp: -------------------------------------------------------------------------------- 1 | #include "random.h" 2 | #include 3 | #include 4 | #include 5 | #include "assert.h" 6 | 7 | #ifndef M_PI 8 | #define M_PI 3.14159265358979323846 9 | #endif 10 | 11 | Random Random::Instance; 12 | 13 | Random::Random(unsigned int seed) 14 | : m_seed(seed), m_stream(seed) 15 | { } 16 | 17 | void Random::SetSeedImpl(const unsigned int& seed) 18 | { 19 | m_seed = seed; 20 | srand(m_seed); 21 | m_stream.SetValue(seed); 22 | } 23 | 24 | void Random::SetSeedAutoImpl() 25 | { 26 | SetSeed(time(NULL)); 27 | } 28 | 29 | const unsigned int& Random::GetSeedImpl() const 30 | { 31 | return m_seed; 32 | } 33 | 34 | double Random::NextUniform(const double& min, const double& max) 35 | { 36 | //return ((double)rand() / RAND_MAX) * (max - min) + min; 37 | return ((double)m_stream.NextValue() / RandomStream::MaxValue) * (max - min) + min; 38 | } 39 | 40 | double Random::NextNormal(const double& miu, const double& sigma) 41 | { 42 | return pow(-2 * log(Uniform()), 0.5) * cos(2 * M_PI * Uniform()) * sigma + miu; 43 | } 44 | 45 | double Random::NextPossion(const double& lambda, const double& bound) 46 | { 47 | while(true) 48 | { 49 | double v = -lambda * log(Uniform()); 50 | if(bound <= 0 || v < bound) 51 | { 52 | return v; 53 | } 54 | } 55 | return 0; 56 | } 57 | 58 | double Random::NextExponential(const double& lambda) 59 | { 60 | return log(1 - Uniform()) / (-lambda); 61 | } 62 | 63 | void Random::SetSeed(const unsigned int& seed) 64 | { 65 | Instance.SetSeedImpl(seed); 66 | } 67 | 68 | void Random::SetSeedAuto() 69 | { 70 | Instance.SetSeedAutoImpl(); 71 | } 72 | 73 | const unsigned int& Random::GetSeed() 74 | { 75 | return Instance.GetSeedImpl(); 76 | } 77 | 78 | double Random::Uniform(const double& min, const double& max) 79 | { 80 | return Instance.NextUniform(min, max); 81 | } 82 | 83 | double Random::Normal(const double& miu, const double& sigma) 84 | { 85 | return Instance.NextNormal(miu, sigma); 86 | } 87 | 88 | double Random::Possion(const double& lambda, const double& bound) 89 | { 90 | return Instance.NextPossion(lambda, bound); 91 | } 92 | 93 | double Random::Exponential(const double& lambda) 94 | { 95 | return Instance.NextExponential(lambda); 96 | } 97 | -------------------------------------------------------------------------------- /CodeCraft2019/util/random.h: -------------------------------------------------------------------------------- 1 | #ifndef RANDOM_H 2 | #define RANDOM_H 3 | 4 | #include "random-stream.h" 5 | 6 | class Random { 7 | private: 8 | static Random Instance; 9 | unsigned int m_seed; 10 | RandomStream m_stream; 11 | 12 | public: 13 | Random(unsigned int seed = 0); 14 | 15 | void SetSeedImpl(const unsigned int& seed); 16 | void SetSeedAutoImpl(); 17 | const unsigned int& GetSeedImpl() const; 18 | 19 | double NextUniform(const double& min = 0.0, const double& max = 1.0); 20 | double NextNormal(const double& miu = 0.0, const double& sigma = 1.0); 21 | double NextPossion(const double& lambda = 1.0, const double& bound = 0.0); //bound <= 0 means no bound 22 | double NextExponential(const double& lambda = 1.0); 23 | 24 | /* static functions */ 25 | static void SetSeed(const unsigned int& seed); 26 | static void SetSeedAuto(); 27 | static const unsigned int& GetSeed(); 28 | 29 | static double Uniform(const double& min = 0.0, const double& max = 1.0); 30 | static double Normal(const double& miu = 0.0, const double& sigma = 1.0); 31 | static double Possion(const double& lambda = 1.0, const double& bound = 0.0); //bound <= 0 means no bound 32 | static double Exponential(const double& lambda = 1.0); 33 | 34 | };//class Random 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /CodeCraft2019/util/timer.cpp: -------------------------------------------------------------------------------- 1 | #include "timer.h" 2 | #include "stdlib.h" 3 | #include "log.h" 4 | #include "assert.h" 5 | 6 | TimerHandle::TimerHandle(const clock_t& record) 7 | : m_record(record) 8 | { } 9 | 10 | double TimerHandle::GetSpendTime() const 11 | { 12 | return Timer::Instance.DoGetSpendTime(m_record); 13 | } 14 | 15 | 16 | 17 | Timer Timer::Instance; 18 | 19 | Timer::Timer() 20 | : m_start(clock()) 21 | { } 22 | 23 | double Timer::DoGetSpendTime(const clock_t& t) const 24 | { 25 | return (double)(clock() - t) / CLOCKS_PER_SEC; 26 | } 27 | 28 | const TimerHandle Timer::DoRecord() const 29 | { 30 | return TimerHandle(clock()); 31 | } 32 | 33 | double Timer::DoGetSpendTime() const 34 | { 35 | return DoGetSpendTime(m_start); 36 | } 37 | 38 | double Timer::DoGetLeftTime(const double& max) const 39 | { 40 | return max - DoGetSpendTime(); 41 | } 42 | 43 | const TimerHandle Timer::Record() 44 | { 45 | return Instance.DoRecord(); 46 | } 47 | 48 | double Timer::GetSpendTime() 49 | { 50 | return Instance.DoGetSpendTime(); 51 | } 52 | 53 | double Timer::GetLeftTime(const double& max) 54 | { 55 | return Instance.DoGetLeftTime(max); 56 | } 57 | 58 | Timer::CostStatistic::CostStatistic() 59 | : UpdateCount(0), UpdateAverage(0), UpdateMax(0), UpdateMin(0), Handle(Timer::Record()) 60 | { } 61 | 62 | void Timer::DoUpdateTimeCostBegin(const std::string& id) 63 | { 64 | m_statistic[id].Handle = Timer::Record(); 65 | } 66 | 67 | void Timer::DoUpdateTimeCostEnd(const std::string& id) 68 | { 69 | auto find = m_statistic.find(id); 70 | ASSERT(find != m_statistic.end()); 71 | double time = find->second.Handle.GetSpendTime(); 72 | if (find->second.UpdateCount == 0) 73 | { 74 | find->second.UpdateAverage = time; 75 | find->second.UpdateMax = time; 76 | find->second.UpdateMin = time; 77 | } 78 | else 79 | { 80 | find->second.UpdateAverage = find->second.UpdateAverage / (find->second.UpdateCount + 1) * find->second.UpdateCount + time / (find->second.UpdateCount + 1); 81 | if (time > find->second.UpdateMax) find->second.UpdateMax = time; 82 | if (time < find->second.UpdateMin) find->second.UpdateMin = time; 83 | } 84 | ++(find->second.UpdateCount); 85 | } 86 | 87 | void Timer::DoPrint() const 88 | { 89 | if (LOG_IS_ENABLE) 90 | { 91 | for (auto ite = m_statistic.begin(); ite != m_statistic.end(); ++ite) 92 | { 93 | LOG("Scheduler statistic : " << ite->first); 94 | LOG("\t Update count : " << ite->second.UpdateCount); 95 | if (ite->second.UpdateCount > 0) 96 | { 97 | LOG("\t Total cost : " << ite->second.UpdateAverage * ite->second.UpdateCount * 1000 << " ms"); 98 | LOG("\t Average cost : " << ite->second.UpdateAverage * 1000 << " ms"); 99 | LOG("\t Minimum cost : " << ite->second.UpdateMin * 1000 << " ms"); 100 | LOG("\t Maximum cost : " << ite->second.UpdateMax * 1000 << " ms"); 101 | } 102 | } 103 | } 104 | } 105 | 106 | void Timer::UpdateTimeCostBegin(const std::string& id) 107 | { 108 | Instance.DoUpdateTimeCostBegin(id); 109 | } 110 | 111 | void Timer::UpdateTimeCostEnd(const std::string& id) 112 | { 113 | Instance.DoUpdateTimeCostEnd(id); 114 | } 115 | 116 | void Timer::Print() 117 | { 118 | Instance.DoPrint(); 119 | } -------------------------------------------------------------------------------- /CodeCraft2019/util/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef TIMER_H 2 | #define TIMER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class TimerHandle 9 | { 10 | public: 11 | double GetSpendTime() const; 12 | 13 | private: 14 | TimerHandle(const clock_t& record); //only Timer can create an instance 15 | friend class Timer; 16 | clock_t m_record; 17 | 18 | };//class TimerHandle 19 | 20 | class Timer 21 | { 22 | private: 23 | static Timer Instance; 24 | Timer(); 25 | 26 | clock_t m_start; 27 | double m_max; 28 | 29 | double DoGetSpendTime(const clock_t& t) const; 30 | friend class TimerHandle; 31 | 32 | const TimerHandle DoRecord() const; 33 | double DoGetSpendTime() const; 34 | double DoGetLeftTime(const double& max) const; 35 | 36 | /* for calculating algorithm time cost */ 37 | struct CostStatistic 38 | { 39 | CostStatistic(); 40 | int UpdateCount; 41 | double UpdateAverage; 42 | double UpdateMax; 43 | double UpdateMin; 44 | TimerHandle Handle; 45 | };//struct CostStatistic 46 | std::map m_statistic; 47 | void DoUpdateTimeCostBegin(const std::string& id); 48 | void DoUpdateTimeCostEnd(const std::string& id); 49 | void DoPrint() const; 50 | 51 | public: 52 | static const TimerHandle Record(); 53 | static double GetSpendTime(); 54 | static double GetLeftTime(const double& max); 55 | 56 | /* for calculating algorithm time cost */ 57 | static void UpdateTimeCostBegin(const std::string& id); 58 | static void UpdateTimeCostEnd(const std::string& id); 59 | static void Print(); 60 | 61 | };//class Timer 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Huawei 2019 CodeCraft 2 | 2019年华为软件精英挑战赛代码仓储 3 | 4 | 西北赛区队伍:我想喝手磨咖啡 5 | 6 | 初赛及复赛西北赛区第一,决赛32强,惨遭大佬们殴打,最美代码奖获得者(说真的内心有愧... 7 | 8 | 算法苦手,成绩不堪入目所以就把解题思路放在后面的位置,有兴趣的朋友可以一起讨论~ 9 | 10 | ## Repo结构 11 | 12 | 这个repo实际上就是我们比赛一直在用的私有仓储,所以直接就是一个完整的VS工程加上一个备份目录backups,里面也包含cmake的内容,config的内容也在里面,所以下载的话会有11M左右,另外在公开的时候把可视化目录[Visualization](./Visualization/)也加了进来,具体的可以看目录里面的介绍。 13 | 14 | 由于兼容原因,repo项目是VS2012构建的,更高版本VS需要修改项目设置中的平台工具集一类的的设置。 15 | 16 | 关于代码,实际上如果真的仔细看的话,也没有真正达到峰峰老师的要求,望各位海涵,也希望和大家多交流共同进步。 17 | 18 | ## 代码结构 19 | 20 | 基本抽象为5个部分: 21 | 22 | - 底层基本代码(util):如数据结构、基本功能、日志和中断等 23 | - 赛题场景信息(scenario):车辆、路口和道路等信息 24 | - 仿真器(simulation):判题器以及记录每个时间片状态的车辆和道路信息等 25 | - 调度器(scheduler):算法和策略 26 | - 测试器(tester):用于验证判题器和自制测试地图(实际并没有get到康康老师迷人的地图制作技巧,只是在瞎生成) 27 | 28 | ### 底层主要功能 29 | 30 | |文件名|功能| 31 | |----|----| 32 | |log|运行日志| 33 | |assert|断言宏| 34 | |callback|回调封装| 35 | |random|随机变量| 36 | |timer|程序运行时间| 37 | 38 | ### 场景信息结构 39 | 40 | 这部分的信息是静态唯一的(从id的角度而言),在通过文件读入地图时进行加载和对象生成 41 | 42 | |文件名|功能| 43 | |----|----| 44 | |car|车辆信息| 45 | |cross|路口信息| 46 | |road|道路信息| 47 | |scenario|信息容器| 48 | 49 | ### 判题器结构 50 | 51 | 这部分属于动态信息,会与静态的场景信息相对应,比如car同一个id就只能有一个对象,但是sim-car就能有多个,目的是能够保存不同时间片下或是不同策略下的状态信息 52 | 53 | |文件名|功能| 54 | |----|----| 55 | |sim-car|车辆运行信息,包含了所在道路信息,位置信息等| 56 | |sim-road|道路信息,包含了在路上的所有车辆信息| 57 | |sim-scenario|场景信息,上述信息的载体| 58 | |tactics|需要输出答案的相关信息,包括路径信息和发车时间信息| 59 | |simulator|判题器,以单时间片为单位对场景信息进行更新,完整运行时间约1.7s| 60 | 61 | ### 调度器结构 62 | 63 | |文件名|功能| 64 | |----|----| 65 | |scheduler|调度器基类| 66 | |dead-lock-solver|运行中通过回溯解除死锁| 67 | 68 | 由于我们的基本解题思路是基于运行中动态调整策略,所以调度器基类提供一下可重载虚函数接口: 69 | 70 | |接口|功能| 71 | |----|----| 72 | |DoInitialize|初始化接口| 73 | |DoUpdate|每个时间片更新前的接口| 74 | |DoHandleBeforeGarageDispatch|每个时间片调度结束,发车之前的接口(便于在发车前再根据路况调整一次路径)| 75 | |DoHandleGetoutGarage|每辆车在即将上路时调用的接口,用于最后决策一次是否能发车以及路径等| 76 | |DoHandleBecomeFirstPriority|每辆车在成为第一优先级也就是能出路口时调用的接口,用于临时改路规避拥堵| 77 | |DoHandleResult|每个时间片结束时调用的接口,如果发生死锁可以在此时进行解决| 78 | 79 | 特殊子类scheduler-answer仅仅在DoInitialize时读入答案,然后进行答案验证。 80 | 81 | ### 整体框架 82 | 83 | 总的来说,我们解题是基于判题器的,通过运行判题器发生事件,然后由调度器处理事件。当然如果仅仅把判题器当作纯粹的判题器来用也是没问题的。整体框架如下所示: 84 | 85 | ![can not find the picture](./introduction/introduction.png) 86 | 87 | ## 算法 88 | 89 | 我们算法没什么经验,所以做得也很粗糙,能走到这一步也算运气好了,借酸菜鱼dalao名言,就是又酸又菜又多余,看了咕咕咕dalao的代码之后([友情链接](https://github.com/kongroo/Huawei-CodeCraft-2019)),心服口服(抱紧大佬不放手 90 | 91 | - 从始至终我们一直都用的flody动态改路的思想,路权使用的是当前时间片的路况信息和路长路宽,然后在发车的时候加了一些策略进去限制上路数量,比如在VIP车快结束的时候就不上普通车了,以免把VIP挡着,发车顺序为优先VIP车、速度小的以及路上消耗时间长的。总的来说都是一拍脑子加的一些玩意。 92 | 93 | - 关于死锁解决,我们采用的是回溯的方法,在时间片更新完的时候检测到死锁的话,就找到死锁环上的第一优先级车,然后选一部分重新规划下一跳及其之后的路径,规划完之后,将时间片退回到改路的车成为第一优先级的时候(历史分歧点),然后重新开始跑,顺便还要记住这些路径以免发生循环死锁。 94 | 95 | - 附加需求我们的处理方法是选择路上消耗时间长的预置VIP车来提高Tpri成绩,另外还留了一部分名额用于预置车死锁时解除死锁。 96 | 97 | 我们这个算法(scheduler-floyd)问题还是蛮大的,首先flody算路径的时候不能按每辆车来算,但是改成dijkstra的话因为每个时间片都会动态规划路径就会计算量爆炸,所以会出现车辆扎堆走的情况,其次是车辆上路和选路的判断依据为当前路况,不能保证路径现在空闲的路在车辆到达时仍然空闲,到时候就会因为拥塞而改路,也不能保证现在拥塞的路未来就不能往上走,道路利用率就很低。 98 | 99 | 然后我们就想用数学建模的方法预测未来路况(scheduler-time-weight),在拿到一辆车的路径后,把车在路上走看成一个Markov过程(拥堵或顺利往前走),就能得到这辆车在每个时间片出现在每条路上的概率,然后就能估算未来某个时间片某条路的路况,根据路况就能用dijkstra更好的选路,也能更好的决定这车这时候能不能上路,预测的路况每时间片更新,已经在路上的车如果遇到拥堵或者和上路时预测路况差别很大的情况时再动态改路。不过我们又遇到一个问题,在一开始通过空间负载均衡规划好路径后,经过一段时间的发车,剩下的车经常负载不均衡,所以又得重新均衡重新分配路径,分配得越频繁,程序运行时间越长,毕竟6w辆车,跑6w次dijkstra(卒),反正到最后也没捣鼓出来好的解决方案,不过看着路况是非常舒服的,基本不会堵车,分布也很均衡的(然并卵)。 100 | 101 | 不知道有没有用类似方法的dalao交流一下更好的思路。 102 | -------------------------------------------------------------------------------- /Visualization/CodeCraft2019Visualization.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26403.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCraft2019Visualization", "CodeCraft2019Visualization\CodeCraft2019Visualization.csproj", "{81A81B21-6020-468E-A85B-A1410272C060}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {81A81B21-6020-468E-A85B-A1410272C060}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {81A81B21-6020-468E-A85B-A1410272C060}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {81A81B21-6020-468E-A85B-A1410272C060}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {81A81B21-6020-468E-A85B-A1410272C060}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Visualization/CodeCraft2019Visualization/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Visualization/CodeCraft2019Visualization/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Windows; 7 | 8 | namespace CodeCraft2019Visualization 9 | { 10 | /// 11 | /// App.xaml 的交互逻辑 12 | /// 13 | public partial class App : Application 14 | { 15 | public App() 16 | { 17 | #if DEBUG 18 | #else 19 | this.Startup += new StartupEventHandler(OnStartup); 20 | this.Exit += new ExitEventHandler(OnExit); 21 | #endif 22 | } 23 | 24 | public void OnStartup(object sender, StartupEventArgs e) 25 | { 26 | Action OnException = null; 27 | OnException = (str, exp) => 28 | { 29 | try 30 | { 31 | var err = exp as Exception; 32 | Logging.Error(str + "\r\nSource:" + err.Source + "\r\nMessage:" + err.Message + "\r\nTrace Stack:\r\n" + err.StackTrace); 33 | if (err.InnerException != null) 34 | OnException("innner : ", err.InnerException); 35 | } 36 | catch 37 | { 38 | Logging.Error("Unknown exception : " + exp.ToString()); 39 | } 40 | }; 41 | 42 | this.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler((o, err) => 43 | { 44 | OnException("UI thread ERROR -> DispatcherUnhandledException", err.Exception); 45 | }); 46 | System.Threading.Tasks.TaskScheduler.UnobservedTaskException += (o, err) => 47 | { 48 | OnException("Task thread ERROR -> UnobservedTaskException", err.Exception); 49 | }; 50 | AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler((o, err) => 51 | { 52 | OnException("non-UI thread ERROR -> UnhandledException", err.ExceptionObject); 53 | }); 54 | } 55 | 56 | public void OnExit(object sender, ExitEventArgs e) 57 | { 58 | 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Visualization/CodeCraft2019Visualization/Basic.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Drawing; 3 | 4 | namespace CodeCraft2019Visualization 5 | { 6 | partial class Scenario 7 | { 8 | partial class Road 9 | { 10 | public enum DrawDirection 11 | { 12 | Up, 13 | Down, 14 | Left, 15 | Right 16 | } 17 | public int Id { get; set; } = 0; 18 | public int Lanes { get; set; } = 0; 19 | public int Length { get; set; } = 0; 20 | public Cross From { get; set; } = null; 21 | public Cross To { get; set; } = null; 22 | } 23 | 24 | partial class Cross 25 | { 26 | public int Id { get; set; } = 0; 27 | public int[] Neighbors { get; } = new int[] { -1, -1, -1, -1 }; 28 | } 29 | 30 | class Car 31 | { 32 | public enum CarType 33 | { 34 | Normal, 35 | Preset, 36 | Force 37 | } 38 | public int Id { get; set; } = 0; 39 | public CarType Type { get; set; } = CarType.Normal; 40 | public bool IsVip { get; set; } = false; 41 | } 42 | 43 | class TimeChip 44 | { 45 | public class ChipInfo 46 | { 47 | public int RoadId { get; set; } = 0; 48 | public bool Forward { get; set; } = true; 49 | //lane -> position 50 | public List> Cars { get; set; } = new List>(); 51 | } 52 | public int Time { get; set; } = 0; 53 | public List Situation { get; set; } = new List(); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Visualization/CodeCraft2019Visualization/Config.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace CodeCraft2019Visualization 4 | { 5 | static class Config 6 | { 7 | static public ConfigPath Path => Instance.Path; 8 | static public ConfigSize Size => Instance.Size; 9 | static public ConfigColor Color => Instance.Color; 10 | static public ConfigParameter Parameter => Instance.Parameter; 11 | 12 | class ConfigContent 13 | { 14 | public ConfigContent() { } 15 | public ConfigPath Path { get; } = new ConfigPath(); 16 | public ConfigSize Size { get; } = new ConfigSize(); 17 | public ConfigColor Color { get; } = new ConfigColor(); 18 | public ConfigParameter Parameter { get; } = new ConfigParameter(); 19 | } 20 | 21 | public class ConfigPath 22 | { 23 | public string CarName { get; set; } = "car.txt"; 24 | public string CrossName { get; set; } = "cross.txt"; 25 | public string RoadName { get; set; } = "road.txt"; 26 | public string ConfigDir { get; set; } = "./config/"; 27 | public string LogFullPath { get; set; } = "./log.tr"; 28 | public string OutputDir { get; set; } = "./output/"; 29 | } 30 | 31 | public class ConfigSize 32 | { 33 | public int CrossSize { get; set; } = 16; 34 | public int CarWidth { get; set; } = 4; 35 | public int RoadPadding { get; set; } = 22; 36 | public int IntervalBetweenCross { get; set; } = 160; 37 | } 38 | 39 | public class ConfigColor 40 | { 41 | public Color Backgroud = System.Drawing.Color.White; 42 | public Color Foregroud = System.Drawing.Color.Black; 43 | public Font Font = new Font("微软雅黑", 12); 44 | public Color Road = System.Drawing.Color.Gray; 45 | public Color Cross = System.Drawing.Color.Aqua; 46 | public Color NormalCar = System.Drawing.Color.Blue; 47 | public Color PresetCar = System.Drawing.Color.Red; 48 | public Color ForceCar = System.Drawing.Color.Green; 49 | public Color VipMark = System.Drawing.Color.Yellow; 50 | } 51 | 52 | public class ConfigParameter 53 | { 54 | public bool SaveMemory { get; set; } = true; 55 | public bool SaveImage { get; set; } = false; 56 | public double PlayInterval { get; set; } = 0.2; 57 | public Size WindowSize { get; set; } = new System.Drawing.Size(750, 500); 58 | } 59 | 60 | private const string ConfigurePath = "config.ini"; 61 | static private ConfigContent m_instance = null; 62 | static private ConfigContent Instance 63 | { 64 | get 65 | { 66 | if (m_instance == null) 67 | { 68 | if (!System.IO.File.Exists(ConfigurePath)) 69 | { 70 | m_instance = new ConfigContent(); 71 | } 72 | else 73 | { 74 | var read = System.IO.File.ReadAllText(ConfigurePath); 75 | m_instance = Newtonsoft.Json.JsonConvert.DeserializeObject(read); 76 | } 77 | } 78 | return m_instance; 79 | } 80 | } 81 | 82 | static public void SaveConfigure() 83 | { 84 | System.IO.File.WriteAllText(ConfigurePath, Newtonsoft.Json.JsonConvert.SerializeObject(Instance)); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Visualization/CodeCraft2019Visualization/IO.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Text.RegularExpressions; 7 | 8 | namespace CodeCraft2019Visualization 9 | { 10 | partial class Scenario 11 | { 12 | private static Regex IORegex = new Regex(@"\((\d+),(forward|backward),\[(.+)\]\)", RegexOptions.Compiled); 13 | private static Regex IOLaneRegex = new Regex(@"\[(.+?)\]"); 14 | private void IO() 15 | { 16 | Logging.Log("read file : " + Config.Path.LogFullPath); 17 | using (var fs = new FileStream(Config.Path.LogFullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) 18 | { 19 | if (fs == null) return; 20 | TimeChip chip = null; 21 | using (var sr = new StreamReader(fs)) 22 | { 23 | int line = 0; 24 | while (!sr.EndOfStream) 25 | { 26 | ++line; 27 | var str = sr.ReadLine(); 28 | if (str.Substring(0, 5).Contains("time:")) 29 | { 30 | if (chip != null) 31 | { 32 | m_datas.Add(chip); 33 | } 34 | chip = new TimeChip(); 35 | try 36 | { 37 | chip.Time = Convert.ToInt32(str.Substring(5)); 38 | Logging.Log("read time chip : " + m_datas.Count + " time is " + chip.Time); 39 | } 40 | catch 41 | { 42 | Logging.Log("unexpected time line [" + line + "] : " + str); 43 | break; 44 | } 45 | } 46 | else if (str[0] == '(') 47 | { 48 | Logging.Assert(chip != null); 49 | var match = IORegex.Match(str).Groups; 50 | if (match.Count != 4) 51 | { 52 | Logging.Log("unexpected line [" + line + "] : " + str); 53 | } 54 | else 55 | { 56 | TimeChip.ChipInfo info = new TimeChip.ChipInfo(); 57 | info.RoadId = Convert.ToInt32(match[1].Value); 58 | var dir = match[2].Value; 59 | Logging.Assert(dir == "forward" || dir == "backward"); 60 | info.Forward = dir == "forward"; 61 | var matches = IOLaneRegex.Matches(match[3].Value); 62 | foreach (var eMatch in matches) 63 | { 64 | Logging.Assert((eMatch as Match).Groups.Count == 2); 65 | info.Cars.Add((eMatch as Match).Groups[1].Value.Split(',').Aggregate(new List(), (l, s) => { l.Add(Convert.ToInt32(s)); return l; })); 66 | } 67 | chip.Situation.Add(info); 68 | } 69 | } 70 | else 71 | { 72 | Logging.Log("unexpected line [" + line + "] : " + str); 73 | } 74 | } 75 | } 76 | } 77 | IsIOComplete = true; 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Visualization/CodeCraft2019Visualization/Logging.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace CodeCraft2019Visualization 5 | { 6 | class Logging 7 | { 8 | [DllImport("Kernel32.dll")] 9 | private static extern bool AllocConsole(); 10 | [DllImport("kernel32.dll", EntryPoint = "FreeConsole")] 11 | private static extern bool FreeConsole(); 12 | [DllImport("user32.dll", EntryPoint = "FindWindow")] 13 | extern static IntPtr FindWindow(string lpClassName, string lpWindowName); 14 | [DllImport("user32.dll", EntryPoint = "GetSystemMenu")] 15 | extern static IntPtr GetSystemMenu(IntPtr hWnd, IntPtr bRevert); 16 | [DllImport("user32.dll", EntryPoint = "RemoveMenu")] 17 | extern static IntPtr RemoveMenu(IntPtr hMenu, uint uPosition, uint uFlags); 18 | [DllImport("Kernel32.dll")] 19 | public static extern bool SetConsoleTitle(string strMessage); 20 | 21 | 22 | private Logging(bool create) 23 | { 24 | #if DEBUG 25 | if (create) 26 | { 27 | AllocConsole(); 28 | IntPtr windowHandle = FindWindow(null, System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); 29 | IntPtr closeMenu = GetSystemMenu(windowHandle, IntPtr.Zero); 30 | uint SCCLOSE = 0xF060; 31 | RemoveMenu(closeMenu, SCCLOSE, 0x0); 32 | SetConsoleTitle("Debug Console"); 33 | } 34 | #endif 35 | } 36 | 37 | ~Logging() 38 | { 39 | #if DEBUG 40 | FreeConsole(); 41 | #endif 42 | } 43 | 44 | static private Logging Instance = new Logging(false); 45 | static private void WriteLine(string msg) 46 | { 47 | #if DEBUG 48 | Console.WriteLine(msg); 49 | #endif 50 | } 51 | 52 | #if DEBUG 53 | static public ConsoleKeyInfo ReadKey() 54 | { 55 | return Console.ReadKey(); 56 | } 57 | #endif 58 | 59 | static public void Pause() 60 | { 61 | #if DEBUG 62 | ReadKey(); 63 | #endif 64 | } 65 | 66 | static string LogFile = "log.txt"; 67 | static bool LogFileInitialized = false; 68 | static object LockObject = new object(); 69 | static public void Log(T msg, string level = "Normal") 70 | { 71 | #if DEBUG 72 | WriteLine('[' + level + ']' + ' ' + msg.ToString()); 73 | #else 74 | lock (LockObject) 75 | { 76 | //if (Configure.ReleaseLogToFile) 77 | { 78 | if (!LogFileInitialized) 79 | { 80 | System.IO.File.WriteAllText(LogFile, DateTime.Now.ToString() + "\r\n"); 81 | LogFileInitialized = true; 82 | } 83 | System.IO.File.AppendAllText(LogFile, '[' + level + ']' + ' ' + msg.ToString() + "\r\n"); 84 | } 85 | } 86 | #endif 87 | } 88 | 89 | static public void Warn(T msg) 90 | { 91 | Log(msg.ToString(), "Warn"); 92 | } 93 | 94 | static public void Error(string msg = "", string level = "Error") 95 | { 96 | Log(msg, level); 97 | Pause(); 98 | //MessageBox.Show(msg, level); 99 | System.Windows.MessageBox.Show(msg, level); 100 | System.Environment.Exit(0); 101 | } 102 | 103 | static public void Assert(bool cond, string msg = "") 104 | { 105 | if (!cond) 106 | { 107 | throw new InvalidOperationException(); 108 | Error(msg, "ASSERT"); 109 | } 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Visualization/CodeCraft2019Visualization/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |