Showing preview only (2,264K chars total). Download the full file or copy to clipboard to get everything.
Repository: binary-husky/unreal-map
Branch: master
Commit: 6454c72cc242
Files: 402
Total size: 96.2 MB
Directory structure:
gitextract_cudsbdvr/
├── .gitignore
├── BuildLinuxRender.py
├── BuildLinuxServer.py
├── BuildWindowsRender.py
├── BuildWindowsServer.py
├── Config/
│ ├── DefaultEditor.ini
│ ├── DefaultEditorPerProjectUserSettings.ini
│ ├── DefaultEngine.ini
│ ├── DefaultGame.ini
│ └── DefaultInput.ini
├── Content/
│ ├── Assets/
│ │ ├── AbstractActor/
│ │ │ ├── Agent.uasset
│ │ │ ├── DeleteOnResetActor.uasset
│ │ │ ├── HmapDefaultPawn.uasset
│ │ │ ├── HmapDefaultPawnLegacy.uasset
│ │ │ ├── HmapDefaultPawnMinimap.uasset
│ │ │ └── ReqResetActor.uasset
│ │ ├── CoreSystem/
│ │ │ ├── CoreControl.uasset
│ │ │ ├── CoreFunctionLib.uasset
│ │ │ ├── HmapGameMode.uasset
│ │ │ ├── HmapHud.uasset
│ │ │ ├── PerceptionComponentEfficient.uasset
│ │ │ └── PerceptionInterface.uasset
│ │ ├── DefAction/
│ │ │ └── ParseAction.uasset
│ │ ├── DefAgent/
│ │ │ ├── AgentTypeManifest.uasset
│ │ │ ├── DefAirAgent/
│ │ │ │ ├── RLA_UAV.uasset
│ │ │ │ ├── RLA_UAV_Support.uasset
│ │ │ │ ├── RLA_UAV_Support_V2.uasset
│ │ │ │ └── RLA_UAV_VIP.uasset
│ │ │ ├── DefAttackPost/
│ │ │ │ ├── Attacker.uasset
│ │ │ │ ├── Lv3_DefenceTank.uasset
│ │ │ │ ├── Lv3_DefenceTower.uasset
│ │ │ │ └── PosAttacker.uasset
│ │ │ ├── DefCarAgent/
│ │ │ │ ├── RLA_CAR.uasset
│ │ │ │ ├── RLA_CAR_RED.uasset
│ │ │ │ └── RLA_LaserLauncher.uasset
│ │ │ ├── DefCarrierAgent/
│ │ │ │ ├── Carrier.uasset
│ │ │ │ ├── DroneMesh.uasset
│ │ │ │ └── SmallDrone.uasset
│ │ │ ├── DefControl/
│ │ │ │ ├── AC_RL.uasset
│ │ │ │ ├── AC_RL_ACCESS.uasset
│ │ │ │ ├── AC_RL_ACCESS_LaserWeaponV2.uasset
│ │ │ │ └── AC_RL_ACCESS_NoWeapon.uasset
│ │ │ ├── DefFormation/
│ │ │ │ ├── Lv2_MomentumTestAgentSensor.uasset
│ │ │ │ └── Lv3_MomentumAgentWithHp.uasset
│ │ │ ├── DefIntercept/
│ │ │ │ ├── Attacker.uasset
│ │ │ │ ├── Defender.uasset
│ │ │ │ └── Landmark.uasset
│ │ │ ├── DefPlane/
│ │ │ │ ├── PlaneAgent.uasset
│ │ │ │ ├── UAV_Dragon.uasset
│ │ │ │ └── UAV_Rainbow.uasset
│ │ │ ├── DefPreyPredator/
│ │ │ │ ├── Predator.uasset
│ │ │ │ └── Prey.uasset
│ │ │ ├── DefReproduce/
│ │ │ │ └── DummyAgent.uasset
│ │ │ ├── DefTarget/
│ │ │ │ ├── AirDefense.uasset
│ │ │ │ ├── Commander.uasset
│ │ │ │ ├── Missile.uasset
│ │ │ │ ├── Target_Agent.uasset
│ │ │ │ ├── air_defense.uasset
│ │ │ │ └── fleet.uasset
│ │ │ ├── DefWaterdrop/
│ │ │ │ ├── Ship.uasset
│ │ │ │ └── Waterdrop.uasset
│ │ │ ├── Lv1_AgentCanMoveLegacy.uasset
│ │ │ ├── Lv1_MomentumAgent.uasset
│ │ │ ├── Lv1_MoveAgent.uasset
│ │ │ ├── Lv1_TestFlyingAgent.uasset
│ │ │ ├── Lv1_TestWalkingAgent.uasset
│ │ │ ├── Lv2_AgentCanControlLegacy.uasset
│ │ │ ├── Lv2_TestAgentSensor.uasset
│ │ │ ├── Lv3_AgentWithHp.uasset
│ │ │ ├── SharedBehaviorTree/
│ │ │ │ ├── ATTACK_MICRO_MANAGE.uasset
│ │ │ │ ├── BB_RL.uasset
│ │ │ │ ├── BT_RL_V2.uasset
│ │ │ │ ├── RL_CMD_IDLE_SETTING.uasset
│ │ │ │ └── RL_CMD_STATE.uasset
│ │ │ └── SharedTask/
│ │ │ ├── ArgKeepDistanceToTargetOrLocationV3.uasset
│ │ │ ├── BTService_CallingGuardLocationUpdateV2.uasset
│ │ │ ├── CallChangeCmdStateToIdleV2.uasset
│ │ │ ├── CallGuardLocationUpdateV2.uasset
│ │ │ ├── SetFocusToTargetOrLocation.uasset
│ │ │ ├── WeaponFiringNoFinishV2.uasset
│ │ │ └── cancel_movementV2.uasset
│ │ ├── DefNotAgent/
│ │ │ ├── BP_Explosion.uasset
│ │ │ ├── BP_Explosion_TypeB.uasset
│ │ │ ├── DefReqResetActor/
│ │ │ │ ├── AgentKillerWall/
│ │ │ │ │ ├── Cylinder_Brush_StaticMesh.uasset
│ │ │ │ │ ├── KillZoneInvisible.uasset
│ │ │ │ │ ├── KillZoneInvisible_Circle.uasset
│ │ │ │ │ └── KillZoneInvisible_Dynamic.uasset
│ │ │ │ ├── FlagToCapture.uasset
│ │ │ │ ├── KeyObjDecoration.uasset
│ │ │ │ ├── RecordWhoGetInside/
│ │ │ │ │ ├── InvisibleTrigger.uasset
│ │ │ │ │ └── InvisibleTrigger_CanEndEpisode.uasset
│ │ │ │ └── VipTargetToReach/
│ │ │ │ └── KeyObjExample.uasset
│ │ │ ├── General_Laser.uasset
│ │ │ ├── LaserForIntercept.uasset
│ │ │ ├── Weapon_Laser.uasset
│ │ │ ├── Weapon_MissileTypeC.uasset
│ │ │ └── toy.uasset
│ │ ├── GUI/
│ │ │ ├── ChildMap.uasset
│ │ │ ├── ChildMapWidget.uasset
│ │ │ ├── HpBar.uasset
│ │ │ ├── Icon_Cmd.uasset
│ │ │ ├── Icons.uasset
│ │ │ ├── Icons_airport.uasset
│ │ │ ├── Icons_cmd.uasset
│ │ │ ├── Icons_missile.uasset
│ │ │ ├── Icons_target.uasset
│ │ │ ├── MouseTraceSelector.uasset
│ │ │ ├── PlaneIcon.uasset
│ │ │ ├── RingMark.uasset
│ │ │ ├── SelectEffect.uasset
│ │ │ ├── airport.uasset
│ │ │ ├── house.uasset
│ │ │ ├── missile.uasset
│ │ │ └── 飞机2.uasset
│ │ └── Trashbin/
│ │ └── DroneAgentBlueprint/
│ │ ├── AC_Drone.uasset
│ │ ├── AC_Drone_Opp.uasset
│ │ ├── BB_Drone.uasset
│ │ ├── BT_Drone.uasset
│ │ ├── BT_Drone_Opp.uasset
│ │ ├── Drone.uasset
│ │ ├── Drone_Ground.uasset
│ │ ├── Drone_Ground_Opp.uasset
│ │ ├── EndlessPatrol.uasset
│ │ ├── KeepDistanceToTargetOrLocation.uasset
│ │ ├── KeepMsFiringToTarget.uasset
│ │ ├── LinkingPoint.uasset
│ │ ├── LinkingPointGroup.uasset
│ │ ├── MaintainDistanceToTargetOrLocation.uasset
│ │ └── MissileTypeB.uasset
│ └── Maps/
│ ├── AirportSwarmTraining.umap
│ ├── AirportSwarmTraining_BuiltData.uasset
│ ├── AutoEntry.umap
│ ├── Entry.umap
│ ├── TestCradle.umap
│ ├── TestCradle_BuiltData.uasset
│ ├── UhmapAttackPost.umap
│ ├── UhmapAttackPost_BuiltData.uasset
│ ├── UhmapBreakingBad.umap
│ ├── UhmapBreakingBad_BuiltData.uasset
│ ├── UhmapCarrier.umap
│ ├── UhmapCarrier_BuiltData.uasset
│ ├── UhmapFlagCapture.umap
│ ├── UhmapFormation.umap
│ ├── UhmapIntercept.umap
│ ├── UhmapJustAnIsland_BuiltData.uasset
│ ├── UhmapLargeScale.umap
│ ├── UhmapLargeScaleLegacy.umap
│ ├── UhmapLargeScale_BuiltData.uasset
│ ├── UhmapPreyPredator.umap
│ ├── UhmapReproduce.umap
│ ├── UhmapReproduce_BuiltData.uasset
│ ├── UhmapTemplate.umap
│ ├── UhmapTemplate_BuiltData.uasset
│ ├── UhmapWaterdrop.umap
│ └── UhmapWaterdrop_BuiltData.uasset
├── Docs/
│ ├── git_coop.md
│ └── old_install_method/
│ └── README.md
├── Please_Run_This_First_To_Fetch_Big_Files.py
├── PythonExample/
│ ├── README.md
│ └── hmp_minimal_modules/
│ ├── .gitattributes
│ ├── .gitignore
│ ├── .gitmodules
│ ├── ALGORITHM/
│ │ ├── common/
│ │ │ ├── alg_base.py
│ │ │ ├── attention.py
│ │ │ ├── conc.py
│ │ │ ├── dl_pool.py
│ │ │ ├── his.py
│ │ │ ├── hyper_net.py
│ │ │ ├── logit2act.py
│ │ │ ├── mlp.py
│ │ │ ├── net_manifest.py
│ │ │ ├── norm.py
│ │ │ ├── pca.py
│ │ │ ├── ppo_sampler.py
│ │ │ ├── rl_alg_base.py
│ │ │ ├── traj.py
│ │ │ ├── traj_gae.py
│ │ │ └── traj_manager.py
│ │ ├── example_foundation.py
│ │ ├── hete_league_onenet_fix/
│ │ │ ├── ccategorical.py
│ │ │ ├── cython_func.pyx
│ │ │ ├── div_tree.py
│ │ │ ├── foundation.py
│ │ │ ├── hete_assignment.py
│ │ │ ├── hete_net.py
│ │ │ ├── net.py
│ │ │ ├── ppo.py
│ │ │ ├── ppo_sampler.py
│ │ │ ├── shell_env.py
│ │ │ ├── stage_planner.py
│ │ │ └── trajectory.py
│ │ ├── my_ai/
│ │ │ └── foundation.py
│ │ ├── ppo_ma/
│ │ │ ├── ccategorical.py
│ │ │ ├── cython_func.pyx
│ │ │ ├── div_tree.py
│ │ │ ├── foundation.py
│ │ │ ├── net.py
│ │ │ ├── ppo.py
│ │ │ ├── ppo_sampler.py
│ │ │ ├── shell_env.py
│ │ │ ├── stage_planner.py
│ │ │ └── trajectory.py
│ │ ├── random/
│ │ │ ├── actionset.py
│ │ │ └── foundation.py
│ │ └── script_ai/
│ │ ├── a_attackpost.py
│ │ ├── a_escape.py
│ │ ├── a_test_reproduce.py
│ │ ├── assignment.py
│ │ ├── blue_strategy.py
│ │ ├── decision.py
│ │ ├── dummy.py
│ │ ├── dummy_uhmap.py
│ │ ├── global_params.py
│ │ ├── manual.py
│ │ ├── module_evaluation.py
│ │ ├── red_strategy.py
│ │ ├── stance.py
│ │ ├── uhmap_bb.py
│ │ ├── uhmap_island.py
│ │ ├── uhmap_ls.py
│ │ └── uhmap_ls_mp.py
│ ├── LICENSE
│ ├── MISSION/
│ │ ├── common/
│ │ │ └── base_env.py
│ │ ├── env_router.py
│ │ ├── readme.md
│ │ └── uhmap/
│ │ ├── SubTasks/
│ │ │ ├── SubtaskCommonFn.py
│ │ │ ├── UhmapAdversial.py
│ │ │ ├── UhmapAdversialConf.py
│ │ │ ├── UhmapAttackPost.py
│ │ │ ├── UhmapAttackPostConf.py
│ │ │ ├── UhmapBreakingBad.py
│ │ │ ├── UhmapBreakingBadConf.py
│ │ │ ├── UhmapCarrier.py
│ │ │ ├── UhmapCarrierConf.py
│ │ │ ├── UhmapEscape.py
│ │ │ ├── UhmapEscapeConf.py
│ │ │ ├── UhmapFormation.py
│ │ │ ├── UhmapFormationConf.py
│ │ │ ├── UhmapHuge.py
│ │ │ ├── UhmapHugeConf.py
│ │ │ ├── UhmapIntercept.py
│ │ │ ├── UhmapInterceptConf.py
│ │ │ ├── UhmapJustAnIsland.py
│ │ │ ├── UhmapJustAnIslandConf.py
│ │ │ ├── UhmapLargeScale.py
│ │ │ ├── UhmapLargeScaleConf.py
│ │ │ ├── UhmapPreyPredator.py
│ │ │ ├── UhmapPreyPredatorConf.py
│ │ │ ├── UhmapReproduce.py
│ │ │ ├── UhmapReproduceConf.py
│ │ │ ├── UhmapWaterdrop.py
│ │ │ ├── UhmapWaterdropConf.py
│ │ │ └── cython_func.pyx
│ │ ├── actionset.py
│ │ ├── actionset_v3.py
│ │ ├── actset_lookup.py
│ │ ├── agent.py
│ │ ├── auto_download.py
│ │ ├── struct.cpp
│ │ ├── uhmap.md
│ │ └── uhmap_env_wrapper.py
│ ├── README.md
│ ├── UTIL/
│ │ ├── __init__.py
│ │ ├── auto_gpu.py
│ │ ├── batch_exp.py
│ │ ├── colorful.py
│ │ ├── config_args.py
│ │ ├── data_struct.py
│ │ ├── exp_helper.py
│ │ ├── fetch_multiserver.py
│ │ ├── file_lock.py
│ │ ├── gpu_eater.py
│ │ ├── gpu_share.py
│ │ ├── hidden_print.py
│ │ ├── hmp_daemon.py
│ │ ├── legacy/
│ │ │ └── gpu_share_unfin.py
│ │ ├── mem_watcher_ue.py
│ │ ├── memleak_finder.py
│ │ ├── mprofile.py
│ │ ├── mserver_launcher.sh
│ │ ├── network.py
│ │ ├── pip_find_missing.py
│ │ ├── shm_env.py
│ │ ├── shm_pool.pyx
│ │ ├── sync_exp.py
│ │ ├── tensor_ops.py
│ │ ├── tensor_ops_c.pyx
│ │ └── win_pool.py
│ ├── VISUALIZE/
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── color.html
│ │ ├── mcom.py
│ │ ├── mcom_def.py
│ │ ├── mcom_rec.py
│ │ ├── mcom_replay.py
│ │ ├── mcom_rt.py
│ │ ├── mcom_test.py
│ │ ├── mcom_v2d.py
│ │ ├── read_group_replay.ipynb
│ │ ├── seaborn_defaults.py
│ │ └── threejs_replay.py
│ ├── ZDOCS/
│ │ ├── Dockerfile
│ │ ├── DockerfilePython311
│ │ ├── bashrc_suffix
│ │ ├── examples/
│ │ │ └── uhmap/
│ │ │ ├── AirAttack.jsonc
│ │ │ ├── AirShow.jsonc
│ │ │ ├── hlt+50vs50.jsonc
│ │ │ ├── ppoma+50vs50.jsonc
│ │ │ ├── ppoma+intercept.jsonc
│ │ │ ├── ppoma+predatorprey.jsonc
│ │ │ ├── ppoma+uhmap10vs10hete.jsonc
│ │ │ ├── ppoma_waterdrop.jsonc
│ │ │ ├── qmix+uhmap10vs10hete.jsonc
│ │ │ ├── qmix+uhmap20vs20.jsonc
│ │ │ ├── qmix+uhmap50vs50+debug.jsonc
│ │ │ ├── qmix+uhmap50vs50.jsonc
│ │ │ ├── qplex+uhmap10vs10hete.jsonc
│ │ │ ├── qtran+uhmap10vs10hete.jsonc
│ │ │ └── random_waterdrop.jsonc
│ │ ├── pip_requirement.md
│ │ ├── sc2checkversion
│ │ ├── setup_docker.md
│ │ ├── setup_no_docker.md
│ │ ├── setup_ubuntu.md
│ │ ├── setup_ue_docker.md
│ │ ├── ssh_pubkey.sh
│ │ ├── test_examples.py
│ │ ├── use_pymarl2.md
│ │ └── use_unreal_hmap.md
│ ├── ZHECKPOINT/
│ │ └── uhmap_hete10vs10/
│ │ ├── experiment_test.jsonc
│ │ ├── render_result.jsonc
│ │ ├── render_result_editor.jsonc
│ │ └── render_result_editor2.jsonc
│ ├── agent_with_sensor.jsonc
│ ├── attack_post.jsonc
│ ├── carrier.jsonc
│ ├── config.py
│ ├── cradle.ipynb
│ ├── cradle.py
│ ├── escape.jsonc
│ ├── formation.jsonc
│ ├── main.py
│ ├── multi_server.py
│ ├── multi_team.py
│ ├── multi_team_parallel.py
│ ├── reproduce.jsonc
│ └── task_runner.py
├── README.md
├── README_CN.md
├── Source/
│ ├── Jsonx/
│ │ ├── Jsonx.Build.cs
│ │ ├── Private/
│ │ │ ├── Dom/
│ │ │ │ ├── JsonxObject.cpp
│ │ │ │ └── JsonxValue.cpp
│ │ │ ├── JsonxModule.cpp
│ │ │ └── Tests/
│ │ │ └── JsonxTests.cpp
│ │ └── Public/
│ │ ├── Dom/
│ │ │ ├── JsonxObject.h
│ │ │ └── JsonxValue.h
│ │ ├── Jsonx.h
│ │ ├── JsonxGlobals.h
│ │ ├── JsonxUtils/
│ │ │ └── JsonxObjectArrayUpdater.h
│ │ ├── Policies/
│ │ │ ├── CondensedJsonxPrintPolicy.h
│ │ │ ├── JsonxPrintPolicy.h
│ │ │ └── PrettyJsonxPrintPolicy.h
│ │ └── Serialization/
│ │ ├── JsonxReader.h
│ │ ├── JsonxSerializer.h
│ │ ├── JsonxSerializerMacros.h
│ │ ├── JsonxTypes.h
│ │ └── JsonxWriter.h
│ ├── JsonxUtilities/
│ │ ├── JsonxUtilities.Build.cs
│ │ ├── Private/
│ │ │ ├── JsonxObjectConverter.cpp
│ │ │ ├── JsonxObjectWrapper.cpp
│ │ │ └── JsonxUtilitiesModule.cpp
│ │ └── Public/
│ │ ├── JsonxDomBuilder.h
│ │ ├── JsonxObjectConverter.h
│ │ ├── JsonxObjectWrapper.h
│ │ └── JsonxUtilities.h
│ ├── UHMP/
│ │ ├── AgentBaseCpp.cpp
│ │ ├── AgentBaseCpp.h
│ │ ├── DataStruct.h
│ │ ├── HMPAIController.cpp
│ │ ├── HMPAIController.h
│ │ ├── HMPLevelScriptActor.cpp
│ │ ├── HMPLevelScriptActor.h
│ │ ├── HmpCrowdFollowingComponent.cpp
│ │ ├── HmpCrowdFollowingComponent.h
│ │ ├── HmpPythonIO.cpp
│ │ ├── HmpPythonIO.h
│ │ ├── IOCompress/
│ │ │ ├── lz4.c
│ │ │ └── lz4.h
│ │ ├── UHMP.Build.cs
│ │ ├── UHMP.cpp
│ │ ├── UHMP.h
│ │ ├── UHMPBlueprintFunctionLibrary.cpp
│ │ └── UHMPBlueprintFunctionLibrary.h
│ ├── UHMP.Target.cs
│ ├── UHMPEditor.Target.cs
│ └── UHMPServer.Target.cs
├── build.py
├── compress.txt
├── current_version
├── onedrive_util.py
├── test_memory_leak.py
└── upload_big_file.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
Binaries
Build
DerivedDataCache
Intermediate
Saved
TEMP
Temp
Py
.vscode
.vs
*.VC.db
*.opensdf
*.opendb
*.sdf
*.sln
*.suo
*.xcodeproj
*.xcworkspace
Python
__pycache__
*-datas
# private*
private*
Content/Model3D
Plugins
7-Zip
UHMP.uproject
EnvDesignTutorial.pptx
# f'.\\7-Zip\\7z.exe a -tzip -mx4 ./Build/uhmp-big-file-v{desired_version}.zip ./Content/Model3D ./Plugins ./7-Zip ./UHMP.uproject ./EnvDesignTutorial.pptx'
# ./7-Zip/7z.exe a -tzip -mx4 ./Build/tt.zip -ir!Content\Model3D\Flying\Meshes 7-Zip
Content/StarterContent
================================================
FILE: BuildLinuxRender.py
================================================
"""
After you have installed the toolchain for cross-compilation,
you must open the solution for the engine in Rider (or VisualStudio) and
build (rebuild is not necessary) the editor for Win64 (yes, that is Win64 and not Linux).
This will create the needed folder “Engine/Binaries/Win64/Linux”.
Then restart your editor, and packaging LinuxServer will work.
"""
import subprocess, sys, shutil, time, os
EnginePath = "F:/UnrealEngine-4.27.2-release/Engine"
assert os.path.exists(EnginePath), f"Cannot find Unreal Engine at this path {EnginePath}"
Windows_Only = False
Build = 'Test' # Development/Test/shipping
Platform = 'Linux' # Win64/Linux
def print亮绿(*kw,**kargs):
print("\033[1;32m",*kw,"\033[0m",**kargs)
time_mark = time.strftime("%Y-%m-%d-%H-%M", time.localtime())
try:
shutil.rmtree('Build/LinuxNoEditor')
except:
pass
print亮绿(f'********* Begin Build: {Build} On {Platform} ***********')
# build server
path = os.path.abspath('./').replace(r'\\', '/')
process = subprocess.Popen([
f"{EnginePath}/Build/BatchFiles/RunUAT.bat",
f"-ScriptsForProject={path}/UHMP.uproject",
"BuildCookRun",
"-nocompileeditor",
"-nop4",
f"-project={path}/UHMP.uproject",
"-cook",
"-stage",
"-archive",
f"-archivedirectory={path}/Build",
"-package ",
f"-ue4exe={EnginePath}/Binaries/Win64/UE4Editor-Cmd.exe",
"-compressed",
"-ddc=DerivedDataBackendGraph",
"-pak",
"-prereqs",
"-nodebuginfo",
f"-targetplatform={Platform}",
"-build",
"-target=UHMP",
"-serverconfig=%s"%Build,
"-utf8output",
"-compile"
])
return_code = process.wait()
print亮绿('********* ********************** ***********')
print亮绿('********* ********************** ***********')
print亮绿('********* ********************** ***********')
print亮绿('********* ********************** ***********')
if (return_code!=0):
print('fail')
sys.exit()
================================================
FILE: BuildLinuxServer.py
================================================
"""
After you have installed the toolchain for cross-compilation,
you must open the solution for the engine in Rider (or VisualStudio) and
build (rebuild is not necessary) the editor for Win64 (yes, that is Win64 and not Linux).
This will create the needed folder “Engine/Binaries/Win64/Linux”.
Then restart your editor, and packaging LinuxServer will work.
"""
import subprocess, sys, shutil, time, os
EnginePath = "F:/UnrealEngine-4.27.2-release/Engine"
assert os.path.exists(EnginePath), f"Cannot find Unreal Engine at this path {EnginePath}"
Windows_Only = False
Build = 'Test' # Development/Test/shipping
Platform = 'Linux' # Win64/Linux
def print亮绿(*kw,**kargs):
print("\033[1;32m",*kw,"\033[0m",**kargs)
time_mark = time.strftime("%Y-%m-%d-%H-%M", time.localtime())
try:
shutil.rmtree('Build/LinuxServer')
except:
pass
print亮绿(f'********* Begin Build: {Build} On {Platform} ***********')
# build server
path = os.path.abspath('./').replace(r'\\', '/')
process = subprocess.Popen([
f"{EnginePath}/Build/BatchFiles/RunUAT.bat",
f"-ScriptsForProject={path}/UHMP.uproject",
"BuildCookRun",
"-nocompileeditor",
"-nop4",
f"-project={path}/UHMP.uproject",
"-cook",
"-stage",
"-archive",
f"-archivedirectory={path}/Build",
"-package ",
f"-ue4exe={EnginePath}/Binaries/Win64/UE4Editor-Cmd.exe",
"-compressed",
"-ddc=DerivedDataBackendGraph",
"-pak",
"-prereqs",
"-nodebuginfo",
f"-targetplatform={Platform}",
"-build",
"-target=UHMPServer",
"-serverconfig=%s"%Build,
"-utf8output",
"-compile"
])
return_code = process.wait()
print亮绿('********* ********************** ***********')
print亮绿('********* ********************** ***********')
print亮绿('********* ********************** ***********')
print亮绿('********* ********************** ***********')
if (return_code!=0):
print('fail')
sys.exit()
================================================
FILE: BuildWindowsRender.py
================================================
import subprocess, sys, shutil, time, os
EnginePath = "F:/UnrealEngine-4.27.2-release/Engine"
assert os.path.exists(EnginePath), f"Cannot find Unreal Engine at this path {EnginePath}"
Windows_Only = False
Build = 'Test' # Development/Test/shipping
Platform = 'Win64' # Win64/Linux
def print亮绿(*kw,**kargs):
print("\033[1;32m",*kw,"\033[0m",**kargs)
time_mark = time.strftime("%Y-%m-%d-%H-%M", time.localtime())
try:
shutil.rmtree('Build/WindowsNoEditor')
except:
pass
print亮绿(f'********* Begin Build: {Build} On {Platform} ***********')
# build server
path = os.path.abspath('./').replace(r'\\', '/')
process = subprocess.Popen([
f"{EnginePath}/Build/BatchFiles/RunUAT.bat",
f"-ScriptsForProject={path}/UHMP.uproject",
"BuildCookRun",
"-nocompileeditor",
"-nop4",
f"-project={path}/UHMP.uproject",
"-cook",
"-stage",
"-archive",
f"-archivedirectory={path}/Build",
"-package ",
f"-ue4exe={EnginePath}/Binaries/Win64/UE4Editor-Cmd.exe",
"-compressed",
"-ddc=DerivedDataBackendGraph",
"-pak",
"-prereqs",
"-nodebuginfo",
f"-targetplatform={Platform}",
"-build",
"-target=UHMP",
"-serverconfig=%s"%Build,
"-utf8output",
"-compile"
])
return_code = process.wait()
print亮绿('********* ********************** ***********')
print亮绿('********* ********************** ***********')
print亮绿('********* ********************** ***********')
print亮绿('********* ********************** ***********')
if (return_code!=0):
print('fail')
sys.exit()
================================================
FILE: BuildWindowsServer.py
================================================
import subprocess, sys, shutil, time, os
EnginePath = "F:/UnrealEngine-4.27.2-release/Engine"
assert os.path.exists(EnginePath), f"Cannot find Unreal Engine at this path {EnginePath}"
Windows_Only = False
Build = 'Test' # Development/Test/shipping
Platform = 'Win64' # Win64/Linux
def print亮绿(*kw,**kargs):
print("\033[1;32m",*kw,"\033[0m",**kargs)
time_mark = time.strftime("%Y-%m-%d-%H-%M", time.localtime())
try:
shutil.rmtree('Build/WindowsServer')
except:
pass
print亮绿(f'********* Begin Build: {Build} On {Platform} ***********')
# build server
path = os.path.abspath('./').replace(r'\\', '/')
process = subprocess.Popen([
f"{EnginePath}/Build/BatchFiles/RunUAT.bat",
f"-ScriptsForProject={path}/UHMP.uproject",
"BuildCookRun",
"-nocompileeditor",
"-nop4",
f"-project={path}/UHMP.uproject",
"-cook",
"-stage",
"-archive",
f"-archivedirectory={path}/Build",
"-package ",
f"-ue4exe={EnginePath}/Binaries/Win64/UE4Editor-Cmd.exe",
"-compressed",
"-ddc=DerivedDataBackendGraph",
"-pak",
"-prereqs",
"-nodebuginfo",
f"-targetplatform={Platform}",
"-build",
"-target=UHMPServer",
"-serverconfig=%s"%Build,
"-utf8output",
"-compile"
])
return_code = process.wait()
print亮绿('********* ********************** ***********')
print亮绿('********* ********************** ***********')
print亮绿('********* ********************** ***********')
print亮绿('********* ********************** ***********')
if (return_code!=0):
print('fail')
sys.exit()
================================================
FILE: Config/DefaultEditor.ini
================================================
================================================
FILE: Config/DefaultEditorPerProjectUserSettings.ini
================================================
[/Script/BlueprintGraph.BlueprintEditorSettings]
bDrawMidpointArrowsInBlueprints=False
bShowGraphInstructionText=True
bHideUnrelatedNodes=False
bShowShortTooltips=True
bSplitContextTargetSettings=True
bExposeAllMemberComponentFunctions=True
bShowContextualFavorites=False
bExposeDeprecatedFunctions=False
bCompactCallOnMemberNodes=False
bFlattenFavoritesMenus=True
bFavorPureCastNodes=False
bAutoCastObjectConnections=False
bShowViewportOnSimulate=False
bShowInheritedVariables=False
bAlwaysShowInterfacesInOverrides=True
bShowParentClassInOverrides=True
bShowEmptySections=True
bShowAccessSpecifier=False
bSpawnDefaultBlueprintNodes=True
bHideConstructionScriptComponentsInDetailsView=True
bHostFindInBlueprintsInGlobalTab=True
bNavigateToNativeFunctionsFromCallNodes=True
Bookmarks=()
bIncludeCommentNodesInBookmarksTab=True
bShowBookmarksForCurrentDocumentOnlyInTab=False
GraphEditorQuickJumps=()
SaveOnCompile=SoC_Never
bJumpToNodeErrors=False
bAllowExplicitImpureNodeDisabling=True
bShowActionMenuItemSignatures=False
bBlueprintNodeUniqueNames=False
bShowDetailedCompileResults=False
CompileEventDisplayThresholdMs=5
NodeTemplateCacheCapMB=20.000000
================================================
FILE: Config/DefaultEngine.ini
================================================
[/Script/EngineSettings.GameMapsSettings]
GameDefaultMap=/Game/Maps/AutoEntry.AutoEntry
EditorStartupMap=/Game/Maps/UhmapLargeScale.UhmapLargeScale
ServerDefaultMap=/Game/Maps/AutoEntry.AutoEntry
[/Script/HardwareTargeting.HardwareTargetingSettings]
TargetedHardwareClass=Desktop
AppliedTargetedHardwareClass=Desktop
DefaultGraphicsPerformance=Maximum
AppliedDefaultGraphicsPerformance=Maximum
[/Script/Engine.Engine]
+ActiveGameNameRedirects=(OldGameName="TP_BlankBP",NewGameName="/Script/UHMP")
+ActiveGameNameRedirects=(OldGameName="/Script/TP_BlankBP",NewGameName="/Script/UHMP")
+ActiveGameNameRedirects=(OldGameName="/Script/MyProject2", NewGameName="/Script/UHMP")
CustomTimeStepClassName=None
bUseFixedFrameRate=True
FixedFrameRate=64.000000
[/Script/Engine.RendererSettings]
r.DefaultFeature.AutoExposure=False
r.DefaultFeature.AutoExposure.Method=0
r.DefaultFeature.MotionBlur=False
[/Script/Engine.CollisionProfile]
-Profiles=(Name="NoCollision",CollisionEnabled=NoCollision,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="No collision",bCanModify=False)
-Profiles=(Name="BlockAll",CollisionEnabled=QueryAndPhysics,ObjectTypeName="WorldStatic",CustomResponses=,HelpMessage="WorldStatic object that blocks all actors by default. All new custom channels will use its own default response. ",bCanModify=False)
-Profiles=(Name="OverlapAll",CollisionEnabled=QueryOnly,ObjectTypeName="WorldStatic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ",bCanModify=False)
-Profiles=(Name="BlockAllDynamic",CollisionEnabled=QueryAndPhysics,ObjectTypeName="WorldDynamic",CustomResponses=,HelpMessage="WorldDynamic object that blocks all actors by default. All new custom channels will use its own default response. ",bCanModify=False)
-Profiles=(Name="OverlapAllDynamic",CollisionEnabled=QueryOnly,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldDynamic object that overlaps all actors by default. All new custom channels will use its own default response. ",bCanModify=False)
-Profiles=(Name="IgnoreOnlyPawn",CollisionEnabled=QueryOnly,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that ignores Pawn and Vehicle. All other channels will be set to default.",bCanModify=False)
-Profiles=(Name="OverlapOnlyPawn",CollisionEnabled=QueryOnly,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Pawn",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that overlaps Pawn, Camera, and Vehicle. All other channels will be set to default. ",bCanModify=False)
-Profiles=(Name="Pawn",CollisionEnabled=QueryAndPhysics,ObjectTypeName="Pawn",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Pawn object. Can be used for capsule of any playerable character or AI. ",bCanModify=False)
-Profiles=(Name="Spectator",CollisionEnabled=QueryOnly,ObjectTypeName="Pawn",CustomResponses=((Channel="WorldStatic",Response=ECR_Block),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore)),HelpMessage="Pawn object that ignores all other actors except WorldStatic.",bCanModify=False)
-Profiles=(Name="CharacterMesh",CollisionEnabled=QueryOnly,ObjectTypeName="Pawn",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Pawn object that is used for Character Mesh. All other channels will be set to default.",bCanModify=False)
-Profiles=(Name="PhysicsActor",CollisionEnabled=QueryAndPhysics,ObjectTypeName="PhysicsBody",CustomResponses=,HelpMessage="Simulating actors",bCanModify=False)
-Profiles=(Name="Destructible",CollisionEnabled=QueryAndPhysics,ObjectTypeName="Destructible",CustomResponses=,HelpMessage="Destructible actors",bCanModify=False)
-Profiles=(Name="InvisibleWall",CollisionEnabled=QueryAndPhysics,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="WorldStatic object that is invisible.",bCanModify=False)
-Profiles=(Name="InvisibleWallDynamic",CollisionEnabled=QueryAndPhysics,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that is invisible.",bCanModify=False)
-Profiles=(Name="Trigger",CollisionEnabled=QueryOnly,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldDynamic object that is used for trigger. All other channels will be set to default.",bCanModify=False)
-Profiles=(Name="Ragdoll",CollisionEnabled=QueryAndPhysics,ObjectTypeName="PhysicsBody",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Simulating Skeletal Mesh Component. All other channels will be set to default.",bCanModify=False)
-Profiles=(Name="Vehicle",CollisionEnabled=QueryAndPhysics,ObjectTypeName="Vehicle",CustomResponses=,HelpMessage="Vehicle object that blocks Vehicle, WorldStatic, and WorldDynamic. All other channels will be set to default.",bCanModify=False)
-Profiles=(Name="UI",CollisionEnabled=QueryOnly,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Block),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ",bCanModify=False)
+Profiles=(Name="NoCollision",CollisionEnabled=NoCollision,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="No collision")
+Profiles=(Name="BlockAll",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=,HelpMessage="WorldStatic object that blocks all actors by default. All new custom channels will use its own default response. ")
+Profiles=(Name="OverlapAll",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ")
+Profiles=(Name="BlockAllDynamic",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=,HelpMessage="WorldDynamic object that blocks all actors by default. All new custom channels will use its own default response. ")
+Profiles=(Name="OverlapAllDynamic",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldDynamic object that overlaps all actors by default. All new custom channels will use its own default response. ")
+Profiles=(Name="IgnoreOnlyPawn",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that ignores Pawn and Vehicle. All other channels will be set to default.")
+Profiles=(Name="OverlapOnlyPawn",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Pawn",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that overlaps Pawn, Camera, and Vehicle. All other channels will be set to default. ")
+Profiles=(Name="Pawn",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Pawn object. Can be used for capsule of any playerable character or AI. ")
+Profiles=(Name="Spectator",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="WorldStatic"),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore)),HelpMessage="Pawn object that ignores all other actors except WorldStatic.")
+Profiles=(Name="CharacterMesh",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Pawn object that is used for Character Mesh. All other channels will be set to default.")
+Profiles=(Name="PhysicsActor",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="PhysicsBody",CustomResponses=,HelpMessage="Simulating actors")
+Profiles=(Name="Destructible",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Destructible",CustomResponses=,HelpMessage="Destructible actors")
+Profiles=(Name="InvisibleWall",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="WorldStatic object that is invisible.")
+Profiles=(Name="InvisibleWallDynamic",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that is invisible.")
+Profiles=(Name="Trigger",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldDynamic object that is used for trigger. All other channels will be set to default.")
+Profiles=(Name="Ragdoll",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="PhysicsBody",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Simulating Skeletal Mesh Component. All other channels will be set to default.")
+Profiles=(Name="Vehicle",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Vehicle",CustomResponses=,HelpMessage="Vehicle object that blocks Vehicle, WorldStatic, and WorldDynamic. All other channels will be set to default.")
+Profiles=(Name="UI",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility"),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ")
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Block,bTraceType=False,bStaticObject=False,Name="Missile")
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel2,DefaultResponse=ECR_Block,bTraceType=False,bStaticObject=False,Name="Agent")
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel3,DefaultResponse=ECR_Block,bTraceType=False,bStaticObject=False,Name="Env")
-ProfileRedirects=(OldName="BlockingVolume",NewName="InvisibleWall")
-ProfileRedirects=(OldName="InterpActor",NewName="IgnoreOnlyPawn")
-ProfileRedirects=(OldName="StaticMeshComponent",NewName="BlockAllDynamic")
-ProfileRedirects=(OldName="SkeletalMeshActor",NewName="PhysicsActor")
-ProfileRedirects=(OldName="InvisibleActor",NewName="InvisibleWallDynamic")
+ProfileRedirects=(OldName="BlockingVolume",NewName="InvisibleWall")
+ProfileRedirects=(OldName="InterpActor",NewName="IgnoreOnlyPawn")
+ProfileRedirects=(OldName="StaticMeshComponent",NewName="BlockAllDynamic")
+ProfileRedirects=(OldName="SkeletalMeshActor",NewName="PhysicsActor")
+ProfileRedirects=(OldName="InvisibleActor",NewName="InvisibleWallDynamic")
-CollisionChannelRedirects=(OldName="Static",NewName="WorldStatic")
-CollisionChannelRedirects=(OldName="Dynamic",NewName="WorldDynamic")
-CollisionChannelRedirects=(OldName="VehicleMovement",NewName="Vehicle")
-CollisionChannelRedirects=(OldName="PawnMovement",NewName="Pawn")
+CollisionChannelRedirects=(OldName="Static",NewName="WorldStatic")
+CollisionChannelRedirects=(OldName="Dynamic",NewName="WorldDynamic")
+CollisionChannelRedirects=(OldName="VehicleMovement",NewName="Vehicle")
+CollisionChannelRedirects=(OldName="PawnMovement",NewName="Pawn")
[/Script/NavigationSystem.RecastNavMesh]
CellSize=5.000000
CellHeight=10.000000
AgentRadius=106.453094
AgentHeight=74.311516
TileSizeUU=1000.000000
AgentMaxStepHeight=100.000000
AgentMaxSlope=44.000000
RuntimeGeneration=Static
bDrawPolyEdges=False
[URL]
GameName=UHMP
[/Script/NavigationSystem.NavigationSystemV1]
DefaultAgentName=None
CrowdManagerClass=/Script/AIModule.CrowdManager
bAutoCreateNavigationData=True
bSpawnNavDataInNavBoundsLevel=False
bAllowClientSideNavigation=False
bShouldDiscardSubLevelNavData=True
bTickWhilePaused=False
bInitialBuildingLocked=False
bSkipAgentHeightCheckWhenPickingNavData=False
bGenerateNavigationOnlyAroundNavigationInvokers=False
ActiveTilesUpdateInterval=1.000000
DataGatheringMode=Instant
DirtyAreaWarningSizeThreshold=-1.000000
+SupportedAgents=(Name="AirportAgents",Color=(B=0,G=255,R=140,A=164),DefaultQueryExtent=(X=500.000000,Y=500.000000,Z=500.000000),NavDataClass=/Script/NavigationSystem.RecastNavMesh,AgentRadius=130.000000,AgentHeight=100.000000,AgentStepHeight=50.000000,NavWalkingSearchHeightScale=0.500000,PreferredNavData=/Script/NavigationSystem.RecastNavMesh,bCanCrouch=False,bCanJump=False,bCanWalk=True,bCanSwim=False,bCanFly=True)
+SupportedAgents=(Name="RLA",Color=(B=0,G=255,R=140,A=164),DefaultQueryExtent=(X=500.000000,Y=500.000000,Z=500.000000),NavDataClass=/Script/NavigationSystem.RecastNavMesh,AgentRadius=130.000000,AgentHeight=100.000000,AgentStepHeight=-1.000000,NavWalkingSearchHeightScale=0.500000,PreferredNavData=None,bCanCrouch=False,bCanJump=False,bCanWalk=True,bCanSwim=False,bCanFly=True)
SupportedAgentsMask=(bSupportsAgent0=True,bSupportsAgent1=True,bSupportsAgent2=True,bSupportsAgent3=True,bSupportsAgent4=True,bSupportsAgent5=True,bSupportsAgent6=True,bSupportsAgent7=True,bSupportsAgent8=True,bSupportsAgent9=True,bSupportsAgent10=True,bSupportsAgent11=True,bSupportsAgent12=True,bSupportsAgent13=True,bSupportsAgent14=True,bSupportsAgent15=True)
DirtyAreasUpdateFreq=60.000000
[/Script/Engine.PhysicsSettings]
MaxPhysicsDeltaTime=0.500000
InitialAverageFrameRate=0.041667
[/Script/Engine.GarbageCollectionSettings]
gc.TimeBetweenPurgingPendingKillObjects=10.000000
gc.ActorClusteringEnabled=True
================================================
FILE: Config/DefaultGame.ini
================================================
[/Script/EngineSettings.GeneralProjectSettings]
ProjectID=2433E6A446E19AAC82A379AF7E021098
[StartupActions]
bAddPacks=True
InsertPack=(PackSource="StarterContent.upack",PackName="StarterContent")
[/Script/UnrealEd.ProjectPackagingSettings]
Build=IfProjectHasCode
BuildConfiguration=PPBC_Development
BuildTarget=UHMP
StagingDirectory=(Path="F:/2/git_test/uhmap/Build")
FullRebuild=False
ForDistribution=False
IncludeDebugFiles=False
BlueprintNativizationMethod=Disabled
+NativizeBlueprintAssets=(FilePath="/Game/Assets/BlueprintLib/Agent")
+NativizeBlueprintAssets=(FilePath="/Game/Assets/BlueprintLib/BpHmpPythonBridgeV2")
+NativizeBlueprintAssets=(FilePath="/Game/Assets/Core/BpHmpPythonBridgeV2")
+NativizeBlueprintAssets=(FilePath="/Game/Assets/Core/Main")
+NativizeBlueprintAssets=(FilePath="/Game/Assets/Core/CoreControl")
+NativizeBlueprintAssets=(FilePath="/Game/Assets/CoreSystem/CoreControl")
+NativizeBlueprintAssets=(FilePath="/Game/Assets/CoreAgent/Agent")
+NativizeBlueprintAssets=(FilePath="/Game/Assets/CoreActors/Agent")
+NativizeBlueprintAssets=(FilePath="/Game/Assets/AbstractActors/Agent")
+NativizeBlueprintAssets=(FilePath="/Game/Assets/AbstractActor/Agent")
bIncludeNativizedAssetsInProjectGeneration=False
bExcludeMonolithicEngineHeadersInNativizedCode=False
UsePakFile=True
bUseIoStore=False
bMakeBinaryConfig=False
bGenerateChunks=False
bGenerateNoChunks=False
bChunkHardReferencesOnly=False
bForceOneChunkPerFile=False
MaxChunkSize=0
bBuildHttpChunkInstallData=False
HttpChunkInstallDataDirectory=(Path="")
bCompressed=True
PakFileCompressionFormats=Oodle
bForceUseProjectCompressionFormatIgnoreHardwareOverride=False
PakFileAdditionalCompressionOptions=-compressionblocksize=256KB
PakFileCompressionMethod=Kraken
PakFileCompressionLevel_DebugDevelopment=3
PakFileCompressionLevel_TestShipping=5
PakFileCompressionLevel_Distribution=7
HttpChunkInstallDataVersion=
IncludePrerequisites=True
IncludeAppLocalPrerequisites=False
bShareMaterialShaderCode=True
bDeterministicShaderCodeOrder=False
bSharedMaterialNativeLibraries=True
ApplocalPrerequisitesDirectory=(Path="")
IncludeCrashReporter=False
InternationalizationPreset=English
-CulturesToStage=en
+CulturesToStage=en
LocalizationTargetCatchAllChunkId=0
bCookAll=False
bCookMapsOnly=False
bSkipEditorContent=False
bSkipMovies=False
-IniKeyBlacklist=KeyStorePassword
-IniKeyBlacklist=KeyPassword
-IniKeyBlacklist=rsa.privateexp
-IniKeyBlacklist=rsa.modulus
-IniKeyBlacklist=rsa.publicexp
-IniKeyBlacklist=aes.key
-IniKeyBlacklist=SigningPublicExponent
-IniKeyBlacklist=SigningModulus
-IniKeyBlacklist=SigningPrivateExponent
-IniKeyBlacklist=EncryptionKey
-IniKeyBlacklist=IniKeyBlacklist
-IniKeyBlacklist=IniSectionBlacklist
+IniKeyBlacklist=KeyStorePassword
+IniKeyBlacklist=KeyPassword
+IniKeyBlacklist=rsa.privateexp
+IniKeyBlacklist=rsa.modulus
+IniKeyBlacklist=rsa.publicexp
+IniKeyBlacklist=aes.key
+IniKeyBlacklist=SigningPublicExponent
+IniKeyBlacklist=SigningModulus
+IniKeyBlacklist=SigningPrivateExponent
+IniKeyBlacklist=EncryptionKey
+IniKeyBlacklist=IniKeyBlacklist
+IniKeyBlacklist=IniSectionBlacklist
+MapsToCook=(FilePath="/Game/Maps/AutoEntry")
+MapsToCook=(FilePath="/Game/Maps/UhmapBreakingBad")
+MapsToCook=(FilePath="/Game/Maps/UhmapLargeScale")
+MapsToCook=(FilePath="/Game/Maps/UhmapIntercept")
+MapsToCook=(FilePath="/Game/Maps/UhmapPreyPredator")
+MapsToCook=(FilePath="/Game/Maps/UhmapWaterdrop")
+MapsToCook=(FilePath="/Game/Maps/UhmapAttackPost")
+MapsToCook=(FilePath="/Game/Maps/UhmapCarrier")
+MapsToCook=(FilePath="/Game/Maps/UhmapReproduce")
+MapsToCook=(FilePath="/Game/Maps/UhmapFormation")
+MapsToCook=(FilePath="/Game/Maps/UhmapFlagCapture")
================================================
FILE: Config/DefaultInput.ini
================================================
[/Script/Engine.InputSettings]
-AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
-AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
-AxisConfig=(AxisKeyName="Mouse2D",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
+AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Mouse2D",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MouseWheelAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_LeftTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_Special_Left_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_Special_Left_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Daydream_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Daydream_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Daydream_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Daydream_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Vive_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Vive_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Vive_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Vive_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Vive_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Vive_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Left_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Right_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Grip_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Touch",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Grip_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
bAltEnterTogglesFullscreen=True
bF11TogglesFullscreen=True
bUseMouseForTouch=False
bEnableMouseSmoothing=True
bEnableFOVScaling=True
bCaptureMouseOnLaunch=True
bAlwaysShowTouchInterface=False
bShowConsoleOnFourFingerTap=True
bEnableGestureRecognizer=False
bUseAutocorrect=False
DefaultViewportMouseCaptureMode=CapturePermanently_IncludingInitialMouseDown
DefaultViewportMouseLockMode=LockOnCapture
FOVScale=0.011110
DoubleClickTime=0.200000
+ActionMappings=(ActionName="ResumControl",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Tab)
+ActionMappings=(ActionName="OnMouseSelect",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftMouseButton)
+ActionMappings=(ActionName="OnRightMouseSelect",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=RightMouseButton)
+ActionMappings=(ActionName="OnMidMousePressed",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=MiddleMouseButton)
+ActionMappings=(ActionName="On=Pressed",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Equals)
DefaultPlayerInputClass=/Script/Engine.PlayerInput
DefaultInputComponentClass=/Script/Engine.InputComponent
DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.DefaultVirtualJoysticks
-ConsoleKeys=Tilde
+ConsoleKeys=Tilde
================================================
FILE: Content/Maps/AirportSwarmTraining.umap
================================================
[File too large to display: 26.3 MB]
================================================
FILE: Content/Maps/TestCradle_BuiltData.uasset
================================================
[File too large to display: 21.0 MB]
================================================
FILE: Content/Maps/UhmapBreakingBad.umap
================================================
[File too large to display: 25.9 MB]
================================================
FILE: Content/Maps/UhmapLargeScale_BuiltData.uasset
================================================
[File too large to display: 21.0 MB]
================================================
FILE: Docs/git_coop.md
================================================
# 如何将修改同步到远程
### 0. 首先关闭虚幻引擎!
### 1. 打开vscode,切换到git页面
<div align="center">
<img src="Docs/2022-10-17-17-14-13.png" width="300" >
</div>
### 2. 填写message,然后点击commit
### 3. 再点击sync changes,然后出现下面界面(也有可能直接顺利完成,忽略以下步骤即可)
<div align="center">
<img src="Docs/2022-10-17-17-30-42.png" width="300" >
</div>
<div align="center">
<img src="Docs/2022-10-17-17-16-09.png" width="300" >
</div>
### 4. 如果没有“Merge Changes”,再次点击提交即可,但一般都会有若干项“Merge Changes”,即和其他人发生冲突的文件,需要进行处理
### 5. 如有“Merge Changes”,打开终端
#### 5-1 (确实对该文件做出过有意义的修改)如果想保存本地,无视远程文件,强行把本地文件汇入远程:
终端命令:
```
git checkout --ours /path/to/file
git add /path/to/file
```
在此例子中,
```
git checkout --ours Content\Assets\DefAction\ParseAction.uasset
git add Content\Assets\DefAction\ParseAction.uasset
```
#### 5-2 (无意修改此文件,或该文件属于其他人的管辖范围)如果想覆盖本地文件,采纳远程文件:
终端命令:
```
git checkout --theirs /path/to/file
git add /path/to/file
```
在此例子中,
```
git checkout --theirs Content\Assets\DefAction\ParseAction.uasset
git add Content\Assets\DefAction\ParseAction.uasset
```
### 6. 再次点击Commit,完成流程
================================================
FILE: Docs/old_install_method/README.md
================================================
# UHMAP
Developed with Unreal Engine 4
# How to install | 如何安装自定义版本的虚幻引擎
另见视频:
https://ageasga-my.sharepoint.com/:v:/g/personal/fuqingxu_yiteam_tech/EawfqsV2jF5Nsv3KF7X1-woBH-VTvELL6FSRX4cIgUboLg?e=Vmp67E
## 1. 下载 Visual Studio Community
https://visualstudio.microsoft.com/zh-hans/
## 2. 安装 Visual Studio Community
<div align="center">
<img src="Docs/vscode_install.jpg" width="600" >
</div>
<div align="center">
<img src="Docs/vs_install2.png" width="600" >
</div>
需要至少安装C++的桌面开发和C++的游戏开发两部分,安装版本见截图;另需安装.NET框架,版本为4.6.2
## 3. 下载虚幻引擎源代码 (非官方,修改过源码)
https://ageasga-my.sharepoint.com/:u:/g/personal/fuqingxu_yiteam_tech/Ee3lQrUjKNFMjPITm5G-hEgBbeEN6dMOPtKP9ssgONKJcA?e=BavOoJ
## 4. 编译虚幻引擎
1. 解压源代码(到至少150GB空间的磁盘)
1. Open your source folder in Explorer and run **Setup.bat**.
This will download binary content for the engine, as well as installing prerequisites and setting up Unreal file associations.
On Windows 8, a warning from SmartScreen may appear. Click "More info", then "Run anyway" to continue. 运行**Setup.bat**
A clean download of the engine binaries is currently 3-4gb, which may take some time to complete.
Subsequent checkouts only require incremental downloads and will be much quicker. 需要一段时间
1. Run **GenerateProjectFiles.bat** to create project files for the engine. It should take less than a minute to complete. 运行 **GenerateProjectFiles.bat**
1. Load the project into Visual Studio by double-clicking on the **UE4.sln** file. Set your solution configuration to **Development Editor** and your solution
platform to **Win64**, then right click on the **UE4** target and select **Build**. It may take anywhere between 10 and 40 minutes to finish compiling, depending on your system specs. 打开**UE4.sln**,界面顶部的项目配置为**Development Editor** 和 **Win64**, 右击界面右侧菜单的**UE4**,点击**Build**,需要20分钟~1小时时间编译(配置好后,点选界面上面栏目中的生成Build,点击生成UE4)
1. 右键点击项目工程文件夹中的UHMP.uproject,按照图示选择虚幻引擎版本为4.27.2-release,进行初步生成项目的操作;之后打开UHMP.sln,将界面顶部的项目配置为**Development Editor** 和 **Win64**,点选右侧资源管理器中的UHMP,再点击界面顶部的生成-->生成UHMP;完成后双击UHMP.uproject打开工程项目
<div align="center">
<img src="Docs/UHMP_1.png" width="600" >
</div>
6. 成功打开的虚幻编辑器加载界面应当如下图所示
<div align="center">
<img src="Docs/UHMP_window.jpg" width="600" >
</div>
================================================
FILE: Please_Run_This_First_To_Fetch_Big_Files.py
================================================
import os, commentjson, shutil, subprocess, tqdm, shutil
import zipfile
from modelscope import snapshot_download
try: os.makedirs('./TEMP')
except: pass
version = 'unreal-map-v3.4'
model_dir = snapshot_download(f'BinaryHusky/{version}')
zip_file_path = f'./TEMP/{version}.zip'
def combine_file(model_dir, output_file_path, num_parts):
with open(output_file_path, 'wb') as output_file:
for i in range(0, num_parts):
part_file_path = os.path.join(model_dir, "tensor", f"safetensor_{i+1}.pt")
with open(part_file_path, 'rb') as part_file:
output_file.write(part_file.read())
extract_to_path = './'
combine_file(model_dir, output_file_path=zip_file_path, num_parts=5)
# 打开 ZIP 文件
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
# 解压所有文件到指定目录
zip_ref.extractall(extract_to_path)
print(f"files unzipped {extract_to_path}")
print("everything is ready!")
================================================
FILE: PythonExample/README.md
================================================
This demo program can connect to developing/compiled U-MAP environment to debug your simulation.
This program is a copy of another resp: https://github.com/binary-husky/hmp2g
================================================
FILE: PythonExample/hmp_minimal_modules/.gitattributes
================================================
*.js linguist-detectable=false
================================================
FILE: PythonExample/hmp_minimal_modules/.gitignore
================================================
# Build and Release Folders
bin-debug/
bin-release/
*/__pycache__
[Oo]bj/
[Bb]in/
# Other files and folders
.settings/
# Executables
*.swf
*.air
*.ipa
*.apk
*.so
*.pyc
*.pyd
*.so
# gpu lock
*.glock
*.mp3
*.png
# pytorch model
*.pt
core
!MISSION/collective_assult/malib/core
TODO
__pycache__/
./build/
ALGORITHM/Starcraft/result/
ALGORITHM/Starcraft/model/
ZipResults/
VISUALIZE/train no aWiseAttn
VISUALIZE/train-half-death-reward
ZipResults/Starcraft/
result
# .vscode/
forattack-train/
full-cargo/
T*/
checkpoint/
PROFILE/
RECYCLE/
TEMP/
test_only_*.py
test_only_log
test_only_profile.txt
test_only_profilex.txt
debug_change_self_n_agent.json.profile.txt
debug2-2500pt-test_only_profile.txt
test_only_logdebug_change_self_n_agent.json.log
test_only_profiledebug_change_self_n_agent.json.txt
xx_profile_n_agents2.py
xx_profile_n_agents3.py
xx_profile_n_agents4.py
UTIL/keys.py
private*
fqx*.jsonc
my_*.jsonc
result.prof
ignore
bvrAI.log
ZHECKPOINT/*
THIRDPARTY/pymarl2/test
!ZHECKPOINT/test-50+50
ZHECKPOINT/test-50+50/*
!ZHECKPOINT/test-50+50/model.pt
!ZHECKPOINT/test-50+50/experiment.json
!ZHECKPOINT/test-50+50/test-50+50.jsonc
!ZHECKPOINT/test-50+50/test50.gif
!ZHECKPOINT/test-100+100
ZHECKPOINT/test-100+100/*
!ZHECKPOINT/test-100+100/model.pt
!ZHECKPOINT/test-100+100/experiment.json
!ZHECKPOINT/test-100+100/test-100+100.jsonc
!ZHECKPOINT/50RL-55opp
ZHECKPOINT/50RL-55opp/*
!ZHECKPOINT/50RL-55opp/test-50RL-55opp.jsonc
!ZHECKPOINT/50RL-55opp/model.pt
ZHECKPOINT/50RL-55opp/experiment.json
!ZHECKPOINT/test-cargo50
ZHECKPOINT/test-cargo50/*
!ZHECKPOINT/test-cargo50/model.pt
!ZHECKPOINT/test-cargo50/experiment.json
!ZHECKPOINT/test-cargo50/test-cargo50.jsonc
!ZHECKPOINT/test-cargo50/cargo50.jpg
!ZHECKPOINT/test-cargo50/history_cpt
ZHECKPOINT/test-cargo50/history_cpt/*
!ZHECKPOINT/test-cargo50/history_cpt/init.pkl
!ZHECKPOINT/test-50+50/butterfly.webp
!ZHECKPOINT/test-aii515
ZHECKPOINT/test-aii515/*
!ZHECKPOINT/test-aii515/model.pt
!ZHECKPOINT/test-aii515/experiment.json
!ZHECKPOINT/test-aii515/test-aii515.jsonc
!ZHECKPOINT/test-aii515/aii.jpg
!ZHECKPOINT/test-aii515/history_cpt
ZHECKPOINT/test-aii515/history_cpt/*
!ZHECKPOINT/test-aii515/history_cpt/init.pkl
!ZHECKPOINT/basic-ma-40-demo
ZHECKPOINT/basic-ma-40-demo/*
!ZHECKPOINT/basic-ma-40-demo/trained_model.pt
!ZHECKPOINT/basic-ma-40-demo/train.json
!ZHECKPOINT/basic-ma-40-demo/test.json
!ZHECKPOINT/adca-demo
ZHECKPOINT/adca-demo/*
!ZHECKPOINT/adca-demo/model_trained.pt
!ZHECKPOINT/adca-demo/train.json
!ZHECKPOINT/adca-demo/test.json
!ZHECKPOINT/uhmap_hete10vs10
ZHECKPOINT/uhmap_hete10vs10/backup_files
ZHECKPOINT/uhmap_hete10vs10/logger
!ZHECKPOINT/uhmap_hete10vs10/model_trained.pt
ZHECKPOINT/uhmap_hete10vs10/experiment.jsonc
cmd_io.txt
rec.jpg
detail_reward.jpg
z_*
ALGORITHM/conc_4hist_divtree3
ALGORITHM/conc_4hist_divtree2
example_dca_cs*
PersonalityDevelop.pdf
6vs7Pr-continue-train.jsonc
6vs7Pr.jsonc
6vs7PrTry2-Link.jsonc
6vs7PrTry2.jsonc
7vs7Pr.json
7vs7Pr.jsonc
batch_experiment_backup.py
mcom_buffer_0____starting_session.txt
temp.jpg
temp.jpg.jpg
x.txt
debug*.jsonc
HLT_eval.py
qplex-pad.jsonc
raw_exp.jsonc
info.json
UTIL/mem_watcher.py
ALGORITHM/mirror*
================================================
FILE: PythonExample/hmp_minimal_modules/.gitmodules
================================================
[submodule "THIRDPARTY/pymarl2/pymarl2src"]
path = THIRDPARTY/pymarl2/pymarl2src
url = https://github.com/binary-husky/pymarl-hmap-compat.git
branch = master
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/alg_base.py
================================================
import os, time, torch, traceback
import numpy as np
from config import GlobalConfig
from UTIL.colorful import *
class AlgorithmBase():
def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
self.n_thread = n_thread
self.n_agent = n_agent
self.team = team
self.act_space = space['act_space']
self.obs_space = space['obs_space']
self.ScenarioConfig = GlobalConfig.ScenarioConfig
self.mcv = mcv
self.device = GlobalConfig.device
def interact_with_env(self, team_intel):
raise NotImplementedError
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/attention.py
================================================
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions.categorical import Categorical
from torch.distributions.multivariate_normal import MultivariateNormal
from UTIL.tensor_ops import my_view
class MultiHeadAttention(nn.Module):
# taken from https://github.com/wouterkool/attention-tsp/blob/master/graph_encoder.py
def __init__(
self,
n_heads,
input_dim,
embed_dim=None,
val_dim=None,
key_dim=None
):
super(MultiHeadAttention, self).__init__()
if val_dim is None:
assert embed_dim is not None, "Provide either embed_dim or val_dim"
val_dim = embed_dim // n_heads
if key_dim is None:
key_dim = val_dim
self.n_heads = n_heads
self.input_dim = input_dim
self.embed_dim = embed_dim
self.val_dim = val_dim
self.key_dim = key_dim
self.norm_factor = 1 / math.sqrt(key_dim) # See Attention is all you need
self.W_query = nn.Parameter(torch.Tensor(n_heads, input_dim, key_dim))
self.W_key = nn.Parameter(torch.Tensor(n_heads, input_dim, key_dim))
self.W_val = nn.Parameter(torch.Tensor(n_heads, input_dim, val_dim))
if embed_dim is not None:
self.W_out = nn.Parameter(torch.Tensor(n_heads, key_dim, embed_dim))
self.init_parameters()
def init_parameters(self):
for param in self.parameters():
stdv = 1. / math.sqrt(param.size(-1))
param.data.uniform_(-stdv, stdv)
def forward(self, q, k=None, v=None, mask=None, return_attn=False, return_attn_weight=False):
if q.dim()<=3:
out = self.forward_(q, k, v, mask, return_attn, return_attn_weight)
if return_attn:
out, attn = out
assert attn.shape[0]==1
attn = attn.squeeze(0)
return out, attn
return out
hyper_dim = q.shape[:-2]
q = my_view(q, [-1, *q.shape[-2:]])
if k is not None:
k = my_view(k, [-1, *k.shape[-2:]])
if v is not None:
v = my_view(v, [-1, *v.shape[-2:]])
if mask is not None: mask = my_view(mask, [-1, *mask.shape[-2:]])
out = self.forward_(q, k, v, mask, return_attn, return_attn_weight)
if return_attn:
out, attn = out
if hyper_dim is not None:
out = out.view(*hyper_dim, *out.shape[-2:])
attn = attn.view(*hyper_dim, *attn.shape[-2:]) #??
return out, attn
else:
if hyper_dim is not None:
out = out.view(*hyper_dim, *q.shape[-2:])
return out
def forward_(self, q, k=None, v=None, mask=None, return_attn=False, return_attn_weight=False):
"""
:param q: queries (batch_size, n_query, input_dim)
:param k: data (batch_size, n_key/graph_size, input_dim)
:param mask: mask (batch_size, n_query, graph_size) or viewable as that (i.e. can be 2 dim if n_query == 1)
Mask should contain 1 if attention is not possible (i.e. mask is negative adjacency)
:return:
"""
if k is None:
k = q # compute self-attention
if v is None:
v = k
# k should be (batch_size, graph_size, input_dim)
batch_size, graph_size, input_dim = k.size()
n_query = q.size(1)
assert q.size(0) == batch_size
assert q.size(2) == input_dim
assert input_dim == self.input_dim, "Wrong embedding dimension of input"
kflat = k.contiguous().view(-1, input_dim)
qflat = q.contiguous().view(-1, input_dim)
vflat = v.contiguous().view(-1, input_dim)
# last dimension can be different for keys and values
shp = (self.n_heads, batch_size, graph_size, -1)
shp_q = (self.n_heads, batch_size, n_query, -1)
# Calculate queries, (n_heads, n_query, graph_size, key/val_size)
Q = torch.matmul(qflat, self.W_query).view(shp_q)
# Calculate keys and values (n_heads, batch_size, graph_size, key/val_size)
K = torch.matmul(kflat, self.W_key).view(shp)
V = torch.matmul(vflat, self.W_val).view(shp)
# Calculate compatibility (n_heads, batch_size, n_query, graph_size)
compatibility = self.norm_factor * torch.matmul(Q, K.transpose(2, 3))
if return_attn_weight:
assert self.n_heads == 1
if mask is not None:
mask = mask.view(1, batch_size, n_query, graph_size).expand_as(compatibility)
compatibility[mask.bool()] = -math.inf
return compatibility.squeeze(0)
# Optionally apply mask to prevent attention
if mask is not None: # expand to n_heads
mask = mask.view(1, batch_size, n_query, graph_size).expand_as(compatibility)
compatibility[mask.bool()] = -math.inf
attn = F.softmax(compatibility, dim=-1)
# If there are nodes with no neighbours then softmax returns nan so we fix them to 0
if mask is not None:
attnc = attn.clone()
attnc[mask.bool()] = 0
attn = attnc
# 为了在这里解决 0*nan = nan 的问题,输入必须将V中的nan转化为0
heads = torch.matmul(attn, V)
out = torch.mm(
heads.permute(1, 2, 0, 3).contiguous().view(-1, self.n_heads * self.val_dim),
self.W_out.view(-1, self.embed_dim)
).view(batch_size, n_query, self.embed_dim)
if return_attn:
return out, attn
return out
class SimpleAttention(nn.Module):
def __init__(self, h_dim):
super().__init__()
self.W_query = nn.Parameter(torch.Tensor(h_dim, h_dim))
self.W_key = nn.Parameter(torch.Tensor(h_dim, h_dim))
self.W_val = nn.Parameter(torch.Tensor(h_dim, h_dim))
self.init_parameters()
def init_parameters(self):
for param in self.parameters():
stdv = 1. / math.sqrt(param.size(-1))
param.data.uniform_(-stdv, stdv)
def forward(self, k, q, v, mask=None):
Q = torch.matmul(q, self.W_query)
K = torch.matmul(k, self.W_key)
V = torch.matmul(v, self.W_val)
norm_factor = 1 / math.sqrt(Q.shape[-1])
compat = norm_factor * torch.matmul(Q, K.transpose(-1, -2))
if mask is not None: compat[mask.bool()] = -math.inf
# 为了在这里解决 0*nan = nan 的问题,输入必须将V中的nan转化为0
score = torch.nan_to_num(F.softmax(compat, dim=-1), 0)
return torch.matmul(score, V)
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/conc.py
================================================
import math
import torch,time,random
import torch.nn as nn
import torch.nn.functional as F
from UTIL.tensor_ops import my_view, __hash__, __hashn__, pad_at_dim, gather_righthand
class Concentration(nn.Module):
def __init__(self, n_focus_on, h_dim, skip_connect=False, skip_connect_dim=0, adopt_selfattn=False):
super().__init__()
self.n_focus_on = n_focus_on
self.skip_connect = skip_connect
self.skip_dim = h_dim+skip_connect_dim
self.CT_W_query = nn.Parameter(torch.Tensor(h_dim, h_dim))
self.CT_W_key = nn.Parameter(torch.Tensor(h_dim, h_dim))
self.CT_W_val = nn.Parameter(torch.Tensor(h_dim, h_dim))
self.CT_motivate_mlp = nn.Sequential(nn.Linear(h_dim * 2, h_dim), nn.ReLU(inplace=True))
self.AT_forward_mlp = nn.Sequential(nn.Linear((n_focus_on+1)*self.skip_dim, h_dim), nn.ReLU(inplace=True))
self.adopt_selfattn = adopt_selfattn
if self.adopt_selfattn:
assert False, ('no longer support')
self.init_parameters()
def init_parameters(self):
for param in self.parameters():
stdv = 1. / math.sqrt(param.size(-1))
param.data.uniform_(-stdv, stdv)
def forward(self, vs, ve, ve_dead, skip_connect_ze=None, skip_connect_zs=None):
mask = ve_dead
Q = torch.matmul(vs, self.CT_W_query)
K = torch.matmul(ve, self.CT_W_key)
norm_factor = 1 / math.sqrt(Q.shape[-1])
compat = norm_factor * torch.matmul(Q, K.transpose(2, 3))
assert compat.shape[-2] == 1
compat = compat.squeeze(-2)
compat[mask.bool()] = -math.inf
score = F.softmax(compat, dim=-1)
# nodes with no neighbours were softmax into nan, fix them to 0
score = torch.nan_to_num(score, 0)
# ----------- motivational brach -------------
Va = torch.matmul(score.unsqueeze(-2), torch.matmul(ve, self.CT_W_val))
v_M = torch.cat((vs, Va), -1).squeeze(-2)
v_M_final = self.CT_motivate_mlp(v_M)
# ----------- forward branch -------------
score_sort_index = torch.argsort(score, dim=-1, descending=True)
score_sort_drop_index = score_sort_index[..., :self.n_focus_on]
if self.skip_connect:
ve = torch.cat((ve, skip_connect_ze), -1)
vs = torch.cat((vs, skip_connect_zs), -1)
ve_C = gather_righthand(src=ve, index=score_sort_drop_index, check=False)
need_padding = (score_sort_drop_index.shape[-1] != self.n_focus_on)
if need_padding:
print('the n_focus param is large than input, advise: pad observation instead of pad here')
ve_C = pad_at_dim(ve_C, dim=-2, n=self.n_focus_on)
v_C_stack = torch.cat((vs, ve_C), dim=-2)
if self.adopt_selfattn:
v_C_stack = self.AT_Attention(v_C_stack, mask=None)
v_C_flat = my_view(v_C_stack, [0, 0, -1]); assert v_C_stack.dim()==4
v_C_final = self.AT_forward_mlp(v_C_flat)
return v_C_final, v_M_final
class ConcentrationHete(nn.Module):
def __init__(self, n_focus_on, h_dim, skip_connect=False, skip_connect_dim=0, adopt_selfattn=False):
super().__init__()
self.n_focus_on = n_focus_on
self.skip_connect = skip_connect
self.skip_dim = h_dim+skip_connect_dim
self.AT_W_query = nn.Parameter(torch.Tensor(h_dim, h_dim))
self.AT_W_key = nn.Parameter(torch.Tensor(h_dim, h_dim))
self.AT_W_val = nn.Parameter(torch.Tensor(h_dim, h_dim))
self.AT_motivate_mlp = nn.Sequential(nn.Linear(h_dim * 2, h_dim), nn.ReLU(inplace=True))
self.AT_forward_mlp = nn.Sequential(nn.Linear((n_focus_on+1)*self.skip_dim, h_dim), nn.ReLU(inplace=True))
self.adopt_selfattn = adopt_selfattn
if self.adopt_selfattn:
assert False, ('no longer support')
self.init_parameters()
def init_parameters(self):
for param in self.parameters():
stdv = 1. / math.sqrt(param.size(-1))
param.data.uniform_(-stdv, stdv)
def forward(self, vs, ve, ve_dead, skip_connect_ze=None, skip_connect_zs=None):
mask = ve_dead
Q = torch.matmul(vs, self.AT_W_query)
K = torch.matmul(ve, self.AT_W_key)
norm_factor = 1 / math.sqrt(Q.shape[-1])
compat = norm_factor * torch.matmul(Q, K.transpose(2, 3))
assert compat.shape[-2] == 1
compat = compat.squeeze(-2)
compat[mask.bool()] = -math.inf
score = F.softmax(compat, dim=-1)
# nodes with no neighbours were softmax into nan, fix them to 0
score = torch.nan_to_num(score, 0)
# ----------- motivational brach -------------
Va = torch.matmul(score.unsqueeze(-2), torch.matmul(ve, self.AT_W_val))
v_M = torch.cat((vs, Va), -1).squeeze(-2)
v_M_final = self.AT_motivate_mlp(v_M)
# ----------- forward branch -------------
score_sort_index = torch.argsort(score, dim=-1, descending=True)
score_sort_drop_index = score_sort_index[..., :self.n_focus_on]
if self.skip_connect:
ve = torch.cat((ve, skip_connect_ze), -1)
vs = torch.cat((vs, skip_connect_zs), -1)
ve_C = gather_righthand(src=ve, index=score_sort_drop_index, check=False)
need_padding = (score_sort_drop_index.shape[-1] != self.n_focus_on)
if need_padding:
print('the n_focus param is large than input, advise: pad observation instead of pad here')
ve_C = pad_at_dim(ve_C, dim=-2, n=self.n_focus_on)
v_C_stack = torch.cat((vs, ve_C), dim=-2)
if self.adopt_selfattn:
v_C_stack = self.AT_Attention(v_C_stack, mask=None)
v_C_flat = my_view(v_C_stack, [0, 0, -1]); assert v_C_stack.dim()==4
v_C_final = self.AT_forward_mlp(v_C_flat)
return v_C_final, v_M_final
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/dl_pool.py
================================================
"""
Author: Fu Qingxu,CASIA
Description: deep learning sample manager
"""
import torch
import numpy as np
class DeepLearningPool(object):
def __init__(self, pool_size, batch_size) -> None:
super().__init__()
self.x_batch = None
self.y_batch = None
self.size = pool_size
self.batch_size = batch_size
def add_and_sample(self, x, y):
n_sample = x.shape[0]
assert n_sample > 0
if self.x_batch is None:
self.x_batch = np.zeros(shape=(self.size, *x.shape[1:]), dtype=x.dtype)
self.y_batch = np.zeros(shape=(self.size, *y.shape[1:]), dtype=y.dtype)
self.current_idx = 0
self.current_size = 0
idx = self._get_storage_idx(n_sample)
self.x_batch[idx] = x
self.y_batch[idx] = y
return self._sample()
def _get_storage_idx(self, inc=None):
inc = inc or 1
if self.current_idx + inc <= self.size:
idx = np.arange(self.current_idx, self.current_idx + inc)
self.current_idx += inc
elif self.current_idx < self.size:
overflow = inc - (self.size - self.current_idx)
idx_a = np.arange(self.current_idx, self.size)
idx_b = np.arange(0, overflow)
idx = np.concatenate([idx_a, idx_b])
self.current_idx = overflow
else:
idx = np.arange(0, inc)
self.current_idx = inc
self.current_size = min(self.size, self.current_size + inc)
if inc == 1:
idx = idx[0]
return idx
def _sample(self):
idx = np.random.randint(0, self.current_size, self.batch_size)
return self.x_batch[idx], self.y_batch[idx]
if __name__ == '__main__':
dlp = DeepLearningPool(10, 7)
res = dlp.add_and_sample(x=np.random.rand(2,2,3),y=np.array([1,2]))
print(dlp.y_batch,'res',res[1])
res = dlp.add_and_sample(x=np.random.rand(4,2,3),y=np.array([3,4,5,6]))
print(dlp.y_batch,'res',res[1])
res = dlp.add_and_sample(x=np.random.rand(3,2,3),y=np.array([7,8,9]))
print(dlp.y_batch,'res',res[1])
res = dlp.add_and_sample(x=np.random.rand(3,2,3),y=np.array([10,11,12]))
print(dlp.y_batch,'res',res[1])
res = dlp.add_and_sample(x=np.random.rand(3,2,3),y=np.array([13,14,15]))
print(dlp.y_batch,'res',res[1])
res = dlp.add_and_sample(x=np.random.rand(3,2,3),y=np.array([16,17,18]))
print(dlp.y_batch,'res',res[1])
print('end of test')
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/his.py
================================================
import matplotlib.pyplot as plt
import numpy as np
import matplotlib
# 设置matplotlib正常显示中文和负号
matplotlib.rcParams['font.sans-serif']=['SimHei'] # 用黑体显示中文
matplotlib.rcParams['axes.unicode_minus']=False # 正常显示负号
# 随机生成(10000,)服从正态分布的数据
data = np.random.randn(10000)
"""
绘制直方图
data:必选参数,绘图数据
bins:直方图的长条形数目,可选项,默认为10
normed:是否将得到的直方图向量归一化,可选项,默认为0,代表不归一化,显示频数。normed=1,表示归一化,显示频率。
facecolor:长条形的颜色
edgecolor:长条形边框的颜色
alpha:透明度
"""
plt.hist(data, bins=40, facecolor="blue", edgecolor="black", alpha=0.7)
# 显示横轴标签
plt.xlabel("区间")
# 显示纵轴标签
plt.ylabel("频数/频率")
# 显示图标题
plt.title("频数/频率分布直方图")
plt.show()
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/hyper_net.py
================================================
from re import X
import torch
import torch.nn as nn
import torch.nn.functional as F
from UTIL.tensor_ops import my_view
class HyperNet(nn.Module):
def __init__(self, **kwargs):
super(HyperNet, self).__init__()
self.x_input_dim = kwargs['x_input_dim']
self.embed_dim = kwargs['embed_dim']
self.hyper_input_dim = kwargs['hyper_input_dim']
# hyper w1 b1
self.hyper_w1 = nn.Sequential( nn.Linear(self.hyper_input_dim, self.embed_dim),
nn.ReLU(inplace=True),
nn.Linear(self.embed_dim, self.x_input_dim * self.embed_dim))
self.hyper_b1 = nn.Sequential(nn.Linear(self.hyper_input_dim, self.embed_dim))
# hyper w2 b2
self.hyper_w2 = nn.Sequential(
nn.Linear(self.hyper_input_dim, self.embed_dim),
nn.ReLU(inplace=True),
nn.Linear(self.embed_dim, self.embed_dim * self.embed_dim))
self.hyper_b2 = nn.Sequential(nn.Linear(self.hyper_input_dim, self.embed_dim),
nn.ReLU(inplace=True),
nn.Linear(self.embed_dim, 1))
def forward(self, x, hyper_x):
# x shape (thread/batch, agent, core)
# hyper_x shape (thread/batch, core)
assert hyper_x.dim() == 3
# reshape w1 into # (..., x_input_dim, embed_dim)
w1 = my_view(self.hyper_w1(hyper_x), [0, 0, self.x_input_dim, self.embed_dim])
b1 = self.hyper_b1(hyper_x).unsqueeze(-2) # b1 (thread/batch, core=embed_dim)
# Second layer
w2 = my_view(self.hyper_w2(hyper_x), [0, 0, self.embed_dim, self.embed_dim])
b2 = self.hyper_b2(hyper_x).unsqueeze(-2)
## x shape = (..., x_input_dim)
## w1 shape = (..., x_input_dim, embed_dim)
# x reshape = (..., 1, x_input_dim)
x = x.unsqueeze(-2)
hidden = F.elu(torch.matmul(x, w1) + b1) # b * t, 1, emb
# Forward (batch, 1, 32) * w2(batch, 32, 1) => y(batch, 1)
y = torch.matmul(hidden, w2) + b2 # b * t, 1, 1
return y.squeeze(-2)
class MyHyperNet(nn.Module):
def __init__(self, x_in_dim, hyber_in_dim, layer_out_dims, hyber_hid_dim):
super(MyHyperNet, self).__init__()
self.x_in_dim = x_in_dim
self.layer_out_dims = layer_out_dims
self.hyber_in_dim = hyber_in_dim
self.hyber_hid_dim = hyber_hid_dim
self.n_layer = len(self.layer_out_dims)
self.layer_dim_dict = [(x_in_dim, layer_out_dims[0])] + [(d_in, d_out) for d_in, d_out in zip(layer_out_dims[:-1], layer_out_dims[1:])]
self.weight_each_layer = nn.ModuleList([
nn.Sequential(nn.Linear(self.hyber_in_dim, self.hyber_hid_dim), nn.ReLU(inplace=True), nn.Linear(self.hyber_hid_dim, d_in * d_out))
for d_in, d_out in self.layer_dim_dict
])
self.bias_each_layer = nn.ModuleList([
nn.Sequential(nn.Linear(self.hyber_in_dim, self.hyber_hid_dim), nn.ReLU(inplace=True), nn.Linear(self.hyber_hid_dim, d_out))
for d_in, d_out in self.layer_dim_dict
])
def forward(self, x, hyper_x):
# x shape (thread/batch, agent, core)
# hyper_x shape (thread/batch, core)
assert hyper_x.dim() == 3
x = x.unsqueeze(-2)
for i in range(self.n_layer):
d_in, d_out = self.layer_dim_dict[i]
w = my_view(self.weight_each_layer[i](hyper_x), [0, 0, d_in, d_out])
b = self.bias_each_layer[i](hyper_x).unsqueeze(-2)
x = torch.matmul(x, w) + b
is_last_layer = (i==(self.n_layer-1))
if is_last_layer:
# do NOT use relu at last layer
pass
else:
x = F.relu(x, inplace=True)
return x.squeeze(-2)
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/logit2act.py
================================================
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions.categorical import Categorical
from UTIL.tensor_ops import my_view, Args2tensor_Return2numpy, Args2tensor
from UTIL.tensor_ops import pt_inf
"""
network initialize
"""
class Logit2Act(nn.Module):
def __init__(self, *args, **kwargs):
super().__init__()
def _logit2act_rsn(self, logits_agent_cluster, eval_mode, greedy, eval_actions=None, avail_act=None, eprsn=None):
if avail_act is not None: logits_agent_cluster = torch.where(avail_act>0, logits_agent_cluster, -pt_inf())
act_dist = self.ccategorical.feed_logits(logits_agent_cluster)
if not greedy: act = self.ccategorical.sample(act_dist, eprsn) if not eval_mode else eval_actions
else: act = torch.argmax(act_dist.probs, axis=2)
# the policy gradient loss will feedback from here
actLogProbs = self._get_act_log_probs(act_dist, act)
# sum up the log prob of all agents
distEntropy = act_dist.entropy().mean(-1) if eval_mode else None
return act, actLogProbs, distEntropy, act_dist.probs
def _logit2act(self, logits_agent_cluster, eval_mode, greedy, eval_actions=None, avail_act=None, **kwargs):
if avail_act is not None: logits_agent_cluster = torch.where(avail_act>0, logits_agent_cluster, -pt_inf())
act_dist = Categorical(logits = logits_agent_cluster)
if not greedy: act = act_dist.sample() if not eval_mode else eval_actions
else: act = torch.argmax(act_dist.probs, axis=2)
actLogProbs = self._get_act_log_probs(act_dist, act) # the policy gradient loss will feedback from here
# sum up the log prob of all agents
distEntropy = act_dist.entropy().mean(-1) if eval_mode else None
return act, actLogProbs, distEntropy, act_dist.probs
@staticmethod
def _get_act_log_probs(distribution, action):
return distribution.log_prob(action.squeeze(-1)).unsqueeze(-1)
@Args2tensor_Return2numpy
def act(self, *args, **kargs):
return self._act(*args, **kargs)
@Args2tensor
def evaluate_actions(self, *args, **kargs):
return self._act(*args, **kargs, eval_mode=True)
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/mlp.py
================================================
import torch
import torch.nn as nn
import torch.nn.functional as F
from .norm import DynamicNorm
class SimpleMLP(nn.Module):
def __init__(self, in_dim, out_dim, hidden_dim=128, use_normalization=False):
super().__init__()
activation_func = nn.ReLU
h_dim = hidden_dim
if use_normalization:
print('test DynamicNorm')
self.mlp = nn.Sequential(
DynamicNorm(in_dim, only_for_last_dim=True, exclude_one_hot=True),
nn.Linear(in_dim, h_dim),
activation_func(inplace=True),
nn.Linear(h_dim, out_dim)
)
else:
self.mlp = nn.Sequential(
nn.Linear(in_dim, h_dim),
activation_func(inplace=True),
nn.Linear(h_dim, out_dim)
)
def forward(self,x):
return self.mlp(x)
class ResLinear(nn.Module):
def __init__(self, io_dim, h_dim, need_input_tf=False, input_tf_dim=None, inplace_relu=True) -> None:
super(ResLinear, self).__init__()
self.need_input_tf = need_input_tf
if need_input_tf:
self.f0 = nn.Linear(input_tf_dim, io_dim)
self.f1 = nn.Linear(io_dim, h_dim)
self.lkrelu = nn.ReLU(inplace=True) if inplace_relu else nn.ReLU(inplace=False)
self.f2 = nn.Linear(h_dim, io_dim)
def forward(self, xo):
if self.need_input_tf:
xo = self.f0(xo)
x = self.lkrelu(self.f1(xo))
x = self.f2(x) + xo
x = self.lkrelu(x)
return x
class LinearFinal(nn.Module):
__constants__ = ['in_features', 'out_features']
in_features: int
out_features: int
weight: torch.Tensor
def __init__(self, in_features: int, out_features: int, bias: bool = True) -> None:
super(LinearFinal, self).__init__()
self.in_features = in_features
self.out_features = out_features
self.weight = nn.Parameter(torch.Tensor(out_features, in_features))
if bias:
self.bias = nn.Parameter(torch.Tensor(out_features))
else:
self.register_parameter('bias', None)
def forward(self, input: torch.Tensor) -> torch.Tensor:
return F.linear(input, self.weight, self.bias)
def extra_repr(self) -> str:
return 'in_features={}, out_features={}, bias={}'.format(
self.in_features, self.out_features, self.bias is not None
)
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/net_manifest.py
================================================
import torch.nn as nn
def weights_init(m):
def init_Linear(m, final_layer=False):
nn.init.orthogonal_(m.weight.data)
if final_layer:nn.init.orthogonal_(m.weight.data, gain=0.01)
if m.bias is not None: nn.init.uniform_(m.bias.data, a=-0.02, b=0.02)
initial_fn_dict = {
'Net': None,
'NetCentralCritic': None,
'DataParallel':None,
'BatchNorm1d':None,
'Concentration':None,
'ConcentrationHete':None,
'Pnet':None,
'Sequential':None,
'DataParallel':None,
'Tanh':None,
'ModuleList':None,
'ModuleDict':None,
'MultiHeadAttention':None,
'SimpleMLP':None,
'SimpleAttention':None,
'SelfAttention_Module':None,
'ReLU':None,
'Softmax':None,
'DynamicNorm':None,
'DynamicNormFix':None,
'EXTRACT':None,
'LinearFinal':lambda m:init_Linear(m, final_layer=True),
'Linear':init_Linear,
'ResLinear':None,
'LeakyReLU':None,
'HyperNet':None,
'MyHyperNet':None,
'DivTree':None,
}
classname = m.__class__.__name__
assert classname in initial_fn_dict.keys(), ('how to handle the initialization of this class? ', classname)
init_fn = initial_fn_dict[classname]
if init_fn is None: return
init_fn(m)
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/norm.py
================================================
"""
CASIA, fuqingxu
live vector normalization using pytorch,
therefore the parameter of normalization (mean and var)
can be save together with network parameters
light up exclude_one_hot=True to prevent onehot component being normalized
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions.categorical import Categorical
from torch.distributions.multivariate_normal import MultivariateNormal
from UTIL.tensor_ops import my_view
from UTIL.tensor_ops import Args2tensor_Return2numpy
class DynamicNorm(nn.Module):
# ! warning! this module will mess with multi-gpu setting!!
def __init__(self, input_size, only_for_last_dim, exclude_one_hot=True, exclude_nan=False):
super().__init__()
assert only_for_last_dim
self.exclude_one_hot = exclude_one_hot
self.mean = nn.Parameter(torch.zeros(input_size, requires_grad=False), requires_grad=False)
self.var = nn.Parameter(torch.ones(input_size, requires_grad=False), requires_grad=False)
self.n_sample = nn.Parameter(torch.zeros(1, requires_grad=False, dtype=torch.long), requires_grad=False)
if self.exclude_one_hot:
self.one_hot_filter = nn.Parameter(torch.ones(input_size, requires_grad=False, dtype=torch.bool), requires_grad=False)
self.input_size = input_size
self.exclude_nan = exclude_nan
self.patience = 1000
def forward(self, x, get_mu_var=False):
assert self.input_size == x.shape[-1], ('self.input_size',self.input_size,'x.shape[-1]',x.shape[-1])
_2dx = x.detach().reshape(-1, self.input_size)
if self.exclude_nan: _2dx = _2dx[~torch.isnan(_2dx).any(axis=-1)]
this_batch_size = _2dx.shape[0]
# assert this_batch_size>=1
if this_batch_size<=0:
print('Warning! An empty batch just being normalized')
x = torch.clip_((x - self.mean) / torch.sqrt_(self.var + 1e-8), -10, 10)
return x
if self.training:
with torch.no_grad():
this_batch_mean = torch.mean(_2dx, dim=0)
this_batch_var = torch.var(_2dx, dim=0, unbiased=False)
if torch.isnan(this_batch_var).any():
assert False, ('nan value detected in normalization! but you can turn on exclude_nan')
assert _2dx.dim() == 2
delta = this_batch_mean - self.mean
tot_count = self.n_sample + this_batch_size
new_mean = self.mean + delta * this_batch_size / tot_count
m_a = self.var * (self.n_sample)
m_b = this_batch_var * (this_batch_size)
M2 = m_a + m_b + torch.square_(delta) * self.n_sample * this_batch_size / (self.n_sample + this_batch_size)
new_var = M2 / (self.n_sample + this_batch_size)
if self.exclude_one_hot: # 滤除-1,0和1的点位
self.one_hot_filter.data &= ~(((_2dx != 0) & (_2dx != 1) & (_2dx != -1)).any(dim=0))
self.mean.data = torch.where(self.one_hot_filter, self.mean, new_mean) if self.exclude_one_hot else new_mean # new_mean
new_var_clip = torch.clamp(new_var, min=0.01, max=1000)
self.var.data = torch.where(self.one_hot_filter, self.var, new_var_clip) if self.exclude_one_hot else new_var_clip
self.n_sample.data = tot_count
if get_mu_var:
return self.mean, self.var
x = torch.clip_((x - self.mean) / torch.sqrt_(self.var + 1e-8), -10, 10)
return x
# @Args2tensor_Return2numpy
# def get_mean_var(self, x):
# return self.forward(x, get_mu_var=True)
class DynamicNormFix(nn.Module):
# ! warning! this module will mess with multi-gpu setting!!
def __init__(self, input_size, only_for_last_dim, exclude_one_hot=True, exclude_nan=False):
super().__init__()
assert only_for_last_dim
self.exclude_one_hot = exclude_one_hot
self.mean = nn.Parameter(torch.zeros(input_size, requires_grad=False), requires_grad=False)
self.var = nn.Parameter(torch.ones(input_size, requires_grad=False), requires_grad=False)
self.var_fix = nn.Parameter(torch.ones(input_size, requires_grad=False), requires_grad=False)
self.min = nn.Parameter(torch.ones(input_size, requires_grad=False)+float('inf'), requires_grad=False)
self.max = nn.Parameter(torch.ones(input_size, requires_grad=False)-float('inf'), requires_grad=False)
self.n_sample = nn.Parameter(torch.zeros(1, requires_grad=False, dtype=torch.long), requires_grad=False)
if self.exclude_one_hot:
self.one_hot_filter = nn.Parameter(torch.ones(input_size, requires_grad=False, dtype=torch.bool), requires_grad=False)
self.input_size = input_size
self.exclude_nan = exclude_nan
self.patience = 1000
self.var_fix_wait = 1000
# var fixing, T2 is maximum x abs value after normalization
self.T1 = 5
self.T2 = 10
self.TD = (self.T2**2 - self.T1**2)/self.T2**2
self.first_run = True
self.debug = True
# 兼容np
@Args2tensor_Return2numpy
def np_forward(self, x, freeze=False, get_mu_var=False):
return self.forward(x, freeze, get_mu_var)
def forward(self, x, freeze=False, get_mu_var=False):
assert self.input_size == x.shape[-1], ('self.input_size',self.input_size,'x.shape[-1]',x.shape[-1])
_2dx = x.detach().reshape(-1, self.input_size)
if self.exclude_nan: _2dx = _2dx[~torch.isnan(_2dx).any(axis=-1)]
_2dx_view = my_view(_2dx, [-1, 0])
this_batch_size = _2dx.shape[0]
# assert this_batch_size>=1
if this_batch_size<=0:
print('Warning! An empty batch just being normalized')
x = torch.clip_((x - self.mean) / torch.sqrt_(self.var_fix + 1e-8), -10, 10)
return x
if self.training and (not freeze):
with torch.no_grad():
this_batch_mean = torch.mean(_2dx, dim=0)
this_batch_var = torch.var(_2dx, dim=0, unbiased=False)
if torch.isnan(this_batch_var).any():
assert False, ('nan value detected in normalization! but you can turn on exclude_nan')
assert _2dx.dim() == 2
delta = this_batch_mean - self.mean
tot_count = self.n_sample + this_batch_size
new_mean = self.mean + delta * this_batch_size / tot_count
m_a = self.var * (self.n_sample)
m_b = this_batch_var * (this_batch_size)
M2 = m_a + m_b + torch.square_(delta) * self.n_sample * this_batch_size / (self.n_sample + this_batch_size)
new_var = M2 / (self.n_sample + this_batch_size)
if self.exclude_one_hot: # 滤除-1,0和1的点位
self.one_hot_filter.data &= ~(((_2dx != 0) & (_2dx != 1) & (_2dx != -1)).any(dim=0))
self.mean.data = torch.where(self.one_hot_filter, self.mean, new_mean) if self.exclude_one_hot else new_mean # new_mean
# if self.patience > 0: self.check_errors(_2dx, new_var)
self.var.data = torch.where(self.one_hot_filter, self.var, new_var) if self.exclude_one_hot else new_var
# begin fix variance
max_tmp, _ = _2dx_view.max(0)
min_tmp, _ = _2dx_view.min(0)
# if self.first_run:
if self.patience > 0:
self.patience -= 1
self.first_run = False
self.max.data = torch.maximum(max_tmp, self.max)
self.min.data = torch.minimum(min_tmp, self.min)
else:
# self.max.data = torch.maximum(max_tmp, self.max)
# self.min.data = torch.minimum(min_tmp, self.min)
self.max.data = self.max + (torch.maximum(max_tmp, self.max)-self.max) * this_batch_size / tot_count
self.min.data = self.min + (torch.minimum(min_tmp, self.min)-self.min) * this_batch_size / tot_count
# # if self.debug: self.mcv.rec(max_tmp.squeeze().item(), 'batch max')
# # if self.debug: self.mcv.rec(min_tmp.squeeze().item(), 'batch min')
# # if self.debug: self.mcv.rec(torch.maximum(max_tmp, self.max).squeeze().item(), 'hist max')
# # if self.debug: self.mcv.rec(torch.minimum(min_tmp, self.min).squeeze().item(), 'hist min')
# if self.debug: self.mcv.rec(self.max.data, 'fixed max')
# if self.debug: self.mcv.rec(self.min.data, 'fixed min')
# if self.debug: self.mcv.rec_show()
dm = torch.maximum((self.max - self.mean), (self.mean - self.min))
# std_th_1 = dm / self.T1
std_threshold_2 = dm / self.T2
# var1 = std_th_1**2
var2 = std_threshold_2**2
leak = self.TD * self.var + var2 # leak = (var1 - var2)/(var1) *self.var + var2
new_var_fix = torch.maximum(self.var, leak)
self.var_fix.data = torch.where(self.one_hot_filter, self.var_fix, new_var_fix) if self.exclude_one_hot else new_var_fix
# if self.debug: self.mcv.rec(self.var.data, 'var')
# if self.debug: self.mcv.rec(self.var_fix.data, 'var fix')
# if self.debug: self.mcv.rec(self.var_fix.data-self.var.data, 'delta var')
# if self.debug: self.mcv.rec((1 - self.mean) / torch.sqrt_(self.var_fix + 1e-8), 'base line +1')
# if self.debug: self.mcv.rec((-1 - self.mean) / torch.sqrt_(self.var_fix + 1e-8), 'base line -1')
# if self.debug: self.mcv.rec((10 - self.mean) / torch.sqrt_(self.var_fix + 1e-8), 'base line +10')
# if self.debug: self.mcv.rec((-10 - self.mean) / torch.sqrt_(self.var_fix + 1e-8), 'base line -10')
# !!! qq = self.var_fix.data-self.var.data
# !!! if self.patience > 0 and self.patience < 800 and (not (qq==0).all()):
# !!! print('[norm.py] Input issue: cannot be well expressed by normal distribution', torch.where(qq!=0))
self.n_sample.data = tot_count
# t = (_2dx_view - self.mean) / torch.sqrt_(self.var_fix + 1e-8)
if get_mu_var:
return self.mean, self.var_fix
return (x - self.mean) / torch.sqrt_(self.var_fix + 1e-8)
# def check_errors(self, _2dx, new_var):
# self.patience -= 1
'''
test script
import torch, time
from ALGORITHM.common.norm import DynamicNormFix
input_size = 1
only_for_last_dim = True
dynamic_norm = DynamicNormFix(input_size, only_for_last_dim, exclude_one_hot=True, exclude_nan=False)
for _ in range(101100):
# mask = (torch.randn(60, 1, out=None) > 0)
# x = torch.where(mask,
# torch.randn(60, 1, out=None)*10,
# torch.randn(60, 1, out=None)*5,
# )
# 左边
std = 0.01; offset = -0.01; num = 5
x3 = torch.randn(num, 1, out=None) * std + offset
# 中间
std = 0.01; offset = 0; num = 500
x2 = torch.randn(num, 1, out=None) * std + offset
# 右边
std = 0.01; offset = 1; num = 5
x1 = torch.randn(num, 1, out=None) * std + offset
# # 左边
# std = 1; offset = -10; num = 5
# x3 = torch.randn(num, 1, out=None) * std + offset
# # 中间
# std = 1; offset = 5; num = 500
# x2 = torch.randn(num, 1, out=None) * std + offset
# # 右边
# std = 1; offset = 5; num = 5
# x1 = torch.randn(num, 1, out=None) * std + offset
x = torch.cat((x1,x2,x3), 0)
y = dynamic_norm(x)
print(y)
time.sleep(60)
'''
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/pca.py
================================================
import numpy as np
def pca(samples, target_dim):
assert len(samples.shape) == 2
data = samples - np.mean(samples,axis=0) # mean at batch dim
covMat = np.cov(data,rowvar=0)
fValue,fVector = np.linalg.eig(covMat)
fValueSort = np.argsort(-fValue)
fValueTopN = fValueSort[:target_dim]
fvectormat = fVector[:,fValueTopN]
down_dim_data = np.dot(data, fvectormat)
return down_dim_data
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/ppo_sampler.py
================================================
import torch, math
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import numpy as np
from random import randint, sample
from torch.utils.data.sampler import BatchSampler, SubsetRandomSampler
from UTIL.colorful import *
from UTIL.tensor_ops import _2tensor, __hash__, repeat_at, _2cpu2numpy
from UTIL.tensor_ops import my_view, scatter_with_nan, sample_balance
from config import GlobalConfig as cfg
from UTIL.gpu_share import GpuShareUnit
class TrajPoolSampler():
def __init__(self, n_div, traj_pool, flag, req_dict, req_dict_rename, prevent_batchsize_oom=False, mcv=None):
self.n_pieces_batch_division = n_div
self.prevent_batchsize_oom = prevent_batchsize_oom
self.mcv = mcv
if self.prevent_batchsize_oom:
assert self.n_pieces_batch_division==1, 'self.n_pieces_batch_division should be 1'
self.num_batch = None
self.container = {}
self.warned = False
assert flag=='train'
# req_dict = ['obs', 'state', 'action', 'actionLogProb', 'return', 'reward', 'threat', 'value']
# req_dict_rename = ['obs', 'state', 'action', 'actionLogProb', 'return', 'reward', 'threat', 'state_value']
if cfg.ScenarioConfig.AvailActProvided:
req_dict.append('avail_act')
req_dict_rename.append('avail_act')
return_rename = "return"
value_rename = "state_value"
advantage_rename = "advantage"
# replace 'obs' to 'obs > xxxx'
for key_index, key in enumerate(req_dict):
key_name = req_dict[key_index]
key_rename = req_dict_rename[key_index]
if not hasattr(traj_pool[0], key_name):
real_key_list = [real_key for real_key in traj_pool[0].__dict__ if (key_name+'>' in real_key)]
assert len(real_key_list) > 0, ('check variable provided!', key,key_index)
for real_key in real_key_list:
mainkey, subkey = real_key.split('>')
req_dict.append(real_key)
req_dict_rename.append(key_rename+'>'+subkey)
self.big_batch_size = -1 # vector should have same length, check it!
# load traj into a 'container'
for key_index, key in enumerate(req_dict):
key_name = req_dict[key_index]
key_rename = req_dict_rename[key_index]
if not hasattr(traj_pool[0], key_name): continue
set_item = np.concatenate([getattr(traj, key_name) for traj in traj_pool], axis=0)
if not (self.big_batch_size==set_item.shape[0] or (self.big_batch_size<0)):
print('error')
assert self.big_batch_size==set_item.shape[0] or (self.big_batch_size<0), (key,key_index)
self.big_batch_size = set_item.shape[0]
self.container[key_rename] = set_item # assign value to key_rename
# normalize advantage inside the batch
self.container[advantage_rename] = self.container[return_rename] - self.container[value_rename]
self.container[advantage_rename] = ( self.container[advantage_rename] - self.container[advantage_rename].mean() ) / (self.container[advantage_rename].std() + 1e-5)
# size of minibatch for each agent
self.mini_batch_size = math.ceil(self.big_batch_size / self.n_pieces_batch_division)
# do once
self.do_once_fin = False
def __len__(self):
return self.n_pieces_batch_division
def reminder(self, n_sample):
if not self.do_once_fin:
self.do_once_fin = True
drop_percent = (self.big_batch_size-n_sample) / self.big_batch_size*100
if self.mcv is not None: self.mcv.rec(drop_percent, 'drop percent')
if drop_percent > 20:
print_ = print亮红
print_('droping %.1f percent samples..'%(drop_percent))
assert False, "GPU OOM!"
else:
print_ = print
print_('droping %.1f percent samples..'%(drop_percent))
def get_sampler(self):
if not self.prevent_batchsize_oom:
#
sampler = BatchSampler(SubsetRandomSampler(range(self.big_batch_size)), self.mini_batch_size, drop_last=False)
else:
max_n_sample = self.determine_max_n_sample()
n_sample = min(self.big_batch_size, max_n_sample)
self.reminder(n_sample)
sampler = BatchSampler(SubsetRandomSampler(range(n_sample)), n_sample, drop_last=False)
return sampler
def reset_and_get_iter(self):
self.sampler = self.get_sampler()
for indices in self.sampler:
selected = {}
for key in self.container:
selected[key] = self.container[key][indices]
for key in [key for key in selected if '>' in key]:
# re-combine child key with its parent
mainkey, subkey = key.split('>')
if not mainkey in selected: selected[mainkey] = {}
selected[mainkey][subkey] = selected[key]
del selected[key]
yield selected
def determine_max_n_sample(self):
assert self.prevent_batchsize_oom
if not hasattr(TrajPoolSampler,'MaxSampleNum'):
# initialization
TrajPoolSampler.MaxSampleNum = [int(self.big_batch_size*(i+1)/50) for i in range(50)]
max_n_sample = self.big_batch_size
elif TrajPoolSampler.MaxSampleNum[-1] > 0:
# meaning that oom never happen, at least not yet
# only update when the batch size increases
if self.big_batch_size > TrajPoolSampler.MaxSampleNum[-1]:
TrajPoolSampler.MaxSampleNum.append(self.big_batch_size)
max_n_sample = self.big_batch_size
else:
# meaning that oom already happened, choose TrajPoolSampler.MaxSampleNum[-2] to be the limit
assert TrajPoolSampler.MaxSampleNum[-2] > 0
max_n_sample = TrajPoolSampler.MaxSampleNum[-2]
return max_n_sample
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/rl_alg_base.py
================================================
import time
from UTIL.tensor_ops import __hash__, repeat_at
from UTIL.colorful import *
from .alg_base import AlgorithmBase
# model IO
class RLAlgorithmBase(AlgorithmBase):
def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
super().__init__(n_agent, n_thread, space, mcv, team)
# data integraty check
self._unfi_frag_ = None
# Skip currupt data integraty check after this patience is exhausted
self.patience = 1000
def interact_with_env(self, team_intel):
raise NotImplementedError
def save_model(self, update_cnt, info=None):
raise NotImplementedError
def process_framedata(self, traj_framedata):
raise NotImplementedError
# Rollout Processor 准备提交Rollout,以下划线开头和结尾的键值需要对齐(self.n_thread, ...)
# note that keys starting with _ must have shape (self.n_thread, ...), details see fn:mask_paused_env()
def process_framedata(self, traj_framedata):
'''
hook is called when reward and next moment observation is ready,
now feed them into trajectory manager.
Rollout Processor | 准备提交Rollout, 以下划线开头和结尾的键值需要对齐(self.n_thread, ...)
note that keys starting with _ must have shape (self.n_thread, ...), details see fn:mask_paused_env()
'''
# strip info, since it is not array
items_to_pop = ['info', 'Latest-Obs']
for k in items_to_pop:
if k in traj_framedata:
traj_framedata.pop(k)
# the agent-wise reward is supposed to be the same, so averge them
if self.ScenarioConfig.RewardAsUnity:
traj_framedata['reward'] = repeat_at(traj_framedata['reward'], insert_dim=-1, n_times=self.n_agent)
# change the name of done to be recognised (by trajectory manager)
traj_framedata['_DONE_'] = traj_framedata.pop('done')
traj_framedata['_TOBS_'] = traj_framedata.pop(
'Terminal-Obs-Echo') if 'Terminal-Obs-Echo' in traj_framedata else None
# mask out pause thread
traj_framedata = self.mask_paused_env(traj_framedata)
# put the frag into memory
self.batch_traj_manager.feed_traj(traj_framedata)
def check_reward_type(self, AlgorithmConfig):
if self.ScenarioConfig.RewardAsUnity != AlgorithmConfig.TakeRewardAsUnity:
assert self.ScenarioConfig.RewardAsUnity
assert not AlgorithmConfig.TakeRewardAsUnity
print亮紫(
'Warning, the scenario (MISSION) provide `RewardAsUnity`, but AlgorithmConfig does not `TakeRewardAsUnity` !')
print亮紫(
'If you continue, team reward will be duplicated to serve as individual rewards, wait 3s to proceed...')
time.sleep(3)
def mask_paused_env(self, frag):
running = ~frag['_SKIP_']
if running.all():
return frag
for key in frag:
if not key.startswith('_') and hasattr(frag[key], '__len__') and len(frag[key]) == self.n_thread:
frag[key] = frag[key][running]
return frag
'''
Get event from hmp task runner, called when each test rotinue is complete.
'''
def on_notify(self, message, **kargs):
self.save_model(
update_cnt=self.traj_manager.update_cnt,
info=str(kargs)
)
'''
function to be called when reward is received
'''
def commit_traj_frag(self, unfi_frag, req_hook=True):
assert self._unfi_frag_ is None
self._unfi_frag_ = unfi_frag
self._check_data_hash() # check data integraty
if req_hook:
# leave a hook
return self.traj_waiting_hook
else:
return None
def traj_waiting_hook(self, new_frag):
'''
This function will be called from <multi_team.py::deal_with_hook()>
hook is called when reward and next moment observation is ready
'''
# do data curruption check at beginning, this is important!
self._check_data_curruption()
# finish the frame data with new data feedin
fi_frag = self._unfi_frag_
fi_frag.update(new_frag)
# call upper level function to deal with frame data
self.process_framedata(traj_framedata=fi_frag)
# delete data reference
self._unfi_frag_ = None
def _no_hook(self, new_frag):
return
# protect data from overwriting
def _check_data_hash(self):
if self.patience > 0:
self.patience -= 1
self.hash_db = {}
# for debugging, to detect write protection error
for key in self._unfi_frag_:
item = self._unfi_frag_[key]
if isinstance(item, dict):
self.hash_db[key] = {}
for subkey in item:
subitem = item[subkey]
self.hash_db[key][subkey] = __hash__(subitem)
else:
self.hash_db[key] = __hash__(item)
# protect data from overwriting
def _check_data_curruption(self):
if self.patience > 0:
self.patience -= 1
assert self._unfi_frag_ is not None
assert self.hash_db is not None
for key in self._unfi_frag_:
item = self._unfi_frag_[key]
if isinstance(item, dict):
for subkey in item:
subitem = item[subkey]
assert self.hash_db[key][subkey] == __hash__(subitem), ('Currupted data!')
else:
assert self.hash_db[key] == __hash__(item), ('Currupted data!')
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/traj.py
================================================
# cython: language_level=3
import numpy as np
from UTIL.colorful import *
from UTIL.tensor_ops import __hash__
class TRAJ_BASE():
key_data_type = {}
key_data_shape = {}
max_mem_length = -1
def __init__(self, traj_limit, env_id):
self.traj_limit = traj_limit
self.env_id = env_id
self.readonly_lock = False
self.key_dict = []
self.time_pointer = 0
self.need_reward_bootstrap = False
self.deprecated_flag = False
# remember something in a time step, add it to trajectory
def remember(self, key, content):
assert not self.readonly_lock
if not (key in self.key_dict) and (content is not None):
self.init_track(key=key, first_content=content)
getattr(self, key)[self.time_pointer] = content
elif not (key in self.key_dict) and (content is None):
self.init_track_none(key=key)
elif (key in self.key_dict) and (content is not None):
getattr(self, key)[self.time_pointer] = content
else:
pass
# duplicate/rename a trajectory
def copy_track(self, origin_key, new_key):
if hasattr(self, origin_key):
origin_handle = getattr(self, origin_key)
setattr(self, new_key, origin_handle.copy())
new_handle = getattr(self, new_key)
self.key_dict.append(new_key)
#return origin_handle, new_handle
else:
real_key_list = [real_key for real_key in self.__dict__ if (origin_key+'>' in real_key)]
assert len(real_key_list)>0, ('this key does not exist (yet), check:', origin_key)
for real_key in real_key_list:
mainkey, subkey = real_key.split('>')
self.copy_track(real_key, (new_key+'>'+subkey))
#return
# make sure dtype is ok
def check_type_shape(self, key, first_content=None):
if first_content is not None:
content_type = first_content.dtype
content_shape = first_content.shape
if key in TRAJ_BASE.key_data_type:
assert TRAJ_BASE.key_data_type[key] == content_type
else:
TRAJ_BASE.key_data_type[key] = content_type
TRAJ_BASE.key_data_shape[key] = content_shape
return content_type, content_shape
assert key in TRAJ_BASE.key_data_type
return TRAJ_BASE.key_data_type[key], TRAJ_BASE.key_data_shape[key]
# create track, executed used when a key showing up for the first time in 'self.remember'
def init_track(self, key, first_content):
content = first_content
self.check_type_shape(key, first_content)
assert isinstance(content, np.ndarray) or isinstance(content, float), (key, content.__class__)
tensor_size = ((self.traj_limit,) + tuple(content.shape))
set_item = np.zeros(shape=tensor_size, dtype=content.dtype)
set_item[:] = np.nan if np.issubdtype(content.dtype, np.floating) else 0
setattr(self, key, set_item)
self.key_dict.append(key)
# key pop up yet content is None,
# read dtype from history dtype dictionary to fill the hole
def init_track_none(self, key):
content_dtype, content_shape = self.check_type_shape(key)
tensor_size = ((self.traj_limit,) + tuple(content_shape))
set_item = np.zeros(shape=tensor_size, dtype=content_dtype)
set_item[:] = np.nan if np.issubdtype(content_dtype, np.floating) else 0
setattr(self, key, set_item)
self.key_dict.append(key)
# push the time pointer forward, before you call 'self.remember' again to fill t+1 data
def time_shift(self):
assert self.time_pointer < self.traj_limit
self.time_pointer += 1
# cut trajectory tail, when the number of episode time step < traj_limit
def cut_tail(self):
TJ = lambda key: getattr(self, key)
self.readonly_lock = True
n_frame = self.time_pointer
# check is buffer size too big
if n_frame > TRAJ_BASE.max_mem_length:
TRAJ_BASE.max_mem_length = n_frame
print('max_mem_length:%d, traj_limit:%d'%(TRAJ_BASE.max_mem_length, self.traj_limit))
# clip tail
for key in self.key_dict: setattr(self, key, TJ(key)[:n_frame])
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/traj_gae.py
================================================
# cython: language_level=3
import numpy as np
from ALGORITHM.common.traj import TRAJ_BASE
import copy
from UTIL.colorful import *
from UTIL.tensor_ops import my_view, repeat_at, gather_righthand
class trajectory(TRAJ_BASE):
dead_mask_check = True # confirm mask ok
def __init__(self, traj_limit, env_id, alg_cfg):
super().__init__(traj_limit, env_id)
self.agent_alive_reference = 'alive'
self.alg_cfg = alg_cfg
def early_finalize(self):
assert not self.readonly_lock # unfinished traj
self.need_reward_bootstrap = True
def set_terminal_obs(self, tobs):
self.tobs = copy.deepcopy(tobs)
def cut_tail(self):
# 删去多余的预留空间
super().cut_tail()
TJ = lambda key: getattr(self, key)
# 进一步地, 根据这个轨迹上的NaN,删除所有无效时间点
agent_alive = getattr(self, self.agent_alive_reference)
assert len(agent_alive.shape) == 2, "shoud be 2D (time, agent)/dead_or_alive"
if self.need_reward_bootstrap:
assert False, ('it should not go here if everything goes as expected')
# deprecated if nothing in it
p_valid = agent_alive.any(axis=-1)
p_invalid = ~p_valid
is_fully_valid_traj = (p_valid[-1] == True)
# assert p_valid[-1] == True, 如果有三只队伍,很有可能出现一只队伍全体阵亡,但游戏仍未结束的情况
if p_invalid.all(): #invalid traj
self.deprecated_flag = True
return
if not is_fully_valid_traj:
# adjust reward position if not fully valid
reward = TJ('reward')
for i in reversed(range(self.time_pointer)):
if p_invalid[i] and i != 0: # invalid, push reward forward
reward[i-1] += reward[i]; reward[i] = np.nan
setattr(self, 'reward', reward)
# clip NaN
for key in self.key_dict: setattr(self, key, TJ(key)[p_valid])
if not is_fully_valid_traj:
# reset time pointer
self.time_pointer = p_valid.sum()
# all done
return
def reward_push_forward(self, dead_mask):
# self.new_reward = self.reward.copy()
if self.alg_cfg.gamma_in_reward_forwarding:
gamma = self.alg_cfg.gamma_in_reward_forwarding_value
for i in reversed(range(self.time_pointer)):
if i==0: continue
self.reward[i-1] += np.where(dead_mask[i], self.reward[i]*gamma, 0) # if dead_mask[i]==True, this frame is invalid, move reward forward, set self.reward[i] to 0
self.reward[i] = np.where(dead_mask[i], 0, self.reward[i]) # if dead_mask[i]==True, this frame is invalid, move reward forward, set self.reward[i] to 0
else:
for i in reversed(range(self.time_pointer)):
if i==0: continue
self.reward[i-1] += np.where(dead_mask[i], self.reward[i], 0) # if dead_mask[i]==True, this frame is invalid, move reward forward, set self.reward[i] to 0
self.reward[i] = np.where(dead_mask[i], 0, self.reward[i]) # if dead_mask[i]==True, this frame is invalid, move reward forward, set self.reward[i] to 0
return
# new finalize
def finalize(self):
self.readonly_lock = True
assert not self.deprecated_flag
TJ = lambda key: getattr(self, key)
assert not np.isnan(TJ('reward')).any()
# deadmask
agent_alive = getattr(self, self.agent_alive_reference)
dead_mask = ~agent_alive
if trajectory.dead_mask_check:
trajectory.dead_mask_check = False
if not dead_mask.any():
assert False, "Are you sure agents cannot die? If so, delete this check."
self.reward_push_forward(dead_mask) # push terminal reward forward 38 42 54
threat = np.zeros(shape=dead_mask.shape) - 1
assert dead_mask.shape[0] == self.time_pointer
for i in reversed(range(self.time_pointer)):
# threat[:(i+1)] 不包含threat[(i+1)]
if i+1 < self.time_pointer:
threat[:(i+1)] += (~(dead_mask[i+1]&dead_mask[i])).astype(np.int)
elif i+1 == self.time_pointer:
threat[:] += (~dead_mask[i]).astype(np.int)
SAFE_LIMIT = 8
threat = np.clip(threat, -1, SAFE_LIMIT)
setattr(self, 'threat', np.expand_dims(threat, -1))
# ! Use GAE to calculate return
if self.alg_cfg.use_policy_resonance:
self.gae_finalize_return_pr(reward_key='reward', value_key='BAL_value_all_level', new_return_name='BAL_return_all_level')
else:
self.gae_finalize_return(reward_key='reward', value_key='value', new_return_name='return')
return
def gae_finalize_return(self, reward_key, value_key, new_return_name):
# ------- gae parameters -------
gamma = self.alg_cfg.gamma
tau = self.alg_cfg.tau
# ------- -------------- -------
rewards = getattr(self, reward_key)
value = getattr(self, value_key)
# ------- -------------- -------
length = rewards.shape[0]
assert rewards.shape[0]==value.shape[0]
# if dimension not aligned
if rewards.ndim == value.ndim-1: rewards = np.expand_dims(rewards, -1)
# initalize two more tracks
setattr(self, new_return_name, np.zeros_like(value))
self.key_dict.append(new_return_name)
# ------- -------------- -------
returns = getattr(self, new_return_name)
boot_strap = 0 if not self.need_reward_bootstrap else self.boot_strap_value['bootstrap_'+value_key]
for step in reversed(range(length)):
if step==(length-1): # 最后一帧
value_preds_delta = rewards[step] + gamma * boot_strap - value[step]
gae = value_preds_delta
else:
value_preds_delta = rewards[step] + gamma * value[step + 1] - value[step]
gae = value_preds_delta + gamma * tau * gae
returns[step] = gae + value[step]
def gae_finalize_return_pr(self, reward_key, value_key, new_return_name):
# ------- gae parameters -------
gamma = self.alg_cfg.gamma
tau = self.alg_cfg.tau
# ------- -------------- -------
BAL_value_all_level = copy.deepcopy(getattr(self, value_key))
# reshape to (batch, agent*distribution_precision, 1)
value = my_view(BAL_value_all_level, [0, -1, 1])
# ------- ------- reshape reward ------- -------
rewards_cp = copy.deepcopy(getattr(self, reward_key))
# if dimension not aligned
if rewards_cp.ndim == value.ndim-1: rewards_cp = np.expand_dims(rewards_cp, -1)
assert rewards_cp.shape[-1] == 1
n_agent = rewards_cp.shape[-2]
assert BAL_value_all_level.shape[-2] == n_agent
assert BAL_value_all_level.shape[-1] == self.alg_cfg.distribution_precision
rewards_cp = repeat_at(rewards_cp.squeeze(-1), -1, self.alg_cfg.distribution_precision)
rewards_cp = my_view(rewards_cp, [0, -1, 1])
# ------- -------------- -------
length = rewards_cp.shape[0]
assert rewards_cp.shape[0]==value.shape[0]
# ------- -------------- -------
returns = np.zeros_like(value)
boot_strap = 0 if not self.need_reward_bootstrap else self.boot_strap_value['bootstrap_'+value_key]
for step in reversed(range(length)):
if step==(length-1): # 最后一帧
value_preds_delta = rewards_cp[step] + gamma * boot_strap - value[step]
gae = value_preds_delta
else:
value_preds_delta = rewards_cp[step] + gamma * value[step + 1] - value[step]
gae = value_preds_delta + gamma * tau * gae
returns[step] = gae + value[step]
# ------- -------------- -------
returns = my_view(returns, [0, n_agent, self.alg_cfg.distribution_precision]) # BAL_return_all_level
setattr(self, new_return_name, returns)
self.key_dict.append(new_return_name)
def select_value_level(BAL_all_level, randl):
n_agent = BAL_all_level.shape[1]
tmp_index = np.expand_dims(repeat_at(randl, -1, n_agent), -1)
return gather_righthand(src=BAL_all_level, index=tmp_index, check=False)
self.value_selected = select_value_level(BAL_all_level=self.BAL_value_all_level, randl=self.randl)
self.return_selected = select_value_level(BAL_all_level=self.BAL_return_all_level, randl=self.randl)
'''
轨迹池管理
'''
class TrajManagerBase(object):
def __init__(self, n_env, traj_limit, alg_cfg):
self.alg_cfg = alg_cfg
self.n_env = n_env
self.traj_limit = traj_limit
self.update_cnt = 0
self.traj_pool = []
self.registered_keys = []
self.live_trajs = [trajectory(self.traj_limit, env_id=i, alg_cfg=self.alg_cfg) for i in range(self.n_env)]
self.live_traj_frame = [0 for _ in range(self.n_env)]
self._traj_lock_buf = None
self.patience = 1000
pass
def __check_integraty(self, traj_frag):
if self.patience < 0:
return # stop wasting time checking this
self.patience -= 1
for key in traj_frag:
if key not in self.registered_keys and (not key.startswith('_')):
self.registered_keys.append(key)
for key in self.registered_keys:
assert key in traj_frag, ('this key sometimes disappears from the traj_frag:', key)
def batch_update(self, traj_frag):
self.__check_integraty(traj_frag)
done = traj_frag['_DONE_']; traj_frag.pop('_DONE_') # done flag
skip = traj_frag['_SKIP_']; traj_frag.pop('_SKIP_') # skip/frozen flag
tobs = traj_frag['_TOBS_']; traj_frag.pop('_TOBS_') # terminal obs
# single bool to list bool
if isinstance(done, bool): done = [done for _ in range(self.n_env)]
if isinstance(skip, bool): skip = [skip for _ in range(self.n_env)]
n_active = sum(~skip)
# feed
cnt = 0
for env_i in range(self.n_env):
if skip[env_i]: continue
# otherwise
frag_index = cnt; cnt += 1
env_index = env_i
traj_handle = self.live_trajs[env_index]
for key in traj_frag:
self.traj_remember(traj_handle, key=key, content=traj_frag[key],frag_index=frag_index, n_active=n_active)
self.live_traj_frame[env_index] += 1
traj_handle.time_shift()
if done[env_i]:
assert tobs[env_i] is not None # get the final obs
traj_handle.set_terminal_obs(tobs[env_i])
self.traj_pool.append(traj_handle)
self.live_trajs[env_index] = trajectory(self.traj_limit, env_id=env_index, alg_cfg=self.alg_cfg)
self.live_traj_frame[env_index] = 0
def traj_remember(self, traj, key, content, frag_index, n_active):
if content is None: traj.remember(key, None)
elif isinstance(content, dict):
for sub_key in content:
self.traj_remember(traj, "".join((key , ">" , sub_key)), content=content[sub_key], frag_index=frag_index, n_active=n_active)
else:
assert n_active == len(content), ('length error')
traj.remember(key, content[frag_index]) # *
class BatchTrajManager(TrajManagerBase):
def __init__(self, n_env, traj_limit, trainer_hook, alg_cfg):
super().__init__(n_env, traj_limit, alg_cfg)
self.trainer_hook = trainer_hook
self.traj_limit = traj_limit
# 函数入口
def feed_traj(self, traj_frag, require_hook=False):
if require_hook: raise ModuleNotFoundError("not supported anymore")
assert self._traj_lock_buf is None
assert '_DONE_' in traj_frag
assert '_SKIP_' in traj_frag
self.batch_update(traj_frag=traj_frag) # call parent's batch_update()
return
def train_and_clear_traj_pool(self):
print('do update %d'%self.update_cnt)
for traj_handle in self.traj_pool:
traj_handle.cut_tail()
self.traj_pool = list(filter(lambda traj: not traj.deprecated_flag, self.traj_pool))
for traj_handle in self.traj_pool: traj_handle.finalize()
self.trainer_hook(self.traj_pool, 'train')
self.traj_pool = []
self.update_cnt += 1
return self.update_cnt
def can_exec_training(self):
num_traj_needed = self.alg_cfg.train_traj_needed
if len(self.traj_pool) >= num_traj_needed:
return True
else:
return False
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/traj_manager.py
================================================
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/example_foundation.py
================================================
import numpy as np
import copy
import math
import random
class ExampleFoundation():
def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
self.n_thread = n_thread
self.n_agent = n_agent
self.handler = [None for _ in range(self.n_thread)]
def interact_with_env(self, team_intel):
info = team_intel['Latest-Team-Info']
done = team_intel['Env-Suffered-Reset']
step_cnt = team_intel['Current-Obs-Step']
action_list = np.zeros(shape=(self.n_agent, self.n_thread, 1))
return action_list, team_intel
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/ccategorical.py
================================================
from torch.distributions.categorical import Categorical
import torch
from .foundation import AlgorithmConfig
from UTIL.tensor_ops import repeat_at, _2tensor
from torch.distributions import kl_divergence
EPS = 1e-9
# yita = p_hit = 0.14
def random_process(probs, rsn_flag):
yita = AlgorithmConfig.yita
with torch.no_grad():
max_place = probs.argmax(-1, keepdims=True)
mask_max = torch.zeros_like(probs).scatter_(-1, max_place, 1).bool()
pmax = probs[mask_max]
if rsn_flag:
assert max_place.shape[-1] == 1
return max_place.squeeze(-1)
else:
# forbit max prob being chosen, pmax = probs.max(axis=-1)
p_hat = pmax + (pmax-1)/(1/yita-1)
k = 1/(1-yita)
#!!! write
probs *= k
#!!! write
probs[mask_max] = p_hat
# print(probs)
dist = Categorical(probs=probs)
samp = dist.sample()
assert samp.shape[-1] != 1
return samp
def random_process_allow_big_yita(probs, rsn_flag):
yita = AlgorithmConfig.yita
with torch.no_grad():
max_place = probs.argmax(-1, keepdims=True)
mask_max = torch.zeros_like(probs).scatter_(-1, max_place, 1).bool()
pmax = probs[mask_max].reshape(max_place.shape) #probs[max_place].clone()
if rsn_flag:
assert max_place.shape[-1] == 1
return max_place.squeeze(-1)
else:
# forbit max prob being chosen
# pmax = probs.max(axis=-1) #probs[max_place].clone()
yita_arr = torch.ones_like(pmax)*yita
yita_arr_clip = torch.minimum(pmax, yita_arr)
# p_hat = pmax + (pmax-1) / (1/yita_arr_clip-1) + 1e-10
p_hat = (pmax-yita_arr_clip)/(1-yita_arr_clip)
k = 1/(1-yita_arr_clip)
probs *= k
probs[mask_max] = p_hat.reshape(-1)
# print(probs)
dist = Categorical(probs=probs)
samp = dist.sample()
assert samp.shape[-1] != 1
return samp #.squeeze(-1)
def random_process_with_clamp3(probs, yita, yita_min_prob, rsn_flag):
with torch.no_grad():
max_place = probs.argmax(-1, keepdims=True)
mask_max = torch.zeros_like(probs).scatter_(dim=-1, index=max_place, value=1).bool()
pmax = probs[mask_max].reshape(max_place.shape)
# act max
assert max_place.shape[-1] == 1
act_max = max_place.squeeze(-1)
# act samp
yita_arr = torch.ones_like(pmax)*yita
# p_hat = pmax + (pmax-1) / (1/yita_arr_clip-1) + 1e-10
p_hat = (pmax-yita_arr)/((1-yita_arr)+EPS)
p_hat = p_hat.clamp(min=yita_min_prob)
k = (1-p_hat)/((1-pmax)+EPS)
probs *= k
probs[mask_max] = p_hat.reshape(-1)
dist = Categorical(probs=probs)
act_samp = dist.sample()
# assert act_samp.shape[-1] != 1
hit_e = _2tensor(rsn_flag)
return torch.where(hit_e, act_max, act_samp)
class CCategorical():
def __init__(self, planner):
self.planner = planner
pass
def sample(self, dist, eprsn):
probs = dist.probs.clone()
return random_process_with_clamp3(probs, self.planner.yita, self.planner.yita_min_prob, eprsn)
def register_rsn(self, rsn_flag):
self.rsn_flag = rsn_flag
def feed_logits(self, logits):
try:
return Categorical(logits=logits)
except:
print('error')
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/cython_func.pyx
================================================
import numpy as np
cimport numpy as np
cimport cython
from cython.parallel import prange
np.import_array()
ctypedef fused DTYPE_t:
np.float32_t
np.float64_t
ctypedef fused DTYPE_intlong_t:
np.int64_t
np.int32_t # to compat Windows
ctypedef np.uint8_t DTYPE_bool_t
@cython.boundscheck(False)
@cython.wraparound(False)
@cython.nonecheck(False)
def roll_hisory( DTYPE_t[:,:,:,:] obs_feed_new,
DTYPE_t[:,:,:,:] prev_obs_feed,
DTYPE_bool_t[:,:,:] valid_mask,
DTYPE_intlong_t[:,:] N_valid,
DTYPE_t[:,:,:,:] next_his_pool):
# how many threads
cdef Py_ssize_t vmax = N_valid.shape[0]
# how many agents
cdef Py_ssize_t wmax = N_valid.shape[1]
# how many entity subjects (including self @0)
cdef Py_ssize_t max_obs_entity = obs_feed_new.shape[2]
cdef int n_v, th, a, t, k, pointer
for th in prange(vmax, nogil=True):
# for each thread range -> prange
for a in prange(wmax):
# for each agent
pointer = 0
# step 1 fill next_his_pool[0 ~ (nv-1)] with obs_feed_new[0 ~ max_obs_entity-1]
for k in range(max_obs_entity):
if valid_mask[th,a,k]:
next_his_pool[th, a, pointer] = obs_feed_new[th,a,k]
pointer = pointer + 1
# step 2 fill next_his_pool[nv ~ (max_obs_entity-1)] with prev_obs_feed[0 ~ (max_obs_entity-1-nv)]
n_v = N_valid[th,a]
for k in range(n_v, max_obs_entity):
next_his_pool[th,a,k] = prev_obs_feed[th,a,k-n_v]
return np.asarray(next_his_pool)
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/div_tree.py
================================================
import torch
import torch.nn as nn
import numpy as np
from ALGORITHM.common.mlp import LinearFinal
from UTIL.tensor_ops import add_onehot_id_at_last_dim, add_onehot_id_at_last_dim_fixlen, repeat_at, _2tensor, gather_righthand, scatter_righthand
class DivTree(nn.Module): # merge by MLP version
def __init__(self, input_dim, h_dim, n_action):
super().__init__()
# to design a division tree, I need to get the total number of agents
from .foundation import AlgorithmConfig
self.n_agent = AlgorithmConfig.n_agent
self.div_tree = get_division_tree(self.n_agent)
self.n_level = len(self.div_tree)
self.max_level = len(self.div_tree) - 1
self.current_level = 0
self.init_level = AlgorithmConfig.div_tree_init_level
if self.init_level < 0:
self.init_level = self.max_level
self.current_level_floating = 0.0
get_net = lambda: nn.Sequential(
nn.Linear(h_dim+self.n_agent, h_dim),
nn.ReLU(inplace=True),
LinearFinal(h_dim, n_action)
)
# Note: this is NOT net defining for each agent
# Instead, all agents starts from self.nets[0]
self.nets = torch.nn.ModuleList(modules=[
get_net() for i in range(self.n_agent)
])
def set_to_init_level(self, auto_transfer=True):
if self.init_level!=self.current_level:
for i in range(self.current_level, self.init_level):
self.change_div_tree_level(i+1, auto_transfer)
def change_div_tree_level(self, level, auto_transfer=True):
print('performing div tree level change (%d -> %d/%d) \n'%(self.current_level, level, self.max_level))
self.current_level = level
self.current_level_floating = level
assert len(self.div_tree) > self.current_level, ('Reach max level already!')
if not auto_transfer: return
transfer_list = []
for i in range(self.n_agent):
previous_net_index = self.div_tree[self.current_level-1, i]
post_net_index = self.div_tree[self.current_level, i]
if post_net_index!=previous_net_index:
transfer = (previous_net_index, post_net_index)
if transfer not in transfer_list:
transfer_list.append(transfer)
for transfer in transfer_list:
from_which_net = transfer[0]
to_which_net = transfer[1]
self.nets[to_which_net].load_state_dict(self.nets[from_which_net].state_dict())
print('transfering model parameters from %d-th net to %d-th net'%(from_which_net, to_which_net))
return
def forward(self, x_in, agent_ids): # x0: shape = (?,...,?, n_agent, core_dim)
if self.current_level == 0:
x0 = add_onehot_id_at_last_dim_fixlen(x_in, fixlen=self.n_agent, agent_ids=agent_ids)
x2 = self.nets[0](x0)
return x2, None
else:
x0 = add_onehot_id_at_last_dim_fixlen(x_in, fixlen=self.n_agent, agent_ids=agent_ids)
res = []
for i in range(self.n_agent):
use_which_net = self.div_tree[self.current_level, i]
res.append(self.nets[use_which_net](x0[..., i, :]))
x2 = torch.stack(res, -2)
# x22 = self.nets[0](x1)
return x2, None
# def forward_try_parallel(self, x0): # x0: shape = (?,...,?, n_agent, core_dim)
# x1 = self.shared_net(x0)
# stream = []
# res = []
# for i in range(self.n_agent):
# stream.append(torch.cuda.Stream())
# torch.cuda.synchronize()
# for i in range(self.n_agent):
# use_which_net = self.div_tree[self.current_level, i]
# with torch.cuda.stream(stream[i]):
# res.append(self.nets[use_which_net](x1[..., i, :]))
# print(res[i])
# # s1 = torch.cuda.Stream()
# # s2 = torch.cuda.Stream()
# # # Wait for the above tensors to initialise.
# # torch.cuda.synchronize()
# # with torch.cuda.stream(s1):
# # C = torch.mm(A, A)
# # with torch.cuda.stream(s2):
# # D = torch.mm(B, B)
# # Wait for C and D to be computed.
# torch.cuda.synchronize()
# # Do stuff with C and D.
# x2 = torch.stack(res, -2)
# return x2
def _2div(arr):
arr_res = arr.copy()
arr_pieces = []
pa = 0
st = 0
needdivcnt = 0
for i, a in enumerate(arr):
if a!=pa:
arr_pieces.append([st, i])
if (i-st)!=1: needdivcnt+=1
pa = a
st = i
arr_pieces.append([st, len(arr)])
if (len(arr)-st)!=1: needdivcnt+=1
offset = range(len(arr_pieces), len(arr_pieces)+needdivcnt)
p=0
for arr_p in arr_pieces:
length = arr_p[1] - arr_p[0]
if length == 1: continue
half_len = int(np.ceil(length / 2))
for j in range(arr_p[0]+half_len, arr_p[1]):
try:
arr_res[j] = offset[p]
except:
print('wtf')
p+=1
return arr_res
def get_division_tree(n_agents):
agent2divitreeindex = np.arange(n_agents)
np.random.shuffle(agent2divitreeindex)
max_div = np.ceil(np.log2(n_agents)).astype(int)
levels = np.zeros(shape=(max_div+1, n_agents), dtype=int)
tree_of_agent = []*(max_div+1)
for ith, level in enumerate(levels):
if ith == 0: continue
res = _2div(levels[ith-1,:])
levels[ith,:] = res
res_levels = levels.copy()
for i, div_tree_index in enumerate(agent2divitreeindex):
res_levels[:, i] = levels[:, div_tree_index]
return res_levels
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/foundation.py
================================================
import os, time, torch, traceback, shutil, pickle, io
import numpy as np
from UTIL.colorful import *
from config import GlobalConfig
from UTIL.tensor_ops import repeat_at, _2tensor
from ALGORITHM.common.rl_alg_base import RLAlgorithmBase
class AlgorithmConfig:
'''
AlgorithmConfig: This config class will be 'injected' with new settings from json.
(E.g., override configs with ```python main.py --cfg example.jsonc```)
(please see UTIL.config_args to find out how this advanced trick works out.)
'''
# configuration, open to jsonc modification
gamma = 0.99
tau = 0.95
train_traj_needed = 512
hete_n_alive_frontend = 1
TakeRewardAsUnity = False
use_normalization = True
wait_norm_stable = True
add_prob_loss = False
n_focus_on = 2
n_entity_placeholder = 11
load_checkpoint = False
load_specific_checkpoint = ''
# PPO part
clip_param = 0.2
ppo_epoch = 16
n_pieces_batch_division = 1
value_loss_coef = 0.1
entropy_coef = 0.05
max_grad_norm = 0.5
clip_param = 0.2
lr = 1e-4
# prevent GPU OOM
prevent_batchsize_oom = False
gamma_in_reward_forwarding = False
gamma_in_reward_forwarding_value = 0.99
net_hdim = 24
dual_conc = True
n_agent = 'auto load, do not change'
ConfigOnTheFly = True
hete_n_net_placeholder = 5
hete_thread_align = False
hete_same_prob = 0.25
hete_lasted_n = 100
policy_resonance = False
use_avail_act = True
debug = False
ignore_test = False
type_agent_diff_lr = False
hete_exclude_zero_wr = False
policy_matrix_testing = False
test_which_cpk = 1
type_sel_override = False
type_sel_override_list = []
allow_fast_test = True
def str_array_to_num(str_arr):
out_arr = []
buffer = {}
for str in str_arr:
if str not in buffer:
buffer[str] = len(buffer)
out_arr.append(buffer[str])
return out_arr
def itemgetter(*items):
# same with operator.itemgetter
def g(obj): return tuple(obj[item] if item in obj else None for item in items)
return g
class CPU_Unpickler(pickle.Unpickler):
def find_class(self, module, name):
if module == 'torch.storage' and name == '_load_from_bytes':
return lambda b: torch.load(io.BytesIO(b), map_location='cpu')
else:
return super().find_class(module, name)
class ReinforceAlgorithmFoundation(RLAlgorithmBase):
def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
from .shell_env import ShellEnvWrapper, ActionConvertLegacy
from .hete_net import HeteNet
super().__init__(n_agent, n_thread, space, mcv, team)
AlgorithmConfig.n_agent = n_agent
self.action_converter = ActionConvertLegacy(
SELF_TEAM_ASSUME=team,
OPP_TEAM_ASSUME=(1-team),
OPP_NUM_ASSUME=GlobalConfig.ScenarioConfig.N_AGENT_EACH_TEAM[1-team]
)
n_actions = len(self.action_converter.dictionary_args)
# change obs format, e.g., converting dead agent obs into NaN
self.shell_env = ShellEnvWrapper(n_agent, n_thread, space, mcv, self, AlgorithmConfig, GlobalConfig.ScenarioConfig, self.team)
if self.ScenarioConfig.EntityOriented: rawob_dim = self.ScenarioConfig.obs_vec_length
else: rawob_dim = space['obs_space']['obs_shape']
# self.StagePlanner, for policy resonance
from .stage_planner import StagePlanner
self.stage_planner = StagePlanner(mcv=mcv)
# heterogeneous agent types
agent_type_list = [a['type'] for a in GlobalConfig.ScenarioConfig.SubTaskConfig.agent_list]
self.HeteAgentType = str_array_to_num(agent_type_list)
hete_type = np.array(self.HeteAgentType)[self.ScenarioConfig.AGENT_ID_EACH_TEAM[team]]
# initialize policy
self.policy = HeteNet(rawob_dim=rawob_dim, n_action=n_actions, hete_type=hete_type, stage_planner=self.stage_planner)
self.policy = self.policy.to(self.device)
# initialize optimizer and trajectory (batch) manager
from .ppo import PPO
from .trajectory import BatchTrajManager
self.trainer = PPO(self.policy, ppo_config=AlgorithmConfig, mcv=mcv)
self.traj_manager = BatchTrajManager(
n_env=n_thread, traj_limit=int(GlobalConfig.ScenarioConfig.MaxEpisodeStep),
trainer_hook=self.trainer.train_on_traj)
self.stage_planner.trainer = self.trainer
# confirm that reward method is correct
self.check_reward_type(AlgorithmConfig)
# load checkpoints if needed
self.load_model(AlgorithmConfig)
# enable config_on_the_fly ability
if AlgorithmConfig.ConfigOnTheFly:
self._create_config_fly()
if AlgorithmConfig.policy_matrix_testing:
self.threads_test_reward_sum = np.zeros(shape=(n_thread,), dtype=float)
# self.threads_test_reward = []
self.recent_test_rewards = []
self.recent_test_wins = []
self._unfi_frag_matrix_ = None
self.recent_test_hete_gp_summary = []
self.current_hete_gp_summary = None
from VISUALIZE.mcom import mcom
self.mcv_matrix = mcom(
path='%s/logger/matrix/'%GlobalConfig.logdir,
image_path='%s/matrix.jpg'%GlobalConfig.logdir,
draw_mode='Img',
tag='[ppo.py]' )
self.mcv_matrix.rec_init(color='r')
def action_making(self, StateRecall, test_mode):
# make sure hook is cleared
assert ('_hook_' not in StateRecall)
# read obs et.al.
obs, threads_active_flag, avail_act, hete_pick, hete_type, gp_sel_summary, eprsn = \
itemgetter('obs', 'threads_active_flag', 'avail_act', '_hete_pick_', '_hete_type_', '_gp_pick_', '_EpRsn_')(StateRecall)
# make sure obs shape is correct
assert obs is not None, ('Make sure obs is ok')
assert len(obs) == sum(threads_active_flag), ('check batch size')
# make sure avail_act is correct
if AlgorithmConfig.use_avail_act: assert avail_act is not None
# policy resonance flag reshape
eprsn = repeat_at(eprsn, -1, self.n_agent)
thread_index = np.arange(self.n_thread)[threads_active_flag]
# make decision
with torch.no_grad():
action, value, action_log_prob = self.policy.act(obs=obs,
test_mode=test_mode,
avail_act=avail_act,
hete_pick=hete_pick,
hete_type=hete_type,
gp_sel_summary=gp_sel_summary,
thread_index=thread_index,
eprsn=eprsn,
)
# commit obs to buffer, vars named like _x_ are aligned, others are not!
traj_framefrag = {
"_SKIP_": ~threads_active_flag,
"value": value,
"hete_pick": hete_pick,
"hete_type": hete_type,
"gp_sel_summary": gp_sel_summary,
"avail_act": avail_act,
"actionLogProb": action_log_prob,
"obs": obs,
"action": action,
}
if avail_act is not None: traj_framefrag.update({'avail_act': avail_act})
# deal with rollout later when the reward is ready, leave a hook as a callback here
if not test_mode:
StateRecall['_hook_'] = self.commit_traj_frag(traj_framefrag, req_hook = True)
else:
if test_mode and AlgorithmConfig.policy_matrix_testing:
StateRecall['_hook_'] = self.matrix_callback_special(traj_framefrag)
return action.copy(), StateRecall
'''
function to be called when reward is received
'''
def matrix_callback_special(self, framefrag):
assert self._unfi_frag_matrix_ is None
self._unfi_frag_matrix_ = framefrag
return self.matrix_callback_special_callback
def matrix_callback_special_callback(self, new_frag):
fi_frag = self._unfi_frag_matrix_
self._unfi_frag_matrix_ = None
reward = new_frag['reward'].copy()
done = new_frag['done'].copy()
# self.threads_test_reward.append(reward)
self.threads_test_reward_sum += reward * ~fi_frag['_SKIP_']
if not any(fi_frag['_SKIP_']):
self.current_hete_gp_summary = fi_frag["gp_sel_summary"]
if done.all():
self.recent_test_rewards.extend(self.threads_test_reward_sum)
self.recent_test_wins.extend([q['team_ranking'][self.team]==0 for q in new_frag['info']]) # 0 means rank first
self.recent_test_hete_gp_summary.extend(self.current_hete_gp_summary)
self.threads_test_reward_sum *= 0
self.current_hete_gp_summary = None
return None
def interact_with_env(self, StateRecall):
'''
Interfacing with marl, standard method that you must implement
(redirect to shell_env to help with history rolling)
'''
return self.shell_env.interact_with_env(StateRecall)
def interact_with_env_genuine(self, StateRecall):
'''
When shell_env finish the preparation, interact_with_env_genuine is called
(Determine whether or not to do a training routinue)
'''
# if not StateRecall['Test-Flag']: self.train() # when needed, train!
return self.action_making(StateRecall, StateRecall['Test-Flag'])
def train(self):
'''
Get event from hmp task runner, save model now!
'''
if self.traj_manager.can_exec_training():
if self.stage_planner.can_exec_trainning():
self.traj_manager.train_and_clear_traj_pool()
else:
self.traj_manager.clear_traj_pool()
# read configuration
if AlgorithmConfig.ConfigOnTheFly: self._config_on_fly()
#
self.stage_planner.update_plan()
# override parent function
def on_notify(self, message, **kargs):
win_rate = kargs['win_rate']
mean_reward = kargs['mean_reward']
path = self.save_model(
update_cnt=self.traj_manager.update_cnt,
info=str(kargs)
)
# print('[random win rate] ! ! ! ! !')
# win_rate = np.random.rand()
self.policy.register_ckp(win_rate, path, mean_reward)
if AlgorithmConfig.policy_matrix_testing:
from UTIL.data_struct import UniqueList
# self.recent_test_hete_gp_summary_str = self.recent_test_hete_gp_summary # [str(q.tolist()) for q in self.recent_test_hete_gp_summary]
recent_test_hete_gp_summary_ls = [q.tolist() for q in self.recent_test_hete_gp_summary]
ulist = UniqueList(recent_test_hete_gp_summary_ls)
for u in ulist:
feature = self.policy.ph_to_feature[u].squeeze().cpu().numpy().tolist()
feature = "[%.2f,%.2f,%.2f]"%tuple(feature)
mask = [u==uu for uu in recent_test_hete_gp_summary_ls]
r = np.array(self.recent_test_rewards)[mask].mean()
wr = np.array(self.recent_test_wins)[mask].mean()
self.mcv_matrix.rec(self.policy.ckpg_input_cnt, 'time')
self.mcv_matrix.rec(r, 'r of=%s'%feature)
self.mcv_matrix.rec(wr, 'w of=%s'%feature)
self.mcv_matrix.rec(sum(mask), 'n of=%s'%feature)
self.mcv_matrix.rec_show()
self.recent_test_rewards = []
self.recent_test_wins = []
self.recent_test_hete_gp_summary = []
def save_model(self, update_cnt, info=None):
'''
save model now!
save if triggered when:
1. Update_cnt = 50, 100, ...
2. Given info, indicating a hmp command
3. A flag file is detected, indicating a save command from human
'''
if not os.path.exists('%s/history_cpt/' % GlobalConfig.logdir):
os.makedirs('%s/history_cpt/' % GlobalConfig.logdir)
# dir 1
pt_path = '%s/model.pt' % GlobalConfig.logdir
print绿('saving model to %s' % pt_path)
torch.save({
'policy': self.policy.state_dict(),
'optimizer': self.trainer.optimizer.state_dict(),
}, pt_path)
# dir 2
info = str(update_cnt) if info is None else ''.join([str(update_cnt), '_', info])
pt_path2 = '%s/history_cpt/model_%s.pt' % (GlobalConfig.logdir, info)
shutil.copyfile(pt_path, pt_path2)
# save ckpg_info
with open('%s/history_cpt/ckpg_info.pkl'%GlobalConfig.logdir, 'wb') as f:pickle.dump((self.policy.ckpg_info, self.policy.ckpg_input_cnt, [(n.feature, n.static, n.ready_to_go) for n in self.policy._nets_flat_placeholder_]),f)
print绿('save_model fin')
return pt_path2
def find_ckp(self, feature):
import glob
list_ckp = glob.glob('%s/history_cpt/*.pt'%GlobalConfig.logdir)
ckp_dir = [ckp for ckp in list_ckp if str(feature[0]) in ckp][0]
cuda_n = 'cpu' if 'cpu' in self.device else self.device
cpt = torch.load(ckp_dir, map_location=cuda_n)
# get previous frontier network
return {k.replace('_nets_flat_placeholder_.0.',''):v for k, v in cpt['policy'].items() if '_nets_flat_placeholder_.0.' in k}
def load_model(self, AlgorithmConfig):
'''
load model now
'''
if AlgorithmConfig.load_checkpoint:
manual_dir = AlgorithmConfig.load_specific_checkpoint
ckpt_dir = '%s/model.pt' % GlobalConfig.logdir if manual_dir == '' else '%s/%s' % (GlobalConfig.logdir, manual_dir)
cuda_n = 'cpu' if 'cpu' in self.device else self.device
strict = True
if not platform.system()=="Linux": assert ':' not in ckpt_dir, ('Windows OS does not allow : in file name')
cpt = torch.load(ckpt_dir, map_location=cuda_n)
self.policy.load_state_dict(cpt['policy'], strict=strict)
# https://github.com/pytorch/pytorch/issues/3852
self.trainer.optimizer.load_state_dict(cpt['optimizer'])
print黄('loaded checkpoint:', ckpt_dir)
if os.path.exists('%s/history_cpt/ckpg_info.pkl'%GlobalConfig.logdir):
with open('%s/history_cpt/ckpg_info.pkl'%GlobalConfig.logdir, 'rb') as f:
self.policy.ckpg_info, self.policy.ckpg_input_cnt, n_flags = CPU_Unpickler(f).load()
for (n, flags) in zip(self.policy._nets_flat_placeholder_, n_flags):
n.feature = flags[0]
n.static = flags[1]
n.ready_to_go = flags[2]
if n.feature!=1:
n.load_state_dict(self.find_ckp(n.feature), strict=True)
self.policy.ph_to_feature = _2tensor(np.array([n.feature for n in self.policy._nets_flat_placeholder_]))
print黄('loaded ckpg_info')
else:
print('Warning, past policy missing !!')
def process_framedata(self, traj_framedata):
'''
hook is called when reward and next moment observation is ready,
now feed them into trajectory manager.
Rollout Processor | 准备提交Rollout, 以下划线开头和结尾的键值需要对齐(self.n_thread, ...)
note that keys starting with _ must have shape (self.n_thread, ...), details see fn:mask_paused_env()
'''
# strip info, since it is not array
items_to_pop = ['info', 'Latest-Obs']
for k in items_to_pop:
if k in traj_framedata:
traj_framedata.pop(k)
# the agent-wise reward is supposed to be the same, so averge them
if self.ScenarioConfig.RewardAsUnity:
traj_framedata['reward'] = repeat_at(traj_framedata['reward'], insert_dim=-1, n_times=self.n_agent)
# change the name of done to be recognised (by trajectory manager)
traj_framedata['_DONE_'] = traj_framedata.pop('done')
traj_framedata['_TOBS_'] = traj_framedata.pop(
'Terminal-Obs-Echo') if 'Terminal-Obs-Echo' in traj_framedata else None
# mask out pause thread
traj_framedata = self.mask_paused_env(traj_framedata)
# put the frag into memory
self.traj_manager.feed_traj_framedata(traj_framedata)
def mask_paused_env(self, frag):
running = ~frag['_SKIP_']
if running.all():
return frag
for key in frag:
if not key.startswith('_') and hasattr(frag[key], '__len__') and len(frag[key]) == self.n_thread:
frag[key] = frag[key][running]
return frag
def _create_config_fly(self):
logdir = GlobalConfig.logdir
self.input_file_dir = '%s/cmd_io.txt' % logdir
if not os.path.exists(self.input_file_dir):
with open(self.input_file_dir, 'w+', encoding='utf8') as f: f.writelines(["# Write cmd at next line: ", ""])
def _config_on_fly(self):
if not os.path.exists(self.input_file_dir): return
with open(self.input_file_dir, 'r', encoding='utf8') as f:
cmdlines = f.readlines()
cmdlines_writeback = []
any_change = False
for cmdline in cmdlines:
if cmdline.startswith('#') or cmdline=="\n" or cmdline==" \n":
cmdlines_writeback.append(cmdline)
else:
any_change = True
try:
print亮绿('[foundation.py] ------- executing: %s ------'%cmdline)
exec(cmdline)
cmdlines_writeback.append('# [execute successfully]\t'+cmdline)
except:
print红(traceback.format_exc())
cmdlines_writeback.append('# [execute failed]\t'+cmdline)
if any_change:
with open(self.input_file_dir, 'w+', encoding='utf8') as f:
f.writelines(cmdlines_writeback)
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/hete_assignment.py
================================================
import copy
import numpy as np
from UTIL.tensor_ops import my_view, __hash__, repeat_at, gather_righthand
from .foundation import AlgorithmConfig
def random_group(random_select_fn, n_thread, hete_type, n_hete_types, n_group, selected_tps, testing):
n_agent = hete_type.shape[-1]
group_sel_arr = np.zeros(shape=(n_thread, n_agent), dtype=int)
gp_sel_summary = []
for i in range(n_thread):
group_assignment = np.array([
random_select_fn(testing)
if type not in selected_tps[i] else 0
for type in range(n_hete_types)
])
assert (group_assignment[selected_tps[i]]==0).all()
gp_sel_summary.append(copy.deepcopy(group_assignment))
for ht, group in enumerate(group_assignment):
mask = (hete_type == ht)
group_sel_arr[i,mask] = group
return group_sel_arr, np.stack(gp_sel_summary).astype(np.int64)
def select_nets_for_shellenv(n_types, policy, hete_type_list, n_thread, n_gp, testing):
if (not testing) or (AlgorithmConfig.policy_matrix_testing):
n_alive_frontend = AlgorithmConfig.hete_n_alive_frontend
tmp = np.arange(n_types)
# select types to use frontier
if not AlgorithmConfig.type_sel_override:
selected_types = np.stack([
np.random.choice(
a=tmp,
size=(n_alive_frontend),
replace=False,
p=None)
for _ in range(n_thread)
])
else:
selected_types = np.stack([
AlgorithmConfig.type_sel_override_list
for _ in range(n_thread)
])
else:
# testing but not policy_matrix_testing: select all types to use frontier
selected_types = np.stack([np.arange(n_types) for _ in range(n_thread)])
# generate a random group selection array
if not AlgorithmConfig.policy_matrix_testing:
random_select_fn = policy.random_select
else:
random_select_fn = policy.random_select_matrix_test
group_sel_arr, gp_sel_summary = random_group(
random_select_fn=random_select_fn, n_thread=n_thread, hete_type=hete_type_list,
n_hete_types=n_types, n_group=n_gp, selected_tps=selected_types, testing=testing)
# group to net index
n_tp = n_types
get_placeholder = lambda type, group: group*n_tp + type
hete_type_arr = repeat_at(hete_type_list, 0, n_thread)
selected_nets = get_placeholder(type=hete_type_arr, group=group_sel_arr)
return selected_nets, gp_sel_summary
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/hete_net.py
================================================
import torch, math, copy, pickle
import numpy as np
import torch.nn as nn
from config import GlobalConfig as cfg
from torch.distributions.categorical import Categorical
from UTIL.colorful import print亮绿
from UTIL.tensor_ops import Args2tensor_Return2numpy, Args2tensor, __hashn__, cat_last_dim, __hash__, one_hot_with_nan, repeat_at, scatter_righthand, gather_righthand, _2cpu2numpy, my_view
from .foundation import AlgorithmConfig
from ALGORITHM.common.pca import pca
from ALGORITHM.common.net_manifest import weights_init
from .net import Net, NetCentralCritic
def popgetter(*items):
def g(obj): return tuple(obj.pop(item) if item in obj else None for item in items)
return g
class no_context():
def __enter__(self):
return None
def __exit__(self, exc_type, exc_value, traceback):
return False
def _count_list_type(x):
type_cnt = {}
for xx in x:
if xx not in type_cnt: type_cnt[xx] = 0
type_cnt[xx] += 1
return len(type_cnt)
def _create_tensor_ph_or_fill_(ref, pt, offset, *args):
n_threads, n_agents, mask = args
if pt[offset] is None:
pt[offset] = torch.zeros(size=(n_threads*n_agents, *ref.shape[2:]), device=ref.device, dtype=ref.dtype)
pt[offset][mask] = ref.squeeze(0)
def _tensor_expand_thread_dim_v2_(ref, pt, offset, *args):
# undo dim collapse
n_threads, n_agents = args
v = pt[offset]
pt[offset] = v.view(n_threads, n_agents, *v.shape[1:])
def dfs_create_and_fn(ref, pt, offset, fn, *args):
'''
ref: target to sync
pt: mutable list
offset: mutable list index
fn: function to be executed at leaf nodes
args: anything needed
'''
if ref is None: # there is nothing to sync, instead, do something at leaf node only
ref = pt[offset]
if ref == 'vph':
pt[offset] = 'vph'
return
elif isinstance(ref, tuple) or isinstance(ref, list):
if pt[offset] is None: pt[offset] = [None for item in ref]
for i, item in enumerate(ref):
dfs_create_and_fn(item, pt[offset], i, fn, *args)
elif isinstance(ref, dict):
if pt[offset] is None: pt[offset] = {key:None for key in ref}
for key in ref:
dfs_create_and_fn(ref[key], pt[offset], key, fn, *args)
elif isinstance(ref, torch.Tensor):
fn(ref, pt, offset, *args)
else:
assert False
def _deal_single_in(x, mask_flatten):
if isinstance(x, torch.Tensor):
# collapse first two dims
return x.view(-1, *x.shape[2:])[mask_flatten].unsqueeze(0)
else:
return x
# todo: https://pytorch.org/tutorials/advanced/torch-script-parallelism.html?highlight=parallel
def distribute_compute(fn_arr, mask_arr, **kwargs):
"""compute on each network
Args:
fn_arr : a list of forwarding networks
mask_arr : mask of kwargs
Returns:
tuple tensors: the result of networks
"""
# python don't have pointers,
# however, a list is a mutable type in python, that's what we need
g_out = [None]
n_threads = mask_arr[0].shape[0]
n_agents = mask_arr[0].shape[1]
# calculated result will be gathered into ret_tuple_gather
ret_tuple_gather = []
# one by one we compute the result
for fn, mask in zip(fn_arr, mask_arr):
assert mask.dim()==2
mask_flatten = mask.flatten()
agent_ids = torch.where(mask)[1]
agent_ids = agent_ids.unsqueeze(0) # fake an extral dimension
_kwargs = {key:_deal_single_in(kwargs[key], mask_flatten) for key in kwargs}
with torch.no_grad() if fn.static else no_context() as gs: # no_grad is already declared outside in act mode
ret_tuple = fn._act(agent_ids=agent_ids, **_kwargs)
ret_tuple_gather.append(ret_tuple)
# stack ret_tuple_gather into g_out
for ret_tuple, fn, mask in zip(ret_tuple_gather, fn_arr, mask_arr):
mask_flatten = mask.flatten()
dfs_create_and_fn(ret_tuple, g_out, 0, _create_tensor_ph_or_fill_, n_threads, n_agents, mask_flatten)
# reshape the tensor
dfs_create_and_fn(None, g_out, 0, _tensor_expand_thread_dim_v2_, n_threads, n_agents)
return tuple(g_out[0])
class HeteNet(nn.Module):
def __init__(self, rawob_dim, n_action, hete_type, **kwargs):
super().__init__()
self.rawob_dim = rawob_dim
self.n_action = n_action
self.hete_type = hete_type
self.n_hete_types = _count_list_type(self.hete_type)
self.hete_n_net_placeholder = AlgorithmConfig.hete_n_net_placeholder
self.use_normalization = AlgorithmConfig.use_normalization
self.n_tp = self.n_hete_types
self.n_gp = self.hete_n_net_placeholder
self.n_agent_each_tp = [sum(self.hete_type==i) for i in range(self.n_hete_types)]
self.n_agents = len(self.hete_type)
# convertion between placeholder index and type-group index
self.tpgp_2_ph = lambda type, group: group*self.n_tp + type
self.ph_2_tpgp = lambda ph: (ph%self.n_hete_types, ph//self.n_hete_types)
self.ph_2_gp = lambda ph: ph//self.n_hete_types
# initialize net placeholders
self._nets_flat_placeholder_ = torch.nn.ModuleList(modules=[
Net(rawob_dim, n_action, **kwargs) for _ in range(
self.n_gp
)
])
# initialize critic
self._critic_central = NetCentralCritic(rawob_dim, n_action, **kwargs)
# reshape the handle of networks
self.nets = [ [ self._nets_flat_placeholder_[gp] ] for gp in range(self.n_gp)]
# the frontier nets
self.frontend_nets = self.nets[0]
# the static nets
self.static_nets = self.nets[1:]
# heterogeneous feature dimension
self.hete_feature_dim = 1
# add flags to each nets
for gp, n_arr in enumerate(self.nets):
for _, n in enumerate(n_arr):
ph_index = gp
n.gp = gp
# n.lr_div = self.n_agent_each_tp[tp] / self.n_agents
if gp!=0:
# lock static nets: the static nets are not loaded yet
n.feature = np.zeros(self.hete_feature_dim)
n.ready_to_go = False
self.lock_net(ph_index)
else:
# unlock frontier nets: the frontier nets are ready
n.feature = np.ones(self.hete_feature_dim)
n.ready_to_go = True
self.unlock_net(ph_index)
# a list to trace the vital checkpoints
self.ckpg_info = []
# track the number of checkpoints commited
self.ckpg_input_cnt = 0
# feature array, arranged according to placeholders
self.ph_to_feature = torch.tensor(np.array([n.feature for n in self._nets_flat_placeholder_]), dtype=torch.float, device=cfg.device)
#
# from UTIL.sync_exp import SynWorker
# self.syn_worker = SynWorker('follow')
def lock_net(self, i):
n = self._nets_flat_placeholder_[i]
n.static = True
n.eval()
def unlock_net(self, i):
n = self._nets_flat_placeholder_[i]
n.static = False
n.train()
def register_ckp(self, win_rate, cpk_path, mean_reward):
# deal with new checkpoint
self.ckpg_input_cnt += 1
# get previous win rates
prev_win_rate = [self.ckpg_info[i]['win_rate'] for i in range(len(self.ckpg_info))]
# if the winrate is not a breakthough, give up
if len(prev_win_rate)>0 and win_rate <= max(prev_win_rate):
return
if AlgorithmConfig.hete_exclude_zero_wr and win_rate==0:
return
# list the infomation about this checkpoint
self.ckpg_info.append({
'win_rate': win_rate,
'mean_reward': mean_reward,
'ckpg_cnt': self.ckpg_input_cnt,
'cpk_path': cpk_path,
'model': copy.deepcopy(self.frontend_nets[0].state_dict()),
'feature': [
win_rate
],
})
# sort according to win rate
self.ckpg_info.sort(key=lambda x:x['win_rate'])
# remove a checkpoint that is too close to its neighbor
self.trim_ckp()
print('ckp register change!')
print([self.ckpg_info[i]['win_rate'] for i in range(len(self.ckpg_info))])
print([self.ckpg_info[i]['ckpg_cnt'] for i in range(len(self.ckpg_info))])
# reload parameters
for i, static_nets in enumerate(self.static_nets):
# some net cannot be loaded with parameters yet, because ckpg_info has not collect enough samples
if i >= len(self.ckpg_info): continue
for _, net in enumerate(static_nets):
# load parameters
net.load_state_dict(self.ckpg_info[i]['model'], strict=True)
# the net must be static
assert net.static
# now the net is ready
net.ready_to_go = True
net.feature = self.ckpg_info[i]['feature']
# reload the net features
self.ph_to_feature = torch.tensor(np.array([n.feature for n in self._nets_flat_placeholder_]), dtype=torch.float, device=cfg.device)
print('parameters reloaded')
def random_select(self, testing, *args, **kwargs):
"""randomly select a group index
Args:
AlgorithmConfig.hete_same_prob: a probability about choosing the frontier net as the teammate
Returns:
int: a group index
"""
assert not testing
if np.random.rand() < AlgorithmConfig.hete_same_prob:
return 0
# choose randomly among existing nets
n_option = len(self.ckpg_info)
if n_option > 0:
if n_option > AlgorithmConfig.hete_lasted_n:
assert AlgorithmConfig.hete_lasted_n != 0
rand_sel = np.random.randint(low=n_option+1-AlgorithmConfig.hete_lasted_n, high=n_option+1)
else:
rand_sel = np.random.randint(low=1, high=n_option+1)
return rand_sel
else:
return 0
if AlgorithmConfig.policy_matrix_testing:
def random_select_matrix_test(self, testing, *args, **kwargs):
if testing:
hete_frontier_prob = 0 # 1 / (AlgorithmConfig.hete_lasted_n+1)
# print('manual selection')
n_option = len(self.ckpg_info)
LAST = AlgorithmConfig.test_which_cpk
# return 0
return (n_option+1) - LAST
else:
hete_frontier_prob = AlgorithmConfig.hete_same_prob
if np.random.rand() < hete_frontier_prob:
return 0
# choose randomly among existing nets
n_option = len(self.ckpg_info)
if n_option > 0:
if AlgorithmConfig.hete_lasted_n == 0:
return 0
if n_option > AlgorithmConfig.hete_lasted_n:
assert AlgorithmConfig.hete_lasted_n != 0
rand_sel = np.random.randint(low=n_option+1-AlgorithmConfig.hete_lasted_n, high=n_option+1)
else:
rand_sel = np.random.randint(low=1, high=n_option+1)
return rand_sel
else:
return 0
# called after training update
def on_update(self, update_cnt):
return
def redirect_to_frontend(self, i):
return i%self.n_tp
def acquire_net(self, i):
tp, gp = self.ph_2_tpgp(i)
return self._nets_flat_placeholder_[gp]
def exe(self, hete_pick=None, **kargs):
# shape
n_thread = hete_pick.shape[0]
n_agents = hete_pick.shape[1]
# pop items from kargs
gp_sel_summary, thread_indices, hete_type = popgetter('gp_sel_summary', 'thread_index', 'hete_type')(kargs)
# get ph_feature
# _012345 = torch.arange(self.n_tp, device=kargs['obs'].device, dtype=torch.int64)
ph_sel = gp_sel_summary # *self.n_tp + repeat_at(_012345, 0, n_thread) # group * self.n_tp + tp
ph_feature = self.ph_to_feature[ph_sel] # my_view(, [0, -1])
ph_feature_cp_raw = repeat_at(ph_feature, 1, n_agents)
agent2tp_onehot = torch.nn.functional.one_hot(hete_type.long(), num_classes=self.n_tp).unsqueeze(-1)
type_gp_mat = repeat_at(gp_sel_summary, -1, self.n_tp)
same_gp = (type_gp_mat == type_gp_mat.transpose(-1,-2)).long()
agent_self_type_mask2 = gather_righthand(same_gp, index=hete_type, check=False).unsqueeze(-1)
assert ph_feature_cp_raw.dim() == 4
ph_feature_cp2 = (ph_feature_cp_raw*(1-agent_self_type_mask2) + agent_self_type_mask2)
ph_feature_cp_obs_ = torch.cat((ph_feature_cp2, agent2tp_onehot), 2)
ph_feature_cp_critic_ = torch.cat((ph_feature_cp_raw, agent2tp_onehot), 2)
ph_feature_cp_obs = my_view(ph_feature_cp_obs_, [0,0,-1]) # ph_feature_cp_obs.shape = torch.Size([n_thread=16, n_agents=10, core_dim=12])
ph_feature_cp_critic = my_view(ph_feature_cp_critic_, [0,0,-1]) # ph_feature_cp_obs.shape = torch.Size([n_thread=16, n_agents=10, core_dim=12])
# add ph_feature to kwargs
kargs['obs_hfeature'] = ph_feature_cp_obs
# get a manifest of running nets
# invo_hete_types = [i for i in range(self.n_tp*self.n_gp) if (i in hete_pick)]
invo_gps = [i for i in range(self.n_gp) if (i in gp_sel_summary)]
running_nets = [self.nets[gp][0] for gp in invo_gps]
# make sure all nets under testing is frontend / frontier
if 'test_mode' in kargs and kargs['test_mode']:
for net in running_nets:
if not AlgorithmConfig.policy_matrix_testing: assert not net.static
# run actor policy networks
actor_result = distribute_compute(
fn_arr = running_nets,
mask_arr = [(self.ph_2_gp(hete_pick) == gp) for gp in invo_gps],
**kargs
)
# run critic network
kargs.pop('obs_hfeature') # replace h_feature
kargs['obs_hfeature_critic'] = ph_feature_cp_critic
critic_result = self._critic_central.estimate_state(**kargs)
# combine actor_result and critic_result
actor_result = list(actor_result)
for i, item in enumerate(actor_result):
if item=='vph': actor_result[i] = critic_result
# done !
return tuple(actor_result)
@Args2tensor_Return2numpy
def act(self, **kargs):
return self.exe(**kargs)
@Args2tensor
def evaluate_actions(self, **kargs):
return self.exe(**kargs, eval_mode=True)
def trim_ckp(self):
RemoveNew = True
max_static_gp = self.n_gp - 1
if len(self.ckpg_info) <= max_static_gp:
return
else:
assert len(self.ckpg_info) == max_static_gp+1
# find two ckp with nearest
winrate_list = np.array([self.ckpg_info[i]['win_rate'] for i in range(len(self.ckpg_info))])
winrate_list = np.abs(winrate_list[1:] - winrate_list[:-1])
index = np.argmin(winrate_list)
old_index = index
new_index = index + 1
if self.ckpg_info[new_index]['ckpg_cnt'] < self.ckpg_info[old_index]['ckpg_cnt']:
new_index, old_index = old_index, new_index
if RemoveNew:
self.ckpg_info.pop(new_index)
else:
self.ckpg_info.pop(old_index)
assert len(self.ckpg_info) == max_static_gp
pass
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/net.py
================================================
import torch, math, copy
import numpy as np
import torch.nn as nn
from torch.distributions.categorical import Categorical
from UTIL.colorful import print亮绿
from UTIL.tensor_ops import Args2tensor_Return2numpy, Args2tensor, __hashn__, my_view
from UTIL.tensor_ops import pt_inf
from UTIL.exp_helper import changed
from .ccategorical import CCategorical
from .foundation import AlgorithmConfig
from ALGORITHM.common.attention import SimpleAttention
from ALGORITHM.common.norm import DynamicNormFix
from ALGORITHM.common.net_manifest import weights_init
from ALGORITHM.common.hyper_net import HyperNet
"""
network initialize
"""
class Net(nn.Module):
def __init__(self, rawob_dim, n_action, **kwargs):
super().__init__()
self.update_cnt = nn.Parameter(
torch.zeros(1, requires_grad=False, dtype=torch.long), requires_grad=False)
self.use_normalization = AlgorithmConfig.use_normalization
self.use_policy_resonance = AlgorithmConfig.policy_resonance
self.n_action = n_action
if self.use_policy_resonance:
self.ccategorical = CCategorical(kwargs['stage_planner'])
self.is_resonance_active = lambda: kwargs['stage_planner'].is_resonance_active()
h_dim = AlgorithmConfig.net_hdim
# observation normalization
if self.use_normalization:
self._batch_norm = DynamicNormFix(rawob_dim, only_for_last_dim=True, exclude_one_hot=True, exclude_nan=True)
n_entity = AlgorithmConfig.n_entity_placeholder
# # # # # # # # # # actor-critic share # # # # # # # # # # # #
self.obs_encoder = nn.Sequential(nn.Linear(rawob_dim, h_dim), nn.ReLU(inplace=True), nn.Linear(h_dim, h_dim))
self.attention_layer = SimpleAttention(h_dim=h_dim)
# # # # # # # # # # actor # # # # # # # # # # # #
_size = n_entity * h_dim
self.hyper_net = HyperNet(embed_dim=h_dim, hyper_input_dim=6, x_input_dim=_size)
self.policy_head = nn.Sequential(
nn.Linear(h_dim, h_dim), nn.ReLU(inplace=True),
nn.Linear(h_dim, self.n_action))
self.is_recurrent = False
self.apply(weights_init)
return
def act(self, *args, **kargs):
return self._act(*args, **kargs)
def evaluate_actions(self, *args, **kargs):
return self._act(*args, **kargs, eval_mode=True)
def _act(self, obs=None, test_mode=None, eval_mode=False, eval_actions=None, avail_act=None, agent_ids=None, eprsn=None, obs_hfeature=None):
assert (self.ready_to_go)
mask_dead = torch.isnan(obs).any(-1) # find dead agents
# if not (obs[..., -3+self.tp][~mask_dead] == -1).all().item():
# assert False
if self.static:
assert self.gp >=1
# if not test_mode: assert not self.ready_to_go
eval_act = eval_actions if eval_mode else None
others = {}
if self.use_normalization:
if torch.isnan(obs).all(): pass
else: obs = self._batch_norm(obs, freeze=(eval_mode or test_mode or self.static))
obs_hfeature_norm = obs_hfeature
mask_dead = torch.isnan(obs).any(-1)
obs = torch.nan_to_num_(obs, 0) # replace dead agents' obs, from NaN to 0
# # # # # # # # # # actor-critic share # # # # # # # # # # # #
baec = self.obs_encoder(obs)
baec = self.attention_layer(k=baec,q=baec,v=baec, mask=mask_dead)
# # # # # # # # # # actor # # # # # # # # # # # #
at_bac = my_view(baec,[0,0,-1])
at_bac_hn = self.hyper_net(at_bac, hyper_x=obs_hfeature_norm)
logits = self.policy_head(at_bac_hn)
# choose action selector
logit2act = self._logit2act_rsn if self.use_policy_resonance and self.is_resonance_active() else self._logit2act
# apply action selector
act, actLogProbs, distEntropy, probs = logit2act( logits,
eval_mode=eval_mode,
greedy=(test_mode or self.static),
eval_actions=eval_act,
avail_act=avail_act,
eprsn=eprsn )
if not eval_mode: return act, 'vph', actLogProbs
else: return 'vph', actLogProbs, distEntropy, probs, others
def _logit2act_rsn(self, logits_agent_cluster, eval_mode, greedy, eval_actions=None, avail_act=None, eprsn=None):
if avail_act is not None: logits_agent_cluster = torch.where(avail_act>0, logits_agent_cluster, -pt_inf())
act_dist = self.ccategorical.feed_logits(logits_agent_cluster)
if not greedy: act = self.ccategorical.sample(act_dist, eprsn) if not eval_mode else eval_actions
else: act = torch.argmax(act_dist.probs, axis=2)
# the policy gradient loss will feedback from here
actLogProbs = self._get_act_log_probs(act_dist, act)
# sum up the log prob of all agents
distEntropy = act_dist.entropy().mean(-1) if eval_mode else None
return act, actLogProbs, distEntropy, act_dist.probs
def _logit2act(self, logits_agent_cluster, eval_mode, greedy, eval_actions=None, avail_act=None, **kwargs):
if avail_act is not None: logits_agent_cluster = torch.where(avail_act>0, logits_agent_cluster, -pt_inf())
act_dist = Categorical(logits = logits_agent_cluster)
if not greedy: act = act_dist.sample() if not eval_mode else eval_actions
else: act = torch.argmax(act_dist.probs, axis=2)
actLogProbs = self._get_act_log_probs(act_dist, act) # the policy gradient loss will feedback from here
# sum up the log prob of all agents
distEntropy = act_dist.entropy().mean(-1) if eval_mode else None
return act, actLogProbs, distEntropy, act_dist.probs
@staticmethod
def _get_act_log_probs(distribution, action):
return distribution.log_prob(action.squeeze(-1)).unsqueeze(-1)
class NetCentralCritic(nn.Module):
def __init__(self, rawob_dim, n_action, **kwargs):
super().__init__()
self.update_cnt = nn.Parameter(
torch.zeros(1, requires_grad=False, dtype=torch.long), requires_grad=False)
self.use_normalization = AlgorithmConfig.use_normalization
self.use_policy_resonance = AlgorithmConfig.policy_resonance
self.n_action = n_action
if self.use_policy_resonance:
self.ccategorical = CCategorical(kwargs['stage_planner'])
self.is_resonance_active = lambda: kwargs['stage_planner'].is_resonance_active()
h_dim = AlgorithmConfig.net_hdim
# observation normalization
if self.use_normalization:
self._batch_norm = DynamicNormFix(rawob_dim, only_for_last_dim=True, exclude_one_hot=True, exclude_nan=True)
n_entity = AlgorithmConfig.n_entity_placeholder
# # # # # # # # # # actor-critic share # # # # # # # # # # # #
self.obs_encoder = nn.Sequential(nn.Linear(rawob_dim, h_dim), nn.ReLU(inplace=True), nn.Linear(h_dim, h_dim))
self.attention_layer = SimpleAttention(h_dim=h_dim)
# # # # # # # # # # critic # # # # # # # # # # # #
_size = n_entity * h_dim
self.hyper_net = HyperNet(embed_dim=h_dim, hyper_input_dim=6, x_input_dim=_size)
self.ct_encoder = nn.Sequential(nn.Linear(h_dim, h_dim), nn.ReLU(inplace=True), nn.Linear(h_dim, h_dim))
self.ct_attention_layer = SimpleAttention(h_dim=h_dim)
self.get_value = nn.Sequential(nn.Linear(h_dim, h_dim), nn.ReLU(inplace=True),nn.Linear(h_dim, 1))
self.is_recurrent = False
self.apply(weights_init)
return
def estimate_state(self, obs=None, test_mode=None, eval_mode=False, eval_actions=None, avail_act=None, agent_ids=None, eprsn=None, obs_hfeature_critic=None):
if self.use_normalization:
if torch.isnan(obs).all(): pass
else: obs = self._batch_norm(obs, freeze=(eval_mode or test_mode))
obs_hfeature_norm = obs_hfeature_critic
mask_dead = torch.isnan(obs).any(-1)
obs = torch.nan_to_num_(obs, 0) # replace dead agents' obs, from NaN to 0
# # # # # # # # # # actor-critic share # # # # # # # # # # # #
baec = self.obs_encoder(obs)
baec = self.attention_layer(k=baec,q=baec,v=baec, mask=mask_dead)
# # # # # # # # # # critic # # # # # # # # # # # #
ct_bac = my_view(baec,[0,0,-1])
ct_bac_hn = self.hyper_net(ct_bac, hyper_x=obs_hfeature_norm)
ct_bac = self.ct_encoder(ct_bac_hn)
ct_bac = self.ct_attention_layer(k=ct_bac,q=ct_bac,v=ct_bac)
value = self.get_value(ct_bac)
return value
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/ppo.py
================================================
import torch, math, traceback
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import numpy as np
from random import randint, sample
from torch.utils.data.sampler import BatchSampler, SubsetRandomSampler
from UTIL.colorful import *
from UTIL.tensor_ops import _2tensor, __hash__, __hashn__
from config import GlobalConfig as cfg
from UTIL.gpu_share import GpuShareUnit
from .ppo_sampler import TrajPoolSampler
from VISUALIZE.mcom import mcom
class PPO():
def __init__(self, policy_and_critic, ppo_config, mcv=None):
self.policy_and_critic = policy_and_critic
self.clip_param = ppo_config.clip_param
self.ppo_epoch = ppo_config.ppo_epoch
self.use_avail_act = ppo_config.ppo_epoch
self.n_pieces_batch_division = ppo_config.n_pieces_batch_division
self.value_loss_coef = ppo_config.value_loss_coef
self.entropy_coef = ppo_config.entropy_coef
self.max_grad_norm = ppo_config.max_grad_norm
self.add_prob_loss = ppo_config.add_prob_loss
self.prevent_batchsize_oom = ppo_config.prevent_batchsize_oom
# self.freeze_body = ppo_config.freeze_body
self.lr = ppo_config.lr
self.all_parameter = list(policy_and_critic.named_parameters())
self.parameter = [p for p_name, p in self.all_parameter] # 535
# set learning rate differently?
if ppo_config.type_agent_diff_lr:
others_parameters = [v for k,v in self.all_parameter if '_nets_flat' not in k]
adam_lr_list = [
{'params': list(n.parameters()), 'lr':self.lr*n.lr_div} for n in policy_and_critic._nets_flat_placeholder_
] + [{'params': list(policy_and_critic._critic_central.parameters()), 'lr':self.lr}] # 33*3*5 + 40 = 535
assert sum([len(list(d['params'])) for d in adam_lr_list]) == len(self.all_parameter)
self.optimizer = optim.Adam(adam_lr_list, lr=self.lr)
else:
self.optimizer = optim.Adam(self.parameter, lr=self.lr)
self.g_update_delayer = 0
self.g_initial_value_loss = 0
# 轮流训练式
self.mcv = mcv
self.ppo_update_cnt = 0
self.batch_size_reminder = True
self.trivial_dict = {}
assert self.n_pieces_batch_division == 1
self.gpu_share_unit = GpuShareUnit(cfg.device, gpu_party=cfg.gpu_party)
self.mcv2 = mcom( path='%s/logger/ppo/'%cfg.logdir,
image_path='%s/detail_reward.jpg'%cfg.logdir,
rapid_flush=True,
draw_mode=cfg.draw_mode,
tag='[ppo.py]' )
self.mcv2.rec_init(color='g')
def freeze_body(self):
self.freeze_body = True
self.at_parameter = [p for p_name, p in self.all_parameter if 'AT_policy_head' in p_name]
self.at_optimizer = optim.Adam(self.at_parameter, lr=self.lr)
self.ct_parameter = [p for p_name, p in self.all_parameter if 'CT_' in p_name]
self.ct_optimizer = optim.Adam(self.ct_parameter, lr=self.lr*10.0) #(self.lr)
print('change train object')
def train_on_traj(self, traj_pool, task):
while True:
try:
with self.gpu_share_unit:
self.train_on_traj_(traj_pool, task)
break # 运行到这说明显存充足
except RuntimeError as err:
print(traceback.format_exc())
if self.prevent_batchsize_oom:
# in some cases, reversing MaxSampleNum a single time is not enough
if TrajPoolSampler.MaxSampleNum[-1] < 0: TrajPoolSampler.MaxSampleNum.pop(-1)
assert TrajPoolSampler.MaxSampleNum[-1] > 0
TrajPoolSampler.MaxSampleNum[-1] = -1
print亮红('Insufficient gpu memory, using previous sample size !')
else:
assert False
torch.cuda.empty_cache()
def log_reward_rich(self, traj_pool, mcv2):
tags = {}
for traj in traj_pool:
traj.reward_sum = sum(traj.reward[:,0])
gp_list = traj.gp_sel_summary[0]
if (gp_list==0).all():
tag = 'frontend'
if tag not in tags: tags[tag] = []
tags[tag].append(traj.reward_sum)
else:
gp = max(gp_list)
wr = self.policy_and_critic.ckpg_info[gp-1]['win_rate']
tp = np.argmax(gp_list)
tag = 'tp:%d wr:%.2f'%(tp, wr)
if tag not in tags: tags[tag] = []
tags[tag].append(traj.reward_sum)
tags = dict(sorted(tags.items()))
for k in tags:
mcv2.rec(np.array(tags[k]).mean(), k)
mcv2.rec_show()
def train_on_traj_(self, traj_pool, task):
self.log_reward_rich(traj_pool, self.mcv2)
ppo_valid_percent_list = []
sampler = TrajPoolSampler(n_div=1, traj_pool=traj_pool, flag=task, prevent_batchsize_oom=self.prevent_batchsize_oom, mcv=self.mcv)
# before_training_hash = [__hashn__(t.parameters()) for t in (self.policy_and_critic._nets_flat_placeholder_)]
for e in range(self.ppo_epoch):
sample_iter = sampler.reset_and_get_iter()
self.optimizer.zero_grad()
# ! get traj fragment
sample = next(sample_iter)
# ! build graph, then update network
loss_final, others = self.establish_pytorch_graph(task, sample, e)
loss_final = loss_final*0.5
if e==0: print('[PPO.py] Memory Allocated %.2f GB'%(torch.cuda.memory_allocated()/1073741824))
loss_final.backward()
# log
ppo_valid_percent_list.append(others.pop('PPO valid percent').item())
self.log_trivial(dictionary=others); others = None
nn.utils.clip_grad_norm_(self.parameter, self.max_grad_norm)
self.optimizer.step()
if ppo_valid_percent_list[-1] < 0.70:
print亮黄('policy change too much, epoch terminate early'); break
pass # finish all epoch update
print亮黄(np.array(ppo_valid_percent_list))
self.log_trivial_finalize()
net_updated = [any([p.grad is not None for p in t.parameters()]) for t in (self.policy_and_critic._nets_flat_placeholder_)]
self.optimizer.zero_grad(set_to_none=True)
self.ppo_update_cnt += 1
for updated, net in zip(net_updated, self.policy_and_critic._nets_flat_placeholder_):
if updated:
net.update_cnt.data[0] = self.ppo_update_cnt
self.policy_and_critic.on_update(self.ppo_update_cnt)
torch.cuda.empty_cache()
return self.ppo_update_cnt
def freeze_body(self):
assert False, "function forbidden"
self.freeze_body = True
self.parameter_pv = [p_name for p_name, p in self.all_parameter if not any(p_name.startswith(kw) for kw in ('obs_encoder', 'attention_layer'))]
self.parameter = [p for p_name, p in self.all_parameter if not any(p_name.startswith(kw) for kw in ('obs_encoder', 'attention_layer'))]
self.optimizer = optim.Adam(self.parameter, lr=self.lr)
print('change train object')
def log_trivial(self, dictionary):
for key in dictionary:
if key not in self.trivial_dict: self.trivial_dict[key] = []
item = dictionary[key].item() if hasattr(dictionary[key], 'item') else dictionary[key]
self.trivial_dict[key].append(item)
def log_trivial_finalize(self, print=True):
for key in self.trivial_dict:
self.trivial_dict[key] = np.array(self.trivial_dict[key])
print_buf = ['[ppo.py] ']
for key in self.trivial_dict:
self.trivial_dict[key] = self.trivial_dict[key].mean()
print_buf.append(' %s:%.3f, '%(key, self.trivial_dict[key]))
if self.mcv is not None: self.mcv.rec(self.trivial_dict[key], key)
if print: print紫(''.join(print_buf))
if self.mcv is not None:
self.mcv.rec_show()
self.trivial_dict = {}
def establish_pytorch_graph(self, flag, sample, n):
obs = _2tensor(sample['obs'])
advantage = _2tensor(sample['advantage'])
action = _2tensor(sample['action'])
oldPi_actionLogProb = _2tensor(sample['actionLogProb'])
real_value = _2tensor(sample['return'])
hete_pick = _2tensor(sample['hete_pick'])
hete_type = _2tensor(sample['hete_type'])
gp_sel_summary = _2tensor(sample['gp_sel_summary'])
avail_act = _2tensor(sample['avail_act']) if 'avail_act' in sample else None
# batchsize = advantage.shape[0]#; print亮紫(batchsize)
batch_agent_size = advantage.shape[0]*advantage.shape[1]
assert flag == 'train'
newPi_value, newPi_actionLogProb, entropy, probs, others = \
self.policy_and_critic.evaluate_actions(
obs=obs,
eval_actions=action,
test_mode=False,
avail_act=avail_act,
hete_pick=hete_pick,
hete_type=hete_type,
gp_sel_summary=gp_sel_summary)
entropy_loss = entropy.mean()
n_actions = probs.shape[-1]
if self.add_prob_loss: assert n_actions <= 15 #
penalty_prob_line = (1/n_actions)*0.12
probs_loss = (penalty_prob_line - torch.clamp(probs, min=0, max=penalty_prob_line)).mean()
if not self.add_prob_loss:
probs_loss = torch.zeros_like(probs_loss)
# dual clip ppo core
E = newPi_actionLogProb - oldPi_actionLogProb
E_clip = torch.zeros_like(E)
E_clip = torch.where(advantage > 0, torch.clamp(E, max=np.log(1.0+self.clip_param)), E_clip)
E_clip = torch.where(advantage < 0, torch.clamp(E, min=np.log(1.0-self.clip_param), max=np.log(5) ), E_clip)
ratio = torch.exp(E_clip)
policy_loss = -(ratio*advantage).mean()
# add all loses
value_loss = 0.5 * F.mse_loss(real_value, newPi_value)
AT_net_loss = policy_loss - entropy_loss*self.entropy_coef # + probs_loss*20
CT_net_loss = value_loss * 1.0
# AE_new_loss = ae_loss * 1.0
loss_final = AT_net_loss + CT_net_loss # + AE_new_loss
ppo_valid_percent = ((E_clip == E).int().sum()/batch_agent_size)
nz_mask = real_value!=0
value_loss_abs = (real_value[nz_mask] - newPi_value[nz_mask]).abs().mean()
others = {
'Value loss Abs': value_loss_abs,
'PPO valid percent': ppo_valid_percent,
'CT_net_loss': CT_net_loss,
'AT_net_loss': AT_net_loss,
}
return loss_final, others
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/ppo_sampler.py
================================================
import torch, math, traceback
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import numpy as np
from random import randint, sample
from torch.utils.data.sampler import BatchSampler, SubsetRandomSampler
from UTIL.colorful import *
from UTIL.tensor_ops import _2tensor, __hash__, repeat_at
from config import GlobalConfig as cfg
from UTIL.gpu_share import GpuShareUnit
class TrajPoolSampler():
def __init__(self, n_div, traj_pool, flag, prevent_batchsize_oom=False, mcv=None):
self.n_pieces_batch_division = n_div
self.prevent_batchsize_oom = prevent_batchsize_oom
self.mcv = mcv
if self.prevent_batchsize_oom:
assert self.n_pieces_batch_division==1, ('?')
self.num_batch = None
self.container = {}
self.warned = False
assert flag=='train'
req_dict = ['hete_type', 'gp_sel_summary', 'avail_act', 'obs', 'action', 'actionLogProb', 'return', 'reward', 'hete_pick', 'value']
req_dict_rename = ['hete_type', 'gp_sel_summary', 'avail_act', 'obs', 'action', 'actionLogProb', 'return', 'reward', 'hete_pick', 'state_value']
return_rename = "return"
value_rename = "state_value"
advantage_rename = "advantage"
# replace 'obs' to 'obs > xxxx'
for key_index, key in enumerate(req_dict):
key_name = req_dict[key_index]
key_rename = req_dict_rename[key_index]
if not hasattr(traj_pool[0], key_name):
real_key_list = [real_key for real_key in traj_pool[0].__dict__ if (key_name+'>' in real_key)]
assert len(real_key_list) > 0, ('check variable provided!', key,key_index)
for real_key in real_key_list:
mainkey, subkey = real_key.split('>')
req_dict.append(real_key)
req_dict_rename.append(key_rename+'>'+subkey)
self.big_batch_size = -1 # vector should have same length, check it!
# load traj into a 'container'
for key_index, key in enumerate(req_dict):
key_name = req_dict[key_index]
key_rename = req_dict_rename[key_index]
if not hasattr(traj_pool[0], key_name): continue
set_item = np.concatenate([getattr(traj, key_name) for traj in traj_pool], axis=0)
if not (self.big_batch_size==set_item.shape[0] or (self.big_batch_size<0)):
print('error')
assert self.big_batch_size==set_item.shape[0] or (self.big_batch_size<0), (key,key_index)
self.big_batch_size = set_item.shape[0]
self.container[key_rename] = set_item # 指针赋值
# normalize advantage inside the batch
self.container[advantage_rename] = self.container[return_rename] - self.container[value_rename]
self.container[advantage_rename] = ( self.container[advantage_rename] - self.container[advantage_rename].mean() ) / (self.container[advantage_rename].std() + 1e-5)
# size of minibatch for each agent
self.mini_batch_size = math.ceil(self.big_batch_size / self.n_pieces_batch_division)
def __len__(self):
return self.n_pieces_batch_division
def determine_max_n_sample(self):
assert self.prevent_batchsize_oom
if not hasattr(TrajPoolSampler,'MaxSampleNum'):
# initialization
TrajPoolSampler.MaxSampleNum = [int(self.big_batch_size*(i+1)/50) for i in range(50)]
max_n_sample = self.big_batch_size
elif TrajPoolSampler.MaxSampleNum[-1] > 0:
# meaning that oom never happen, at least not yet
# only update when the batch size increases
if self.big_batch_size > TrajPoolSampler.MaxSampleNum[-1]: TrajPoolSampler.MaxSampleNum.append(self.big_batch_size)
max_n_sample = self.big_batch_size
else:
# meaning that oom already happened, choose TrajPoolSampler.MaxSampleNum[-2] to be the limit
assert TrajPoolSampler.MaxSampleNum[-2] > 0
max_n_sample = TrajPoolSampler.MaxSampleNum[-2]
return max_n_sample
def reset_and_get_iter(self):
if not self.prevent_batchsize_oom:
self.sampler = BatchSampler(SubsetRandomSampler(range(self.big_batch_size)), self.mini_batch_size, drop_last=False)
else:
max_n_sample = self.determine_max_n_sample()
n_sample = min(self.big_batch_size, max_n_sample)
if not hasattr(self,'reminded'):
self.reminded = True
drop_percent = (self.big_batch_size-n_sample)/self.big_batch_size*100
if self.mcv is not None:
self.mcv.rec(drop_percent, 'drop percent')
if drop_percent > 20:
print_ = print亮红
print_('droping %.1f percent samples..'%(drop_percent))
assert False, "GPU OOM!"
else:
print_ = print
print_('droping %.1f percent samples..'%(drop_percent))
self.sampler = BatchSampler(SubsetRandomSampler(range(n_sample)), n_sample, drop_last=False)
for indices in self.sampler:
selected = {}
for key in self.container:
selected[key] = self.container[key][indices]
for key in [key for key in selected if '>' in key]:
# 重新把子母键值组合成二重字典
mainkey, subkey = key.split('>')
if not mainkey in selected: selected[mainkey] = {}
selected[mainkey][subkey] = selected[key]
del selected[key]
yield selected
================================================
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/shell_env.py
================================================
import numpy as np
from config import GlobalConfig
from UTIL.colorful import *
from UTIL.tensor_ops import my_view, __hash__, repeat_at, gather_righthand
from MISSION.uhmap.actset_lookup import encode_action_as_digits
from .foundation import AlgorithmConfig
from .cython_func import roll_hisory
from .hete_assignment import select_nets_for_shellenv
class ShellEnvConfig:
add_avail_act = False
class ActionConvertLegacy():
def __init__(self, SELF_TEAM_ASSUME, OPP_TEAM_ASSUME, OPP_NUM_ASSUME) -> None:
self.SELF_TEAM_ASSUME = SELF_TEAM_ASSUME
self.OPP_TEAM_ASSUME = OPP_TEAM_ASSUME
self.OPP_NUM_ASSUME = OPP_NUM_ASSUME
# (main_cmd, sub_cmd, x=None, y=None, z=None, UID=None, T=None, T_index=None)
self.dictionary_args = [
('N/A', 'N/A', None, None, None, None, None, None), # 0
('Idle', 'DynamicGuard', None, None, None, None, None, None), # 1
('Idle', 'StaticAlert', None, None, None, None, None, None), # 2
('Idle', 'AsFarAsPossible', None, None, None, None, None, None), # 4
('Idle', 'StayWhenTargetInRange', None, None, None, None, None, None), # 5
('SpecificMoving', 'Dir+X', None, None, None, None, None, None), # 7
('SpecificMoving', 'Dir+Y', None, None, None, None, None, None), # 8
('SpecificMoving', 'Dir-X', None, None, None, None, None, None), # 9
('SpecificMoving', 'Dir-Y', None, None, None, None, None, None), # 10
]
for i in range(self.OPP_NUM_ASSUME):
self.dictionary_args.append( ('SpecificAttacking', 'N/A', None, None, None, None, OPP_TEAM_ASSUME, i) )
def convert_act_arr(self, type, a):
if type == 'RLA_UAV_Support':
args = self.dictionary_args[a]
# override wrong actions
if args[0] == 'SpecificAttacking':
return encode_action_as_digits('N/A', 'N/A', None, None, None, None, None, None)
# override incorrect actions
if args[0] == 'Idle':
return encode_action_as_digits('Idle', 'StaticAlert', None, None, None, None, None, None)
return encode_action_as_digits(*args)
else:
return encode_action_as_digits(*self.dictionary_args[a])
def get_tp_avail_act(self, type):
DISABLE = 0
ENABLE = 1
n_act = len(self.dictionary_args)
ret = np.zeros(n_act) + ENABLE
for i in range(n_act):
args = self.dictionary_args[i]
# for all kind of agents
if args[0] == 'PatrolMoving': ret[i] = DISABLE
if type == 'RLA_UAV_Support':
if args[0] == 'PatrolMoving': ret[i] = DISABLE
if args[0] == 'SpecificAttacking': ret[i] = DISABLE
if args[0] == 'Idle': ret[i] = DISABLE
if args[1] == 'StaticAlert': ret[i] = ENABLE
return ret
def confirm_parameters_are_correct(self, team, agent_num, opp_agent_num):
assert team == self.SELF_TEAM_ASSUME
assert self.SELF_TEAM_ASSUME + se
gitextract_cudsbdvr/ ├── .gitignore ├── BuildLinuxRender.py ├── BuildLinuxServer.py ├── BuildWindowsRender.py ├── BuildWindowsServer.py ├── Config/ │ ├── DefaultEditor.ini │ ├── DefaultEditorPerProjectUserSettings.ini │ ├── DefaultEngine.ini │ ├── DefaultGame.ini │ └── DefaultInput.ini ├── Content/ │ ├── Assets/ │ │ ├── AbstractActor/ │ │ │ ├── Agent.uasset │ │ │ ├── DeleteOnResetActor.uasset │ │ │ ├── HmapDefaultPawn.uasset │ │ │ ├── HmapDefaultPawnLegacy.uasset │ │ │ ├── HmapDefaultPawnMinimap.uasset │ │ │ └── ReqResetActor.uasset │ │ ├── CoreSystem/ │ │ │ ├── CoreControl.uasset │ │ │ ├── CoreFunctionLib.uasset │ │ │ ├── HmapGameMode.uasset │ │ │ ├── HmapHud.uasset │ │ │ ├── PerceptionComponentEfficient.uasset │ │ │ └── PerceptionInterface.uasset │ │ ├── DefAction/ │ │ │ └── ParseAction.uasset │ │ ├── DefAgent/ │ │ │ ├── AgentTypeManifest.uasset │ │ │ ├── DefAirAgent/ │ │ │ │ ├── RLA_UAV.uasset │ │ │ │ ├── RLA_UAV_Support.uasset │ │ │ │ ├── RLA_UAV_Support_V2.uasset │ │ │ │ └── RLA_UAV_VIP.uasset │ │ │ ├── DefAttackPost/ │ │ │ │ ├── Attacker.uasset │ │ │ │ ├── Lv3_DefenceTank.uasset │ │ │ │ ├── Lv3_DefenceTower.uasset │ │ │ │ └── PosAttacker.uasset │ │ │ ├── DefCarAgent/ │ │ │ │ ├── RLA_CAR.uasset │ │ │ │ ├── RLA_CAR_RED.uasset │ │ │ │ └── RLA_LaserLauncher.uasset │ │ │ ├── DefCarrierAgent/ │ │ │ │ ├── Carrier.uasset │ │ │ │ ├── DroneMesh.uasset │ │ │ │ └── SmallDrone.uasset │ │ │ ├── DefControl/ │ │ │ │ ├── AC_RL.uasset │ │ │ │ ├── AC_RL_ACCESS.uasset │ │ │ │ ├── AC_RL_ACCESS_LaserWeaponV2.uasset │ │ │ │ └── AC_RL_ACCESS_NoWeapon.uasset │ │ │ ├── DefFormation/ │ │ │ │ ├── Lv2_MomentumTestAgentSensor.uasset │ │ │ │ └── Lv3_MomentumAgentWithHp.uasset │ │ │ ├── DefIntercept/ │ │ │ │ ├── Attacker.uasset │ │ │ │ ├── Defender.uasset │ │ │ │ └── Landmark.uasset │ │ │ ├── DefPlane/ │ │ │ │ ├── PlaneAgent.uasset │ │ │ │ ├── UAV_Dragon.uasset │ │ │ │ └── UAV_Rainbow.uasset │ │ │ ├── DefPreyPredator/ │ │ │ │ ├── Predator.uasset │ │ │ │ └── Prey.uasset │ │ │ ├── DefReproduce/ │ │ │ │ └── DummyAgent.uasset │ │ │ ├── DefTarget/ │ │ │ │ ├── AirDefense.uasset │ │ │ │ ├── Commander.uasset │ │ │ │ ├── Missile.uasset │ │ │ │ ├── Target_Agent.uasset │ │ │ │ ├── air_defense.uasset │ │ │ │ └── fleet.uasset │ │ │ ├── DefWaterdrop/ │ │ │ │ ├── Ship.uasset │ │ │ │ └── Waterdrop.uasset │ │ │ ├── Lv1_AgentCanMoveLegacy.uasset │ │ │ ├── Lv1_MomentumAgent.uasset │ │ │ ├── Lv1_MoveAgent.uasset │ │ │ ├── Lv1_TestFlyingAgent.uasset │ │ │ ├── Lv1_TestWalkingAgent.uasset │ │ │ ├── Lv2_AgentCanControlLegacy.uasset │ │ │ ├── Lv2_TestAgentSensor.uasset │ │ │ ├── Lv3_AgentWithHp.uasset │ │ │ ├── SharedBehaviorTree/ │ │ │ │ ├── ATTACK_MICRO_MANAGE.uasset │ │ │ │ ├── BB_RL.uasset │ │ │ │ ├── BT_RL_V2.uasset │ │ │ │ ├── RL_CMD_IDLE_SETTING.uasset │ │ │ │ └── RL_CMD_STATE.uasset │ │ │ └── SharedTask/ │ │ │ ├── ArgKeepDistanceToTargetOrLocationV3.uasset │ │ │ ├── BTService_CallingGuardLocationUpdateV2.uasset │ │ │ ├── CallChangeCmdStateToIdleV2.uasset │ │ │ ├── CallGuardLocationUpdateV2.uasset │ │ │ ├── SetFocusToTargetOrLocation.uasset │ │ │ ├── WeaponFiringNoFinishV2.uasset │ │ │ └── cancel_movementV2.uasset │ │ ├── DefNotAgent/ │ │ │ ├── BP_Explosion.uasset │ │ │ ├── BP_Explosion_TypeB.uasset │ │ │ ├── DefReqResetActor/ │ │ │ │ ├── AgentKillerWall/ │ │ │ │ │ ├── Cylinder_Brush_StaticMesh.uasset │ │ │ │ │ ├── KillZoneInvisible.uasset │ │ │ │ │ ├── KillZoneInvisible_Circle.uasset │ │ │ │ │ └── KillZoneInvisible_Dynamic.uasset │ │ │ │ ├── FlagToCapture.uasset │ │ │ │ ├── KeyObjDecoration.uasset │ │ │ │ ├── RecordWhoGetInside/ │ │ │ │ │ ├── InvisibleTrigger.uasset │ │ │ │ │ └── InvisibleTrigger_CanEndEpisode.uasset │ │ │ │ └── VipTargetToReach/ │ │ │ │ └── KeyObjExample.uasset │ │ │ ├── General_Laser.uasset │ │ │ ├── LaserForIntercept.uasset │ │ │ ├── Weapon_Laser.uasset │ │ │ ├── Weapon_MissileTypeC.uasset │ │ │ └── toy.uasset │ │ ├── GUI/ │ │ │ ├── ChildMap.uasset │ │ │ ├── ChildMapWidget.uasset │ │ │ ├── HpBar.uasset │ │ │ ├── Icon_Cmd.uasset │ │ │ ├── Icons.uasset │ │ │ ├── Icons_airport.uasset │ │ │ ├── Icons_cmd.uasset │ │ │ ├── Icons_missile.uasset │ │ │ ├── Icons_target.uasset │ │ │ ├── MouseTraceSelector.uasset │ │ │ ├── PlaneIcon.uasset │ │ │ ├── RingMark.uasset │ │ │ ├── SelectEffect.uasset │ │ │ ├── airport.uasset │ │ │ ├── house.uasset │ │ │ ├── missile.uasset │ │ │ └── 飞机2.uasset │ │ └── Trashbin/ │ │ └── DroneAgentBlueprint/ │ │ ├── AC_Drone.uasset │ │ ├── AC_Drone_Opp.uasset │ │ ├── BB_Drone.uasset │ │ ├── BT_Drone.uasset │ │ ├── BT_Drone_Opp.uasset │ │ ├── Drone.uasset │ │ ├── Drone_Ground.uasset │ │ ├── Drone_Ground_Opp.uasset │ │ ├── EndlessPatrol.uasset │ │ ├── KeepDistanceToTargetOrLocation.uasset │ │ ├── KeepMsFiringToTarget.uasset │ │ ├── LinkingPoint.uasset │ │ ├── LinkingPointGroup.uasset │ │ ├── MaintainDistanceToTargetOrLocation.uasset │ │ └── MissileTypeB.uasset │ └── Maps/ │ ├── AirportSwarmTraining.umap │ ├── AirportSwarmTraining_BuiltData.uasset │ ├── AutoEntry.umap │ ├── Entry.umap │ ├── TestCradle.umap │ ├── TestCradle_BuiltData.uasset │ ├── UhmapAttackPost.umap │ ├── UhmapAttackPost_BuiltData.uasset │ ├── UhmapBreakingBad.umap │ ├── UhmapBreakingBad_BuiltData.uasset │ ├── UhmapCarrier.umap │ ├── UhmapCarrier_BuiltData.uasset │ ├── UhmapFlagCapture.umap │ ├── UhmapFormation.umap │ ├── UhmapIntercept.umap │ ├── UhmapJustAnIsland_BuiltData.uasset │ ├── UhmapLargeScale.umap │ ├── UhmapLargeScaleLegacy.umap │ ├── UhmapLargeScale_BuiltData.uasset │ ├── UhmapPreyPredator.umap │ ├── UhmapReproduce.umap │ ├── UhmapReproduce_BuiltData.uasset │ ├── UhmapTemplate.umap │ ├── UhmapTemplate_BuiltData.uasset │ ├── UhmapWaterdrop.umap │ └── UhmapWaterdrop_BuiltData.uasset ├── Docs/ │ ├── git_coop.md │ └── old_install_method/ │ └── README.md ├── Please_Run_This_First_To_Fetch_Big_Files.py ├── PythonExample/ │ ├── README.md │ └── hmp_minimal_modules/ │ ├── .gitattributes │ ├── .gitignore │ ├── .gitmodules │ ├── ALGORITHM/ │ │ ├── common/ │ │ │ ├── alg_base.py │ │ │ ├── attention.py │ │ │ ├── conc.py │ │ │ ├── dl_pool.py │ │ │ ├── his.py │ │ │ ├── hyper_net.py │ │ │ ├── logit2act.py │ │ │ ├── mlp.py │ │ │ ├── net_manifest.py │ │ │ ├── norm.py │ │ │ ├── pca.py │ │ │ ├── ppo_sampler.py │ │ │ ├── rl_alg_base.py │ │ │ ├── traj.py │ │ │ ├── traj_gae.py │ │ │ └── traj_manager.py │ │ ├── example_foundation.py │ │ ├── hete_league_onenet_fix/ │ │ │ ├── ccategorical.py │ │ │ ├── cython_func.pyx │ │ │ ├── div_tree.py │ │ │ ├── foundation.py │ │ │ ├── hete_assignment.py │ │ │ ├── hete_net.py │ │ │ ├── net.py │ │ │ ├── ppo.py │ │ │ ├── ppo_sampler.py │ │ │ ├── shell_env.py │ │ │ ├── stage_planner.py │ │ │ └── trajectory.py │ │ ├── my_ai/ │ │ │ └── foundation.py │ │ ├── ppo_ma/ │ │ │ ├── ccategorical.py │ │ │ ├── cython_func.pyx │ │ │ ├── div_tree.py │ │ │ ├── foundation.py │ │ │ ├── net.py │ │ │ ├── ppo.py │ │ │ ├── ppo_sampler.py │ │ │ ├── shell_env.py │ │ │ ├── stage_planner.py │ │ │ └── trajectory.py │ │ ├── random/ │ │ │ ├── actionset.py │ │ │ └── foundation.py │ │ └── script_ai/ │ │ ├── a_attackpost.py │ │ ├── a_escape.py │ │ ├── a_test_reproduce.py │ │ ├── assignment.py │ │ ├── blue_strategy.py │ │ ├── decision.py │ │ ├── dummy.py │ │ ├── dummy_uhmap.py │ │ ├── global_params.py │ │ ├── manual.py │ │ ├── module_evaluation.py │ │ ├── red_strategy.py │ │ ├── stance.py │ │ ├── uhmap_bb.py │ │ ├── uhmap_island.py │ │ ├── uhmap_ls.py │ │ └── uhmap_ls_mp.py │ ├── LICENSE │ ├── MISSION/ │ │ ├── common/ │ │ │ └── base_env.py │ │ ├── env_router.py │ │ ├── readme.md │ │ └── uhmap/ │ │ ├── SubTasks/ │ │ │ ├── SubtaskCommonFn.py │ │ │ ├── UhmapAdversial.py │ │ │ ├── UhmapAdversialConf.py │ │ │ ├── UhmapAttackPost.py │ │ │ ├── UhmapAttackPostConf.py │ │ │ ├── UhmapBreakingBad.py │ │ │ ├── UhmapBreakingBadConf.py │ │ │ ├── UhmapCarrier.py │ │ │ ├── UhmapCarrierConf.py │ │ │ ├── UhmapEscape.py │ │ │ ├── UhmapEscapeConf.py │ │ │ ├── UhmapFormation.py │ │ │ ├── UhmapFormationConf.py │ │ │ ├── UhmapHuge.py │ │ │ ├── UhmapHugeConf.py │ │ │ ├── UhmapIntercept.py │ │ │ ├── UhmapInterceptConf.py │ │ │ ├── UhmapJustAnIsland.py │ │ │ ├── UhmapJustAnIslandConf.py │ │ │ ├── UhmapLargeScale.py │ │ │ ├── UhmapLargeScaleConf.py │ │ │ ├── UhmapPreyPredator.py │ │ │ ├── UhmapPreyPredatorConf.py │ │ │ ├── UhmapReproduce.py │ │ │ ├── UhmapReproduceConf.py │ │ │ ├── UhmapWaterdrop.py │ │ │ ├── UhmapWaterdropConf.py │ │ │ └── cython_func.pyx │ │ ├── actionset.py │ │ ├── actionset_v3.py │ │ ├── actset_lookup.py │ │ ├── agent.py │ │ ├── auto_download.py │ │ ├── struct.cpp │ │ ├── uhmap.md │ │ └── uhmap_env_wrapper.py │ ├── README.md │ ├── UTIL/ │ │ ├── __init__.py │ │ ├── auto_gpu.py │ │ ├── batch_exp.py │ │ ├── colorful.py │ │ ├── config_args.py │ │ ├── data_struct.py │ │ ├── exp_helper.py │ │ ├── fetch_multiserver.py │ │ ├── file_lock.py │ │ ├── gpu_eater.py │ │ ├── gpu_share.py │ │ ├── hidden_print.py │ │ ├── hmp_daemon.py │ │ ├── legacy/ │ │ │ └── gpu_share_unfin.py │ │ ├── mem_watcher_ue.py │ │ ├── memleak_finder.py │ │ ├── mprofile.py │ │ ├── mserver_launcher.sh │ │ ├── network.py │ │ ├── pip_find_missing.py │ │ ├── shm_env.py │ │ ├── shm_pool.pyx │ │ ├── sync_exp.py │ │ ├── tensor_ops.py │ │ ├── tensor_ops_c.pyx │ │ └── win_pool.py │ ├── VISUALIZE/ │ │ ├── README.md │ │ ├── __init__.py │ │ ├── color.html │ │ ├── mcom.py │ │ ├── mcom_def.py │ │ ├── mcom_rec.py │ │ ├── mcom_replay.py │ │ ├── mcom_rt.py │ │ ├── mcom_test.py │ │ ├── mcom_v2d.py │ │ ├── read_group_replay.ipynb │ │ ├── seaborn_defaults.py │ │ └── threejs_replay.py │ ├── ZDOCS/ │ │ ├── Dockerfile │ │ ├── DockerfilePython311 │ │ ├── bashrc_suffix │ │ ├── examples/ │ │ │ └── uhmap/ │ │ │ ├── AirAttack.jsonc │ │ │ ├── AirShow.jsonc │ │ │ ├── hlt+50vs50.jsonc │ │ │ ├── ppoma+50vs50.jsonc │ │ │ ├── ppoma+intercept.jsonc │ │ │ ├── ppoma+predatorprey.jsonc │ │ │ ├── ppoma+uhmap10vs10hete.jsonc │ │ │ ├── ppoma_waterdrop.jsonc │ │ │ ├── qmix+uhmap10vs10hete.jsonc │ │ │ ├── qmix+uhmap20vs20.jsonc │ │ │ ├── qmix+uhmap50vs50+debug.jsonc │ │ │ ├── qmix+uhmap50vs50.jsonc │ │ │ ├── qplex+uhmap10vs10hete.jsonc │ │ │ ├── qtran+uhmap10vs10hete.jsonc │ │ │ └── random_waterdrop.jsonc │ │ ├── pip_requirement.md │ │ ├── sc2checkversion │ │ ├── setup_docker.md │ │ ├── setup_no_docker.md │ │ ├── setup_ubuntu.md │ │ ├── setup_ue_docker.md │ │ ├── ssh_pubkey.sh │ │ ├── test_examples.py │ │ ├── use_pymarl2.md │ │ └── use_unreal_hmap.md │ ├── ZHECKPOINT/ │ │ └── uhmap_hete10vs10/ │ │ ├── experiment_test.jsonc │ │ ├── render_result.jsonc │ │ ├── render_result_editor.jsonc │ │ └── render_result_editor2.jsonc │ ├── agent_with_sensor.jsonc │ ├── attack_post.jsonc │ ├── carrier.jsonc │ ├── config.py │ ├── cradle.ipynb │ ├── cradle.py │ ├── escape.jsonc │ ├── formation.jsonc │ ├── main.py │ ├── multi_server.py │ ├── multi_team.py │ ├── multi_team_parallel.py │ ├── reproduce.jsonc │ └── task_runner.py ├── README.md ├── README_CN.md ├── Source/ │ ├── Jsonx/ │ │ ├── Jsonx.Build.cs │ │ ├── Private/ │ │ │ ├── Dom/ │ │ │ │ ├── JsonxObject.cpp │ │ │ │ └── JsonxValue.cpp │ │ │ ├── JsonxModule.cpp │ │ │ └── Tests/ │ │ │ └── JsonxTests.cpp │ │ └── Public/ │ │ ├── Dom/ │ │ │ ├── JsonxObject.h │ │ │ └── JsonxValue.h │ │ ├── Jsonx.h │ │ ├── JsonxGlobals.h │ │ ├── JsonxUtils/ │ │ │ └── JsonxObjectArrayUpdater.h │ │ ├── Policies/ │ │ │ ├── CondensedJsonxPrintPolicy.h │ │ │ ├── JsonxPrintPolicy.h │ │ │ └── PrettyJsonxPrintPolicy.h │ │ └── Serialization/ │ │ ├── JsonxReader.h │ │ ├── JsonxSerializer.h │ │ ├── JsonxSerializerMacros.h │ │ ├── JsonxTypes.h │ │ └── JsonxWriter.h │ ├── JsonxUtilities/ │ │ ├── JsonxUtilities.Build.cs │ │ ├── Private/ │ │ │ ├── JsonxObjectConverter.cpp │ │ │ ├── JsonxObjectWrapper.cpp │ │ │ └── JsonxUtilitiesModule.cpp │ │ └── Public/ │ │ ├── JsonxDomBuilder.h │ │ ├── JsonxObjectConverter.h │ │ ├── JsonxObjectWrapper.h │ │ └── JsonxUtilities.h │ ├── UHMP/ │ │ ├── AgentBaseCpp.cpp │ │ ├── AgentBaseCpp.h │ │ ├── DataStruct.h │ │ ├── HMPAIController.cpp │ │ ├── HMPAIController.h │ │ ├── HMPLevelScriptActor.cpp │ │ ├── HMPLevelScriptActor.h │ │ ├── HmpCrowdFollowingComponent.cpp │ │ ├── HmpCrowdFollowingComponent.h │ │ ├── HmpPythonIO.cpp │ │ ├── HmpPythonIO.h │ │ ├── IOCompress/ │ │ │ ├── lz4.c │ │ │ └── lz4.h │ │ ├── UHMP.Build.cs │ │ ├── UHMP.cpp │ │ ├── UHMP.h │ │ ├── UHMPBlueprintFunctionLibrary.cpp │ │ └── UHMPBlueprintFunctionLibrary.h │ ├── UHMP.Target.cs │ ├── UHMPEditor.Target.cs │ └── UHMPServer.Target.cs ├── build.py ├── compress.txt ├── current_version ├── onedrive_util.py ├── test_memory_leak.py └── upload_big_file.py
SYMBOL INDEX (1684 symbols across 166 files)
FILE: BuildLinuxRender.py
function print亮绿 (line 16) | def print亮绿(*kw,**kargs):
FILE: BuildLinuxServer.py
function print亮绿 (line 16) | def print亮绿(*kw,**kargs):
FILE: BuildWindowsRender.py
function print亮绿 (line 8) | def print亮绿(*kw,**kargs):
FILE: BuildWindowsServer.py
function print亮绿 (line 8) | def print亮绿(*kw,**kargs):
FILE: Please_Run_This_First_To_Fetch_Big_Files.py
function combine_file (line 11) | def combine_file(model_dir, output_file_path, num_parts):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/alg_base.py
class AlgorithmBase (line 6) | class AlgorithmBase():
method __init__ (line 7) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method interact_with_env (line 17) | def interact_with_env(self, team_intel):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/attention.py
class MultiHeadAttention (line 9) | class MultiHeadAttention(nn.Module):
method __init__ (line 11) | def __init__(
method init_parameters (line 44) | def init_parameters(self):
method forward (line 49) | def forward(self, q, k=None, v=None, mask=None, return_attn=False, ret...
method forward_ (line 79) | def forward_(self, q, k=None, v=None, mask=None, return_attn=False, re...
class SimpleAttention (line 149) | class SimpleAttention(nn.Module):
method __init__ (line 150) | def __init__(self, h_dim):
method init_parameters (line 157) | def init_parameters(self):
method forward (line 162) | def forward(self, k, q, v, mask=None):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/conc.py
class Concentration (line 7) | class Concentration(nn.Module):
method __init__ (line 8) | def __init__(self, n_focus_on, h_dim, skip_connect=False, skip_connect...
method init_parameters (line 23) | def init_parameters(self):
method forward (line 28) | def forward(self, vs, ve, ve_dead, skip_connect_ze=None, skip_connect_...
class ConcentrationHete (line 66) | class ConcentrationHete(nn.Module):
method __init__ (line 67) | def __init__(self, n_focus_on, h_dim, skip_connect=False, skip_connect...
method init_parameters (line 82) | def init_parameters(self):
method forward (line 87) | def forward(self, vs, ve, ve_dead, skip_connect_ze=None, skip_connect_...
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/dl_pool.py
class DeepLearningPool (line 9) | class DeepLearningPool(object):
method __init__ (line 10) | def __init__(self, pool_size, batch_size) -> None:
method add_and_sample (line 19) | def add_and_sample(self, x, y):
method _get_storage_idx (line 33) | def _get_storage_idx(self, inc=None):
method _sample (line 52) | def _sample(self):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/hyper_net.py
class HyperNet (line 7) | class HyperNet(nn.Module):
method __init__ (line 8) | def __init__(self, **kwargs):
method forward (line 31) | def forward(self, x, hyper_x):
class MyHyperNet (line 56) | class MyHyperNet(nn.Module):
method __init__ (line 57) | def __init__(self, x_in_dim, hyber_in_dim, layer_out_dims, hyber_hid_d...
method forward (line 79) | def forward(self, x, hyper_x):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/logit2act.py
class Logit2Act (line 13) | class Logit2Act(nn.Module):
method __init__ (line 14) | def __init__(self, *args, **kwargs):
method _logit2act_rsn (line 17) | def _logit2act_rsn(self, logits_agent_cluster, eval_mode, greedy, eval...
method _logit2act (line 29) | def _logit2act(self, logits_agent_cluster, eval_mode, greedy, eval_act...
method _get_act_log_probs (line 40) | def _get_act_log_probs(distribution, action):
method act (line 45) | def act(self, *args, **kargs):
method evaluate_actions (line 49) | def evaluate_actions(self, *args, **kargs):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/mlp.py
class SimpleMLP (line 6) | class SimpleMLP(nn.Module):
method __init__ (line 7) | def __init__(self, in_dim, out_dim, hidden_dim=128, use_normalization=...
method forward (line 25) | def forward(self,x):
class ResLinear (line 28) | class ResLinear(nn.Module):
method __init__ (line 29) | def __init__(self, io_dim, h_dim, need_input_tf=False, input_tf_dim=No...
method forward (line 38) | def forward(self, xo):
class LinearFinal (line 46) | class LinearFinal(nn.Module):
method __init__ (line 53) | def __init__(self, in_features: int, out_features: int, bias: bool = T...
method forward (line 63) | def forward(self, input: torch.Tensor) -> torch.Tensor:
method extra_repr (line 66) | def extra_repr(self) -> str:
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/net_manifest.py
function weights_init (line 3) | def weights_init(m):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/norm.py
class DynamicNorm (line 16) | class DynamicNorm(nn.Module):
method __init__ (line 18) | def __init__(self, input_size, only_for_last_dim, exclude_one_hot=True...
method forward (line 31) | def forward(self, x, get_mu_var=False):
class DynamicNormFix (line 74) | class DynamicNormFix(nn.Module):
method __init__ (line 76) | def __init__(self, input_size, only_for_last_dim, exclude_one_hot=True...
method np_forward (line 102) | def np_forward(self, x, freeze=False, get_mu_var=False):
method forward (line 105) | def forward(self, x, freeze=False, get_mu_var=False):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/pca.py
function pca (line 3) | def pca(samples, target_dim):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/ppo_sampler.py
class TrajPoolSampler (line 14) | class TrajPoolSampler():
method __init__ (line 15) | def __init__(self, n_div, traj_pool, flag, req_dict, req_dict_rename, ...
method __len__ (line 68) | def __len__(self):
method reminder (line 71) | def reminder(self, n_sample):
method get_sampler (line 84) | def get_sampler(self):
method reset_and_get_iter (line 95) | def reset_and_get_iter(self):
method determine_max_n_sample (line 110) | def determine_max_n_sample(self):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/rl_alg_base.py
class RLAlgorithmBase (line 7) | class RLAlgorithmBase(AlgorithmBase):
method __init__ (line 8) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method interact_with_env (line 19) | def interact_with_env(self, team_intel):
method save_model (line 22) | def save_model(self, update_cnt, info=None):
method process_framedata (line 25) | def process_framedata(self, traj_framedata):
method process_framedata (line 30) | def process_framedata(self, traj_framedata):
method check_reward_type (line 55) | def check_reward_type(self, AlgorithmConfig):
method mask_paused_env (line 65) | def mask_paused_env(self, frag):
method on_notify (line 78) | def on_notify(self, message, **kargs):
method commit_traj_frag (line 90) | def commit_traj_frag(self, unfi_frag, req_hook=True):
method traj_waiting_hook (line 104) | def traj_waiting_hook(self, new_frag):
method _no_hook (line 120) | def _no_hook(self, new_frag):
method _check_data_hash (line 126) | def _check_data_hash(self):
method _check_data_curruption (line 142) | def _check_data_curruption(self):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/traj.py
class TRAJ_BASE (line 6) | class TRAJ_BASE():
method __init__ (line 11) | def __init__(self, traj_limit, env_id):
method remember (line 21) | def remember(self, key, content):
method copy_track (line 34) | def copy_track(self, origin_key, new_key):
method check_type_shape (line 50) | def check_type_shape(self, key, first_content=None):
method init_track (line 64) | def init_track(self, key, first_content):
method init_track_none (line 76) | def init_track_none(self, key):
method time_shift (line 85) | def time_shift(self):
method cut_tail (line 90) | def cut_tail(self):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/common/traj_gae.py
class trajectory (line 8) | class trajectory(TRAJ_BASE):
method __init__ (line 10) | def __init__(self, traj_limit, env_id, alg_cfg):
method early_finalize (line 15) | def early_finalize(self):
method set_terminal_obs (line 19) | def set_terminal_obs(self, tobs):
method cut_tail (line 22) | def cut_tail(self):
method reward_push_forward (line 54) | def reward_push_forward(self, dead_mask):
method finalize (line 72) | def finalize(self):
method gae_finalize_return (line 107) | def gae_finalize_return(self, reward_key, value_key, new_return_name):
method gae_finalize_return_pr (line 135) | def gae_finalize_return_pr(self, reward_key, value_key, new_return_name):
class TrajManagerBase (line 187) | class TrajManagerBase(object):
method __init__ (line 188) | def __init__(self, n_env, traj_limit, alg_cfg):
method __check_integraty (line 201) | def __check_integraty(self, traj_frag):
method batch_update (line 211) | def batch_update(self, traj_frag):
method traj_remember (line 239) | def traj_remember(self, traj, key, content, frag_index, n_active):
class BatchTrajManager (line 249) | class BatchTrajManager(TrajManagerBase):
method __init__ (line 250) | def __init__(self, n_env, traj_limit, trainer_hook, alg_cfg):
method feed_traj (line 256) | def feed_traj(self, traj_frag, require_hook=False):
method train_and_clear_traj_pool (line 264) | def train_and_clear_traj_pool(self):
method can_exec_training (line 275) | def can_exec_training(self):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/example_foundation.py
class ExampleFoundation (line 6) | class ExampleFoundation():
method __init__ (line 7) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method interact_with_env (line 12) | def interact_with_env(self, team_intel):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/ccategorical.py
function random_process (line 9) | def random_process(probs, rsn_flag):
function random_process_allow_big_yita (line 32) | def random_process_allow_big_yita(probs, rsn_flag):
function random_process_with_clamp3 (line 60) | def random_process_with_clamp3(probs, yita, yita_min_prob, rsn_flag):
class CCategorical (line 84) | class CCategorical():
method __init__ (line 85) | def __init__(self, planner):
method sample (line 90) | def sample(self, dist, eprsn):
method register_rsn (line 94) | def register_rsn(self, rsn_flag):
method feed_logits (line 97) | def feed_logits(self, logits):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/div_tree.py
class DivTree (line 9) | class DivTree(nn.Module): # merge by MLP version
method __init__ (line 10) | def __init__(self, input_dim, h_dim, n_action):
method set_to_init_level (line 36) | def set_to_init_level(self, auto_transfer=True):
method change_div_tree_level (line 43) | def change_div_tree_level(self, level, auto_transfer=True):
method forward (line 64) | def forward(self, x_in, agent_ids): # x0: shape = (?,...,?, n_agent, ...
function _2div (line 112) | def _2div(arr):
function get_division_tree (line 142) | def get_division_tree(n_agents):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/foundation.py
class AlgorithmConfig (line 7) | class AlgorithmConfig:
function str_array_to_num (line 72) | def str_array_to_num(str_arr):
function itemgetter (line 81) | def itemgetter(*items):
class CPU_Unpickler (line 85) | class CPU_Unpickler(pickle.Unpickler):
method find_class (line 86) | def find_class(self, module, name):
class ReinforceAlgorithmFoundation (line 91) | class ReinforceAlgorithmFoundation(RLAlgorithmBase):
method __init__ (line 92) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method action_making (line 157) | def action_making(self, StateRecall, test_mode):
method matrix_callback_special (line 216) | def matrix_callback_special(self, framefrag):
method matrix_callback_special_callback (line 221) | def matrix_callback_special_callback(self, new_frag):
method interact_with_env (line 244) | def interact_with_env(self, StateRecall):
method interact_with_env_genuine (line 252) | def interact_with_env_genuine(self, StateRecall):
method train (line 260) | def train(self):
method on_notify (line 277) | def on_notify(self, message, **kargs):
method save_model (line 315) | def save_model(self, update_cnt, info=None):
method find_ckp (line 344) | def find_ckp(self, feature):
method load_model (line 354) | def load_model(self, AlgorithmConfig):
method process_framedata (line 386) | def process_framedata(self, traj_framedata):
method mask_paused_env (line 410) | def mask_paused_env(self, frag):
method _create_config_fly (line 420) | def _create_config_fly(self):
method _config_on_fly (line 426) | def _config_on_fly(self):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/hete_assignment.py
function random_group (line 8) | def random_group(random_select_fn, n_thread, hete_type, n_hete_types, n_...
function select_nets_for_shellenv (line 28) | def select_nets_for_shellenv(n_types, policy, hete_type_list, n_thread, ...
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/hete_net.py
function popgetter (line 13) | def popgetter(*items):
class no_context (line 17) | class no_context():
method __enter__ (line 18) | def __enter__(self):
method __exit__ (line 20) | def __exit__(self, exc_type, exc_value, traceback):
function _count_list_type (line 23) | def _count_list_type(x):
function _create_tensor_ph_or_fill_ (line 31) | def _create_tensor_ph_or_fill_(ref, pt, offset, *args):
function _tensor_expand_thread_dim_v2_ (line 37) | def _tensor_expand_thread_dim_v2_(ref, pt, offset, *args):
function dfs_create_and_fn (line 45) | def dfs_create_and_fn(ref, pt, offset, fn, *args):
function _deal_single_in (line 73) | def _deal_single_in(x, mask_flatten):
function distribute_compute (line 81) | def distribute_compute(fn_arr, mask_arr, **kwargs):
class HeteNet (line 125) | class HeteNet(nn.Module):
method __init__ (line 126) | def __init__(self, rawob_dim, n_action, hete_type, **kwargs):
method lock_net (line 187) | def lock_net(self, i):
method unlock_net (line 192) | def unlock_net(self, i):
method register_ckp (line 197) | def register_ckp(self, win_rate, cpk_path, mean_reward):
method random_select (line 249) | def random_select(self, testing, *args, **kwargs):
method random_select_matrix_test (line 275) | def random_select_matrix_test(self, testing, *args, **kwargs):
method on_update (line 308) | def on_update(self, update_cnt):
method redirect_to_frontend (line 311) | def redirect_to_frontend(self, i):
method acquire_net (line 314) | def acquire_net(self, i):
method exe (line 318) | def exe(self, hete_pick=None, **kargs):
method act (line 381) | def act(self, **kargs):
method evaluate_actions (line 385) | def evaluate_actions(self, **kargs):
method trim_ckp (line 388) | def trim_ckp(self):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/net.py
class Net (line 21) | class Net(nn.Module):
method __init__ (line 22) | def __init__(self, rawob_dim, n_action, **kwargs):
method act (line 57) | def act(self, *args, **kargs):
method evaluate_actions (line 60) | def evaluate_actions(self, *args, **kargs):
method _act (line 63) | def _act(self, obs=None, test_mode=None, eval_mode=False, eval_actions...
method _logit2act_rsn (line 109) | def _logit2act_rsn(self, logits_agent_cluster, eval_mode, greedy, eval...
method _logit2act (line 121) | def _logit2act(self, logits_agent_cluster, eval_mode, greedy, eval_act...
method _get_act_log_probs (line 132) | def _get_act_log_probs(distribution, action):
class NetCentralCritic (line 138) | class NetCentralCritic(nn.Module):
method __init__ (line 139) | def __init__(self, rawob_dim, n_action, **kwargs):
method estimate_state (line 179) | def estimate_state(self, obs=None, test_mode=None, eval_mode=False, ev...
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/ppo.py
class PPO (line 15) | class PPO():
method __init__ (line 16) | def __init__(self, policy_and_critic, ppo_config, mcv=None):
method freeze_body (line 62) | def freeze_body(self):
method train_on_traj (line 70) | def train_on_traj(self, traj_pool, task):
method log_reward_rich (line 88) | def log_reward_rich(self, traj_pool, mcv2):
method train_on_traj_ (line 109) | def train_on_traj_(self, traj_pool, task):
method freeze_body (line 148) | def freeze_body(self):
method log_trivial (line 156) | def log_trivial(self, dictionary):
method log_trivial_finalize (line 162) | def log_trivial_finalize(self, print=True):
method establish_pytorch_graph (line 177) | def establish_pytorch_graph(self, flag, sample, n):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/ppo_sampler.py
class TrajPoolSampler (line 12) | class TrajPoolSampler():
method __init__ (line 13) | def __init__(self, n_div, traj_pool, flag, prevent_batchsize_oom=False...
method __len__ (line 60) | def __len__(self):
method determine_max_n_sample (line 63) | def determine_max_n_sample(self):
method reset_and_get_iter (line 80) | def reset_and_get_iter(self):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/shell_env.py
class ShellEnvConfig (line 10) | class ShellEnvConfig:
class ActionConvertLegacy (line 14) | class ActionConvertLegacy():
method __init__ (line 15) | def __init__(self, SELF_TEAM_ASSUME, OPP_TEAM_ASSUME, OPP_NUM_ASSUME) ...
method convert_act_arr (line 36) | def convert_act_arr(self, type, a):
method get_tp_avail_act (line 49) | def get_tp_avail_act(self, type):
method confirm_parameters_are_correct (line 67) | def confirm_parameters_are_correct(self, team, agent_num, opp_agent_num):
function count_list_type (line 73) | def count_list_type(x):
class ShellEnvWrapper (line 82) | class ShellEnvWrapper(object):
method __init__ (line 83) | def __init__(self, n_agent, n_thread, space, mcv, rl_functional, alg_c...
method cold_start_warmup (line 128) | def cold_start_warmup(self, StateRecall):
method interact_with_env (line 138) | def interact_with_env(self, StateRecall):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/stage_planner.py
class PolicyRsnConfig (line 5) | class PolicyRsnConfig:
class StagePlanner (line 16) | class StagePlanner:
method __init__ (line 17) | def __init__(self, mcv) -> None:
method is_resonance_active (line 32) | def is_resonance_active(self,):
method is_body_freeze (line 35) | def is_body_freeze(self,):
method get_yita (line 38) | def get_yita(self):
method get_yita_min_prob (line 41) | def get_yita_min_prob(self):
method can_exec_trainning (line 44) | def can_exec_trainning(self):
method update_plan (line 52) | def update_plan(self):
method activate_pr (line 61) | def activate_pr(self):
method when_pr_inactive (line 67) | def when_pr_inactive(self):
method when_pr_active (line 79) | def when_pr_active(self):
method _update_yita (line 87) | def _update_yita(self):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/trajectory.py
class trajectory (line 11) | class trajectory(TRAJ_BASE):
method __init__ (line 13) | def __init__(self, traj_limit, env_id):
method early_finalize (line 17) | def early_finalize(self):
method set_terminal_obs (line 21) | def set_terminal_obs(self, tobs):
method cut_tail (line 24) | def cut_tail(self):
method reward_push_forward (line 57) | def reward_push_forward(self, dead_mask):
method finalize (line 75) | def finalize(self):
method gae_finalize_return (line 106) | def gae_finalize_return(self, reward_key, value_key, new_return_name):
class TrajPoolManager (line 146) | class TrajPoolManager(object):
method __init__ (line 147) | def __init__(self):
method absorb_finalize_pool (line 150) | def absorb_finalize_pool(self, pool):
class TrajManagerBase (line 175) | class TrajManagerBase(object):
method __init__ (line 176) | def __init__(self, n_env, traj_limit):
method __check_integraty (line 188) | def __check_integraty(self, traj_frag):
method batch_update (line 198) | def batch_update(self, traj_frag):
method traj_remember (line 226) | def traj_remember(self, traj, key, content, frag_index, n_active):
class BatchTrajManager (line 236) | class BatchTrajManager(TrajManagerBase):
method __init__ (line 237) | def __init__(self, n_env, traj_limit, trainer_hook):
method update (line 244) | def update(self, traj_frag, index):
method feed_traj_framedata (line 263) | def feed_traj_framedata(self, traj_frag, require_hook=False):
method clear_traj_pool (line 280) | def clear_traj_pool(self):
method train_and_clear_traj_pool (line 289) | def train_and_clear_traj_pool(self):
method can_exec_training (line 301) | def can_exec_training(self):
method unlock_fn (line 305) | def unlock_fn(self, traj_frag):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/my_ai/foundation.py
class AlgorithmConfig (line 6) | class AlgorithmConfig:
class ReinforceAlgorithmFoundation (line 11) | class ReinforceAlgorithmFoundation(object):
method __init__ (line 12) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method interact_with_env (line 18) | def interact_with_env(self, StateRecall):
class DiscreteRLFoundation (line 40) | class DiscreteRLFoundation(object):
method __init__ (line 41) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method interact_with_env (line 66) | def interact_with_env(self, StateRecall):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/ccategorical.py
function random_process (line 9) | def random_process(probs, rsn_flag):
function random_process_allow_big_yita (line 32) | def random_process_allow_big_yita(probs, rsn_flag):
function random_process_with_clamp3 (line 60) | def random_process_with_clamp3(probs, yita, yita_min_prob, rsn_flag):
class CCategorical (line 84) | class CCategorical():
method __init__ (line 85) | def __init__(self, planner):
method sample (line 90) | def sample(self, dist, eprsn):
method register_rsn (line 94) | def register_rsn(self, rsn_flag):
method feed_logits (line 97) | def feed_logits(self, logits):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/div_tree.py
class DivTree (line 9) | class DivTree(nn.Module): # merge by MLP version
method __init__ (line 10) | def __init__(self, input_dim, h_dim, n_action):
method set_to_init_level (line 36) | def set_to_init_level(self, auto_transfer=True):
method change_div_tree_level (line 43) | def change_div_tree_level(self, level, auto_transfer=True):
method forward (line 64) | def forward(self, x_in, agent_ids): # x0: shape = (?,...,?, n_agent, ...
function _2div (line 112) | def _2div(arr):
function get_division_tree (line 142) | def get_division_tree(n_agents):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/foundation.py
class AlgorithmConfig (line 7) | class AlgorithmConfig:
function str_array_to_num (line 61) | def str_array_to_num(str_arr):
function itemgetter (line 70) | def itemgetter(*items):
class ReinforceAlgorithmFoundation (line 75) | class ReinforceAlgorithmFoundation(RLAlgorithmBase):
method __init__ (line 76) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method action_making (line 120) | def action_making(self, StateRecall, test_mode):
method interact_with_env (line 162) | def interact_with_env(self, StateRecall):
method interact_with_env_genuine (line 170) | def interact_with_env_genuine(self, StateRecall):
method train (line 178) | def train(self):
method save_model (line 196) | def save_model(self, update_cnt, info=None):
method load_model (line 224) | def load_model(self, AlgorithmConfig):
method process_framedata (line 243) | def process_framedata(self, traj_framedata):
method mask_paused_env (line 267) | def mask_paused_env(self, frag):
method _create_config_fly (line 277) | def _create_config_fly(self):
method _config_on_fly (line 283) | def _config_on_fly(self):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/net.py
class Net (line 20) | class Net(nn.Module):
method __init__ (line 21) | def __init__(self, rawob_dim, n_action, **kwargs):
method act (line 64) | def act(self, *args, **kargs):
method evaluate_actions (line 68) | def evaluate_actions(self, *args, **kargs):
method _act (line 71) | def _act(self, obs=None, test_mode=None, eval_mode=False, eval_actions...
method _logit2act_rsn (line 110) | def _logit2act_rsn(self, logits_agent_cluster, eval_mode, test_mode, e...
method _logit2act (line 122) | def _logit2act(self, logits_agent_cluster, eval_mode, test_mode, eval_...
method _get_act_log_probs (line 133) | def _get_act_log_probs(distribution, action):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/ppo.py
class PPO (line 15) | class PPO():
method __init__ (line 16) | def __init__(self, policy_and_critic, ppo_config, mcv=None):
method train_on_traj (line 48) | def train_on_traj(self, traj_pool, task):
method train_on_traj_ (line 66) | def train_on_traj_(self, traj_pool, task):
method freeze_body (line 99) | def freeze_body(self):
method log_trivial (line 107) | def log_trivial(self, dictionary):
method log_trivial_finalize (line 113) | def log_trivial_finalize(self, print=True):
method establish_pytorch_graph (line 128) | def establish_pytorch_graph(self, flag, sample, n):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/ppo_sampler.py
class TrajPoolSampler (line 12) | class TrajPoolSampler():
method __init__ (line 13) | def __init__(self, n_div, traj_pool, flag, prevent_batchsize_oom=False...
method __len__ (line 60) | def __len__(self):
method determine_max_n_sample (line 63) | def determine_max_n_sample(self):
method reset_and_get_iter (line 80) | def reset_and_get_iter(self):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/shell_env.py
class ShellEnvConfig (line 10) | class ShellEnvConfig:
class ActionConvertPredatorPrey (line 13) | class ActionConvertPredatorPrey():
method __init__ (line 14) | def __init__(self, SELF_TEAM_ASSUME, OPP_TEAM_ASSUME, OPP_NUM_ASSUME) ...
method convert_act_arr (line 26) | def convert_act_arr(self, type, a):
method get_tp_avail_act (line 29) | def get_tp_avail_act(self, type):
method confirm_parameters_are_correct (line 36) | def confirm_parameters_are_correct(self, team, agent_num, opp_agent_num):
class ActionConvertLegacy (line 39) | class ActionConvertLegacy():
method __init__ (line 40) | def __init__(self, SELF_TEAM_ASSUME, OPP_TEAM_ASSUME, OPP_NUM_ASSUME) ...
method convert_act_arr (line 61) | def convert_act_arr(self, type, a):
method get_tp_avail_act (line 74) | def get_tp_avail_act(self, type):
method confirm_parameters_are_correct (line 92) | def confirm_parameters_are_correct(self, team, agent_num, opp_agent_num):
function count_list_type (line 98) | def count_list_type(x):
class ShellEnvWrapper (line 107) | class ShellEnvWrapper(object):
method __init__ (line 108) | def __init__(self, n_agent, n_thread, space, mcv, rl_functional, alg_c...
method interact_with_env (line 140) | def interact_with_env(self, StateRecall):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/stage_planner.py
class PolicyRsnConfig (line 5) | class PolicyRsnConfig:
class StagePlanner (line 16) | class StagePlanner:
method __init__ (line 17) | def __init__(self, mcv) -> None:
method is_resonance_active (line 28) | def is_resonance_active(self,):
method is_body_freeze (line 31) | def is_body_freeze(self,):
method get_yita (line 34) | def get_yita(self):
method get_yita_min_prob (line 37) | def get_yita_min_prob(self):
method can_exec_trainning (line 40) | def can_exec_trainning(self):
method update_plan (line 43) | def update_plan(self):
method activate_pr (line 52) | def activate_pr(self):
method when_pr_inactive (line 58) | def when_pr_inactive(self):
method when_pr_active (line 70) | def when_pr_active(self):
method _update_yita (line 78) | def _update_yita(self):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/trajectory.py
class trajectory (line 11) | class trajectory(TRAJ_BASE):
method __init__ (line 13) | def __init__(self, traj_limit, env_id):
method early_finalize (line 17) | def early_finalize(self):
method set_terminal_obs (line 21) | def set_terminal_obs(self, tobs):
method cut_tail (line 24) | def cut_tail(self):
method reward_push_forward (line 57) | def reward_push_forward(self, dead_mask):
method finalize (line 75) | def finalize(self):
method gae_finalize_return (line 106) | def gae_finalize_return(self, reward_key, value_key, new_return_name):
class TrajPoolManager (line 146) | class TrajPoolManager(object):
method __init__ (line 147) | def __init__(self):
method absorb_finalize_pool (line 150) | def absorb_finalize_pool(self, pool):
class TrajManagerBase (line 175) | class TrajManagerBase(object):
method __init__ (line 176) | def __init__(self, n_env, traj_limit):
method __check_integraty (line 188) | def __check_integraty(self, traj_frag):
method batch_update (line 198) | def batch_update(self, traj_frag):
method traj_remember (line 226) | def traj_remember(self, traj, key, content, frag_index, n_active):
class BatchTrajManager (line 236) | class BatchTrajManager(TrajManagerBase):
method __init__ (line 237) | def __init__(self, n_env, traj_limit, trainer_hook):
method update (line 244) | def update(self, traj_frag, index):
method feed_traj_framedata (line 263) | def feed_traj_framedata(self, traj_frag, require_hook=False):
method clear_traj_pool (line 280) | def clear_traj_pool(self):
method train_and_clear_traj_pool (line 289) | def train_and_clear_traj_pool(self):
method can_exec_training (line 301) | def can_exec_training(self):
method unlock_fn (line 305) | def unlock_fn(self, traj_frag):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/random/actionset.py
class ActionConvertV1Dummy (line 8) | class ActionConvertV1Dummy():
method __init__ (line 9) | def __init__(self, SELF_TEAM_ASSUME, OPP_TEAM_ASSUME, OPP_NUM_ASSUME) ...
method convert_act_arr (line 20) | def convert_act_arr(self, type, a):
method get_tp_avail_act (line 23) | def get_tp_avail_act(self, type):
method confirm_parameters_are_correct (line 41) | def confirm_parameters_are_correct(self, team, agent_num, opp_agent_num):
class ActionConvertV1Carrier (line 49) | class ActionConvertV1Carrier():
method __init__ (line 50) | def __init__(self, SELF_TEAM_ASSUME, OPP_TEAM_ASSUME, OPP_NUM_ASSUME) ...
method convert_act_arr (line 78) | def convert_act_arr(self, type, a):
method get_tp_avail_act (line 81) | def get_tp_avail_act(self, type):
method confirm_parameters_are_correct (line 99) | def confirm_parameters_are_correct(self, team, agent_num, opp_agent_num):
class ActionConvertV1Momentum (line 107) | class ActionConvertV1Momentum():
method __init__ (line 108) | def __init__(self, SELF_TEAM_ASSUME, OPP_TEAM_ASSUME, OPP_NUM_ASSUME) ...
method convert_act_arr (line 126) | def convert_act_arr(self, type, a):
method get_tp_avail_act (line 129) | def get_tp_avail_act(self, type):
method confirm_parameters_are_correct (line 136) | def confirm_parameters_are_correct(self, team, agent_num, opp_agent_num):
class ActionConvertMovingV4 (line 143) | class ActionConvertMovingV4():
method __init__ (line 144) | def __init__(self, SELF_TEAM_ASSUME, OPP_TEAM_ASSUME, OPP_NUM_ASSUME) ...
method convert_act_arr (line 158) | def convert_act_arr(self, type, a):
method get_tp_avail_act (line 161) | def get_tp_avail_act(self, type):
class CarrierAction (line 166) | class CarrierAction():
method __init__ (line 167) | def __init__(self, SELF_TEAM_ASSUME, OPP_TEAM_ASSUME, OPP_NUM_ASSUME) ...
method convert_act_arr (line 181) | def convert_act_arr(self, type, a):
method get_tp_avail_act (line 184) | def get_tp_avail_act(self, type):
class ActionConvertV2 (line 189) | class ActionConvertV2():
method __init__ (line 190) | def __init__(self, SELF_TEAM_ASSUME, OPP_TEAM_ASSUME, OPP_NUM_ASSUME) ...
method convert_act_arr (line 217) | def convert_act_arr(self, type, a):
method get_tp_avail_act (line 220) | def get_tp_avail_act(self, type):
method confirm_parameters_are_correct (line 238) | def confirm_parameters_are_correct(self, team, agent_num, opp_agent_num):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/random/foundation.py
class AlgorithmConfig (line 6) | class AlgorithmConfig:
class RandomController (line 16) | class RandomController(object):
method __init__ (line 17) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method interact_with_env (line 24) | def interact_with_env(self, StateRecall):
class DummyRandomControllerWithActionSetV1 (line 33) | class DummyRandomControllerWithActionSetV1(object):
method __init__ (line 35) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method interact_with_env (line 48) | def interact_with_env(self, StateRecall):
class RandomControllerWithActionSetV2 (line 63) | class RandomControllerWithActionSetV2(object):
method __init__ (line 65) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method interact_with_env (line 78) | def interact_with_env(self, StateRecall):
class RandomControllerWithActionSetV4 (line 93) | class RandomControllerWithActionSetV4(object):
method __init__ (line 95) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method interact_with_env (line 108) | def interact_with_env(self, StateRecall):
class RandomControllerWithActionSetV1 (line 124) | class RandomControllerWithActionSetV1(object):
method __init__ (line 126) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method interact_with_env (line 139) | def interact_with_env(self, StateRecall):
class RandomControllerWithMomentumAgent (line 154) | class RandomControllerWithMomentumAgent(object):
method __init__ (line 156) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method interact_with_env (line 169) | def interact_with_env(self, StateRecall):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/a_attackpost.py
class AlgorithmConfig (line 7) | class AlgorithmConfig:
class DummyAlgorithmBase (line 10) | class DummyAlgorithmBase():
method __init__ (line 11) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method forward (line 18) | def forward(self, inp, state, mask=None):
method to (line 21) | def to(self, device):
method interact_with_env (line 24) | def interact_with_env(self, State_Recall):
class AttackPostPreprogramBaseline (line 44) | class AttackPostPreprogramBaseline(DummyAlgorithmBase):
method interact_with_env (line 45) | def interact_with_env(self, State_Recall):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/a_escape.py
class AlgorithmConfig (line 7) | class AlgorithmConfig:
class DummyAlgorithmBase (line 10) | class DummyAlgorithmBase():
method __init__ (line 11) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method forward (line 18) | def forward(self, inp, state, mask=None):
method to (line 21) | def to(self, device):
method interact_with_env (line 24) | def interact_with_env(self, State_Recall):
class EscapeGreenPreprogramBaseline (line 44) | class EscapeGreenPreprogramBaseline(DummyAlgorithmBase):
method interact_with_env (line 45) | def interact_with_env(self, State_Recall):
class EscapeRedPreprogramBaseline (line 77) | class EscapeRedPreprogramBaseline(DummyAlgorithmBase):
method interact_with_env (line 78) | def interact_with_env(self, State_Recall):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/a_test_reproduce.py
class AlgorithmConfig (line 7) | class AlgorithmConfig:
class DummyAlgorithmBase (line 10) | class DummyAlgorithmBase():
method __init__ (line 11) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method forward (line 18) | def forward(self, inp, state, mask=None):
method to (line 21) | def to(self, device):
method interact_with_env (line 24) | def interact_with_env(self, State_Recall):
class TestReproduce (line 57) | class TestReproduce(DummyAlgorithmBase):
method __init__ (line 58) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method interact_with_env (line 61) | def interact_with_env(self, State_Recall):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/assignment.py
class TaskAssign (line 10) | class TaskAssign(object):
method __init__ (line 12) | def __init__(self, attackers, drone, defenders):
method assign_attack (line 24) | def assign_attack(self, attack_IDlist):
method assign_drone_ini (line 65) | def assign_drone_ini(self, ):
method judge_expeled (line 99) | def judge_expeled(self, ):
method expel (line 191) | def expel(self, ):
method assign_defend (line 202) | def assign_defend(self, def_ID):
method is_retreat (line 241) | def is_retreat(self, att_ID, def_ID):
method is_attack (line 263) | def is_attack(self, att_ID):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/blue_strategy.py
function offense_combat (line 5) | def offense_combat(self_data, ally_agents_data, enemy_agents_data, key_p...
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/decision.py
class decision (line 11) | class decision():
method __init__ (line 13) | def __init__(self, attackers, drone, defenders):
method act (line 23) | def act(self, type=None):
method attack_StateTrans (line 129) | def attack_StateTrans(self, ):
method drone_StateTrans (line 184) | def drone_StateTrans(self, ):
method defend_StateTrans (line 211) | def defend_StateTrans(self, ):
function test (line 254) | def test():
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/dummy.py
class DummyAlgConfig (line 4) | class DummyAlgConfig():
class DummyAlgorithmBase (line 7) | class DummyAlgorithmBase():
method __init__ (line 8) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method forward (line 14) | def forward(self, inp, state, mask=None):
method to (line 17) | def to(self, device):
method interact_with_env (line 20) | def interact_with_env(self, State_Recall):
class DummyAlgorithm (line 42) | class DummyAlgorithm(DummyAlgorithmBase):
method interact_with_env (line 43) | def interact_with_env(self, State_Recall):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/dummy_uhmap.py
class DummyAlgConfig (line 16) | class DummyAlgConfig():
class DummyAlgorithmBase (line 20) | class DummyAlgorithmBase():
method __init__ (line 21) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method forward (line 27) | def forward(self, inp, state, mask=None):
method to (line 30) | def to(self, device):
method interact_with_env (line 33) | def interact_with_env(self, State_Recall):
class DummyAlgorithmT1 (line 56) | class DummyAlgorithmT1(DummyAlgorithmBase):
method interact_with_env (line 57) | def interact_with_env(self, State_Recall):
method interact_with_env_ (line 68) | def interact_with_env_(self, State_Recall):
class DummyAlgorithmT2 (line 212) | class DummyAlgorithmT2(DummyAlgorithmBase):
method interact_with_env (line 213) | def interact_with_env(self, State_Recall):
method interact_with_env_ (line 224) | def interact_with_env_(self, State_Recall):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/manual.py
function to_cpu_numpy (line 9) | def to_cpu_numpy(x):
class CoopAlgConfig (line 12) | class CoopAlgConfig():
class DummyAlgorithmFoundationHI3D (line 15) | class DummyAlgorithmFoundationHI3D():
method __init__ (line 16) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method forward (line 36) | def forward(self, inp, state, mask=None):
method to (line 39) | def to(self, device):
method get_previous (line 42) | def get_previous(self, team_intel):
method interact_with_env (line 47) | def interact_with_env(self, State_Recall):
method get_action (line 82) | def get_action(self, action, attack_target, invader_pos, invader_vel, ...
method dir_to_action3d (line 94) | def dir_to_action3d(vec, vel):
method set_nearest_target (line 104) | def set_nearest_target(self, Env_Suffered_Reset, invader_pos, landmark...
class DummyAlgorithmFoundationHI3D_old (line 115) | class DummyAlgorithmFoundationHI3D_old():
method __init__ (line 116) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method forward (line 136) | def forward(self, inp, state, mask=None):
method to (line 139) | def to(self, device):
method get_previous (line 142) | def get_previous(self, team_intel):
method interact_with_env (line 147) | def interact_with_env(self, State_Recall):
method get_action (line 182) | def get_action(self, action, attack_target, invader_pos, invader_vel, ...
method dir_to_action3d (line 194) | def dir_to_action3d(vec, vel):
method set_random_target (line 250) | def set_random_target(self, Env_Suffered_Reset):
class IHDummyAlgorithmFoundation (line 260) | class IHDummyAlgorithmFoundation():
method __init__ (line 261) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method forward (line 277) | def forward(self, inp, state, mask=None):
method to (line 280) | def to(self, device):
method get_previous (line 283) | def get_previous(self, team_intel):
method interact_with_env (line 307) | def interact_with_env(self, State_Recall):
method get_action (line 337) | def get_action(action, attack_target, invader_pos, invader_vel, landma...
method set_random_target (line 387) | def set_random_target(self, step_env_cnt_cnt):
class DummyAlgorithmFoundation (line 399) | class DummyAlgorithmFoundation():
method __init__ (line 400) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method interact_with_env (line 419) | def interact_with_env(self, team_intel):
method get_previous (line 458) | def get_previous(self, team_intel):
method dir_to_action (line 466) | def dir_to_action(vec, vel):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/module_evaluation.py
class Evaluation_module (line 11) | class Evaluation_module():
method __init__ (line 12) | def __init__(self, critical_points=[[-3000, 700, 0], [700, -3300, 0]]):
method SigmoidTen (line 26) | def SigmoidTen(self, x, c):
method SigmoidNine (line 31) | def SigmoidNine(self, x, c):
method UAV2Point (line 37) | def UAV2Point(self, p_position, position, velocity, phi, psi, ammo, he...
method UAV2UAV (line 65) | def UAV2UAV(self, identity, a_position,a_ammo,a_health, position,veloc...
method Drone2Point (line 99) | def Drone2Point(self, p_position,p_ts, position, velocity):
method UAV2Point_id (line 117) | def UAV2Point_id(self, attacker_dict, key_point):
method UAV2UAV_id (line 157) | def UAV2UAV_id(self, identity, attacker_dict, defender_dict):
method Drone2Point_id (line 216) | def Drone2Point_id(self, drone_data, key_point):
method defend_to_attack (line 242) | def defend_to_attack(self, self_data, ally_agents_data, enemy_agents_d...
method attack_to_defend (line 298) | def attack_to_defend(self, self_data, ally_agents_data, enemy_agents_d...
method uav_to_defend (line 354) | def uav_to_defend(self, self_data, ally_agents_data, enemy_agents_data...
method evaluate (line 431) | def evaluate(self, self_data, ally_agents_data, enemy_agents_data, key...
function test (line 440) | def test():
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/red_strategy.py
function defense_combat (line 6) | def defense_combat(self_data, ally_agents_data, enemy_agents_data, key_p...
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/stance.py
class Evaluation_module (line 11) | class Evaluation_module():
method __init__ (line 12) | def __init__(self, critical_points=[[-3, -0.7, 0], [0.7, 3.3, 0]]):
method SigmoidTen (line 26) | def SigmoidTen(self, x, c):
method SigmoidNine (line 31) | def SigmoidNine(self, x, c):
method UAV2Point (line 37) | def UAV2Point(self, p_position, position, velocity, phi, psi, ammo, he...
method UAV2UAV (line 65) | def UAV2UAV(self, identity, a_position,a_ammo,a_health, position,veloc...
method Drone2Point (line 99) | def Drone2Point(self, p_position,p_ts, position, velocity):
method UAV2Point_id (line 117) | def UAV2Point_id(self, attacker_dict, key_point):
method UAV2UAV_id (line 155) | def UAV2UAV_id(self, identity, attacker_dict, defender_dict):
method Drone2Point_id (line 207) | def Drone2Point_id(self, drone_data, key_point):
method defend_to_attack (line 234) | def defend_to_attack(self, self_data, ally_agents_data, enemy_agents_d...
method attack_to_defend (line 290) | def attack_to_defend(self, self_data, ally_agents_data, enemy_agents_d...
method uav_to_defend (line 346) | def uav_to_defend(self, self_data, ally_agents_data, enemy_agents_data...
method evaluate (line 423) | def evaluate(self, self_data, ally_agents_data, enemy_agents_data, key...
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/uhmap_bb.py
class DummyAlgConfig (line 7) | class DummyAlgConfig():
class DummyAlgorithmBase (line 10) | class DummyAlgorithmBase():
method __init__ (line 11) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method forward (line 17) | def forward(self, inp, state, mask=None):
method to (line 20) | def to(self, device):
method interact_with_env (line 23) | def interact_with_env(self, State_Recall):
class DummyAlgorithmT2 (line 44) | class DummyAlgorithmT2(DummyAlgorithmBase):
method interact_with_env (line 45) | def interact_with_env(self, State_Recall):
class DummyAlgorithmT1 (line 105) | class DummyAlgorithmT1(DummyAlgorithmBase):
method interact_with_env (line 106) | def interact_with_env(self, State_Recall):
class DummyAlgorithmIdle (line 142) | class DummyAlgorithmIdle(DummyAlgorithmBase):
method interact_with_env (line 143) | def interact_with_env(self, State_Recall):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/uhmap_island.py
class DummyAlgConfig (line 8) | class DummyAlgConfig():
class DummyAlgorithmBase (line 11) | class DummyAlgorithmBase():
method __init__ (line 12) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method forward (line 25) | def forward(self, inp, state, mask=None):
method to (line 28) | def to(self, device):
method interact_with_env (line 31) | def interact_with_env(self, State_Recall):
class DummyAlgorithmIdle (line 54) | class DummyAlgorithmIdle(DummyAlgorithmBase):
method interact_with_env (line 63) | def interact_with_env(self, State_Recall):
method DeltaLocation2Angle (line 268) | def DeltaLocation2Angle(self, delta_x, delta_y):
method TargetAngle2Action (line 291) | def TargetAngle2Action(self, target_yaw):
method TargetHeight2Action (line 311) | def TargetHeight2Action(self, target_height):
class ActionDictionary (line 330) | class ActionDictionary():
method select_act (line 364) | def select_act(type, a):
method get_avail_act (line 370) | def get_avail_act():
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/uhmap_ls.py
class DummyAlgConfig (line 8) | class DummyAlgConfig():
class DummyAlgorithmBase (line 11) | class DummyAlgorithmBase():
method __init__ (line 12) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method forward (line 20) | def forward(self, inp, state, mask=None):
method to (line 23) | def to(self, device):
method interact_with_env (line 26) | def interact_with_env(self, State_Recall):
class DummyAlgorithmSeqFire (line 48) | class DummyAlgorithmSeqFire(DummyAlgorithmBase):
method interact_with_env (line 49) | def interact_with_env(self, State_Recall):
class DummyAlgorithmIdle (line 101) | class DummyAlgorithmIdle(DummyAlgorithmBase):
method interact_with_env (line 102) | def interact_with_env(self, State_Recall):
class DummyAlgorithmMarch (line 137) | class DummyAlgorithmMarch(DummyAlgorithmBase):
method interact_with_env (line 138) | def interact_with_env(self, State_Recall):
function assign_opponent (line 189) | def assign_opponent(opp_pos_arr, opp_id_arr, leader_pos_arr, leader_id_a...
class DummyAlgorithmLinedAttack (line 199) | class DummyAlgorithmLinedAttack(DummyAlgorithmBase):
method interact_with_env (line 200) | def interact_with_env(self, State_Recall):
method uid_alive (line 230) | def uid_alive(raw_info, uid):
method decide_each_thread (line 233) | def decide_each_thread(self, **kwargs):
function vector_shift_towards (line 302) | def vector_shift_towards(pos, toward_pos, offset):
FILE: PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/uhmap_ls_mp.py
class DummyAlgConfig (line 8) | class DummyAlgConfig():
class DummyAlgorithmBase (line 11) | class DummyAlgorithmBase():
method __init__ (line 12) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method forward (line 20) | def forward(self, inp, state, mask=None):
method to (line 23) | def to(self, device):
method interact_with_env (line 26) | def interact_with_env(self, State_Recall):
class DummyAlgorithmSeqFire (line 48) | class DummyAlgorithmSeqFire(DummyAlgorithmBase):
method interact_with_env (line 49) | def interact_with_env(self, State_Recall):
class DummyAlgorithmIdle (line 101) | class DummyAlgorithmIdle(DummyAlgorithmBase):
method interact_with_env (line 102) | def interact_with_env(self, State_Recall):
class DummyAlgorithmMarch (line 137) | class DummyAlgorithmMarch(DummyAlgorithmBase):
method interact_with_env (line 138) | def interact_with_env(self, State_Recall):
function assign_opponent (line 189) | def assign_opponent(opp_pos_arr, opp_id_arr, leader_pos_arr, leader_id_a...
class ThreadDecisionMaker (line 202) | class ThreadDecisionMaker():
method apply_context (line 204) | def apply_context(self, kwargs):
method decide_each_thread (line 208) | def decide_each_thread(self, kwargs):
class DummyAlgorithmLinedAttack (line 280) | class DummyAlgorithmLinedAttack(DummyAlgorithmBase):
method __init__ (line 281) | def __init__(self, n_agent, n_thread, space, mcv=None, team=None):
method interact_with_env (line 296) | def interact_with_env(self, State_Recall):
method uid_alive (line 330) | def uid_alive(raw_info, uid):
function vector_shift_towards (line 335) | def vector_shift_towards(pos, toward_pos, offset):
FILE: PythonExample/hmp_minimal_modules/MISSION/common/base_env.py
class BaseEnv (line 2) | class BaseEnv(object):
method __init__ (line 3) | def __init__(self, rank) -> None:
method step (line 8) | def step(self, act):
method reset (line 23) | def reset(self):
class RawObsArray (line 30) | class RawObsArray(object):
method __init__ (line 32) | def __init__(self, key='default'):
method append (line 42) | def append(self, buf):
method get (line 50) | def get(self):
method get_group_size (line 56) | def get_group_size(self):
method get_raw_obs_size (line 59) | def get_raw_obs_size(self):
FILE: PythonExample/hmp_minimal_modules/MISSION/env_router.py
function load_ScenarioConfig (line 42) | def load_ScenarioConfig():
function make_env_function (line 49) | def make_env_function(env_name, rank):
function make_parallel_envs (line 66) | def make_parallel_envs(process_pool, marker=''):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/SubtaskCommonFn.py
class UhmapCommonFn (line 14) | class UhmapCommonFn(UhmapEnv):
method reset (line 16) | def reset(self):
method step (line 64) | def step(self, act):
method parse_event (line 106) | def parse_event(self, event):
method extract_key_gameobj (line 117) | def extract_key_gameobj(self, resp):
method gen_reward_and_win (line 124) | def gen_reward_and_win(self, resp):
method step_skip (line 165) | def step_skip(self):
method find_agent_by_uid (line 174) | def find_agent_by_uid(self, uid):
method parse_response_ob_info (line 187) | def parse_response_ob_info(self, resp):
method item_random_mv (line 234) | def item_random_mv(src,dst,prob,rand=False):
method get_binary_array (line 245) | def get_binary_array(n_int, n_bits=8, dtype=np.float32):
method make_obs (line 255) | def make_obs(self, resp=None, get_shape=False):
method init_ship (line 423) | def init_ship(self, agent_info, pos_ro):
method init_waterdrop (line 461) | def init_waterdrop(self, agent_info, pos_ro):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapAdversial.py
class UhmapAdversial (line 16) | class UhmapAdversial(UhmapCommonFn, UhmapEnv):
method __init__ (line 17) | def __init__(self, rank) -> None:
method extract_key_gameobj (line 26) | def extract_key_gameobj(self, resp):
method gen_reward_and_win (line 31) | def gen_reward_and_win(self, resp):
method item_random_mv (line 79) | def item_random_mv(src,dst,prob,rand=False):
method get_binary_array (line 90) | def get_binary_array(n_int, n_bits=8, dtype=np.float32):
method make_obs (line 100) | def make_obs(self, resp=None, get_shape=False):
method init_ground (line 278) | def init_ground(self, agent_info, pos_ro):
method init_ground_tank (line 331) | def init_ground_tank(self, agent_info, pos_ro):
method init_air (line 384) | def init_air(self, agent_info, pos_ro):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapAdversialConf.py
class SubTaskConfig (line 2) | class SubTaskConfig():
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapAttackPost.py
function init_position_helper (line 11) | def init_position_helper(x_max, x_min, y_max, y_min, total, this):
class UhmapAttackPost (line 23) | class UhmapAttackPost(UhmapEnv):
method __init__ (line 24) | def __init__(self, rank) -> None:
method reset (line 32) | def reset(self):
method step (line 79) | def step(self, act):
method parse_event (line 121) | def parse_event(self, event):
method extract_key_gameobj (line 132) | def extract_key_gameobj(self, resp):
method gen_reward_and_win (line 139) | def gen_reward_and_win(self, resp):
method step_skip (line 180) | def step_skip(self):
method find_agent_by_uid (line 189) | def find_agent_by_uid(self, uid):
method parse_response_ob_info (line 202) | def parse_response_ob_info(self, resp):
method item_random_mv (line 249) | def item_random_mv(src,dst,prob,rand=False):
method get_binary_array (line 260) | def get_binary_array(n_int, n_bits=8, dtype=np.float32):
method make_obs (line 270) | def make_obs(self, resp=None, get_shape=False):
method init_defence (line 437) | def init_defence(self, agent_info, pos_ro):
method init_attack (line 475) | def init_attack(self, agent_info, pos_ro):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapAttackPostConf.py
class SubTaskConfig (line 2) | class SubTaskConfig():
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapBreakingBad.py
class SubTaskConfig (line 10) | class SubTaskConfig():
class UhmapBreakingBad (line 13) | class UhmapBreakingBad(UhmapEnv):
method __init__ (line 14) | def __init__(self, rank) -> None:
method reset (line 21) | def reset(self):
method step (line 116) | def step(self, act):
method parse_event (line 152) | def parse_event(self, event):
method extract_key_gameobj (line 156) | def extract_key_gameobj(self, resp):
method gen_reward_and_win (line 161) | def gen_reward_and_win(self, resp):
method step_skip (line 212) | def step_skip(self):
method find_agent_by_uid (line 219) | def find_agent_by_uid(self, uid):
method parse_response_ob_info (line 229) | def parse_response_ob_info(self, resp):
method item_random_mv (line 248) | def item_random_mv(src,dst,prob,rand=False):
method get_binary_array (line 259) | def get_binary_array(n_int, n_bits=8, dtype=np.float32):
method make_obs (line 270) | def make_obs(self, resp=None, get_shape=False):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapBreakingBadConf.py
class SubTaskConfig (line 2) | class SubTaskConfig():
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapCarrier.py
class UhmapCarrier (line 16) | class UhmapCarrier(UhmapCommonFn, UhmapEnv):
method __init__ (line 17) | def __init__(self, rank) -> None:
method extract_key_gameobj (line 26) | def extract_key_gameobj(self, resp):
method gen_reward_and_win (line 31) | def gen_reward_and_win(self, resp):
method item_random_mv (line 79) | def item_random_mv(src,dst,prob,rand=False):
method get_binary_array (line 90) | def get_binary_array(n_int, n_bits=8, dtype=np.float32):
method make_obs (line 100) | def make_obs(self, resp=None, get_shape=False):
method init_drone (line 277) | def init_drone(self, agent_info, pos_ro):
method init_carrier (line 331) | def init_carrier(self, agent_info, pos_ro):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapCarrierConf.py
class SubTaskConfig (line 2) | class SubTaskConfig():
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapEscape.py
function init_position_helper (line 11) | def init_position_helper(x_max, x_min, y_max, y_min, total, this):
class UhmapEscape (line 23) | class UhmapEscape(UhmapEnv):
method __init__ (line 24) | def __init__(self, rank) -> None:
method reset (line 32) | def reset(self):
method step (line 79) | def step(self, act):
method parse_event (line 121) | def parse_event(self, event):
method extract_key_gameobj (line 132) | def extract_key_gameobj(self, resp):
method gen_reward_and_win (line 139) | def gen_reward_and_win(self, resp):
method step_skip (line 183) | def step_skip(self):
method find_agent_by_uid (line 192) | def find_agent_by_uid(self, uid):
method parse_response_ob_info (line 205) | def parse_response_ob_info(self, resp):
method item_random_mv (line 252) | def item_random_mv(src,dst,prob,rand=False):
method get_binary_array (line 263) | def get_binary_array(n_int, n_bits=8, dtype=np.float32):
method make_obs (line 273) | def make_obs(self, resp=None, get_shape=False):
method init_defence (line 437) | def init_defence(self, agent_info, pos_ro):
method init_attack (line 483) | def init_attack(self, agent_info, pos_ro):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapEscapeConf.py
class SubTaskConfig (line 2) | class SubTaskConfig():
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapFormation.py
class UhmapFormation (line 15) | class UhmapFormation(UhmapCommonFn, UhmapEnv):
method __init__ (line 16) | def __init__(self, rank) -> None:
method extract_key_gameobj (line 25) | def extract_key_gameobj(self, resp):
method gen_reward_and_win (line 30) | def gen_reward_and_win(self, resp):
method item_random_mv (line 78) | def item_random_mv(src,dst,prob,rand=False):
method get_binary_array (line 89) | def get_binary_array(n_int, n_bits=8, dtype=np.float32):
method make_obs (line 98) | def make_obs(self, resp=None, get_shape=False):
method init_drone (line 275) | def init_drone(self, agent_info, pos_ro):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapFormationConf.py
class SubTaskConfig (line 2) | class SubTaskConfig():
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapHuge.py
class UhmapHuge (line 16) | class UhmapHuge(UhmapCommonFn, UhmapEnv):
method __init__ (line 17) | def __init__(self, rank) -> None:
method extract_key_gameobj (line 26) | def extract_key_gameobj(self, resp):
method gen_reward_and_win (line 31) | def gen_reward_and_win(self, resp):
method item_random_mv (line 79) | def item_random_mv(src,dst,prob,rand=False):
method get_binary_array (line 90) | def get_binary_array(n_int, n_bits=8, dtype=np.float32):
method make_obs (line 100) | def make_obs(self, resp=None, get_shape=False):
method init_ground (line 276) | def init_ground(self, agent_info, pos_ro):
method init_air (line 329) | def init_air(self, agent_info, pos_ro):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapHugeConf.py
class SubTaskConfig (line 2) | class SubTaskConfig():
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapIntercept.py
class UhmapIntercept (line 11) | class UhmapIntercept(UhmapEnv):
method __init__ (line 12) | def __init__(self, rank) -> None:
method reset (line 20) | def reset(self):
method step (line 67) | def step(self, act):
method parse_event (line 109) | def parse_event(self, event):
method extract_key_gameobj (line 120) | def extract_key_gameobj(self, resp):
method gen_reward_and_win (line 127) | def gen_reward_and_win(self, resp):
method step_skip (line 168) | def step_skip(self):
method find_agent_by_uid (line 177) | def find_agent_by_uid(self, uid):
method parse_response_ob_info (line 190) | def parse_response_ob_info(self, resp):
method item_random_mv (line 237) | def item_random_mv(src,dst,prob,rand=False):
method get_binary_array (line 248) | def get_binary_array(n_int, n_bits=8, dtype=np.float32):
method make_obs (line 258) | def make_obs(self, resp=None, get_shape=False):
method init_landmark (line 426) | def init_landmark(self, agent_info, pos_ro):
method init_defender (line 460) | def init_defender(self, agent_info, pos_ro):
method init_attacker (line 495) | def init_attacker(self, agent_info, pos_ro):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapInterceptConf.py
class SubTaskConfig (line 2) | class SubTaskConfig():
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapJustAnIsland.py
class UhmapJustAnIsland (line 14) | class UhmapJustAnIsland(UhmapCommonFn, UhmapEnv):
method __init__ (line 15) | def __init__(self, rank) -> None:
method extract_key_gameobj (line 25) | def extract_key_gameobj(self, resp):
method gen_reward_and_win (line 32) | def gen_reward_and_win(self, resp):
method item_random_mv (line 61) | def item_random_mv(src,dst,prob,rand=False):
method get_binary_array (line 72) | def get_binary_array(n_int, n_bits=8, dtype=np.float32):
method make_obs (line 82) | def make_obs(self, resp=None, get_shape=False):
method init_ground (line 255) | def init_ground(self, agent_info, pos_ro):
method init_air (line 308) | def init_air(self, agent_info, pos_ro):
method init_target (line 404) | def init_target(self, agent_info, pos_ro):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapJustAnIslandConf.py
class SubTaskConfig (line 2) | class SubTaskConfig():
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapLargeScale.py
class UhmapLargeScale (line 16) | class UhmapLargeScale(UhmapCommonFn, UhmapEnv):
method __init__ (line 17) | def __init__(self, rank) -> None:
method extract_key_gameobj (line 26) | def extract_key_gameobj(self, resp):
method gen_reward_and_win (line 31) | def gen_reward_and_win(self, resp):
method item_random_mv (line 79) | def item_random_mv(src,dst,prob,rand=False):
method get_binary_array (line 90) | def get_binary_array(n_int, n_bits=8, dtype=np.float32):
method make_obs (line 100) | def make_obs(self, resp=None, get_shape=False):
method init_ground (line 278) | def init_ground(self, agent_info, pos_ro):
method init_air (line 331) | def init_air(self, agent_info, pos_ro):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapLargeScaleConf.py
class SubTaskConfig (line 2) | class SubTaskConfig():
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapPreyPredator.py
class UhmapPreyPredator (line 15) | class UhmapPreyPredator(UhmapCommonFn, UhmapEnv):
method __init__ (line 16) | def __init__(self, rank) -> None:
method init_ground (line 25) | def init_ground(self, agent_info, pos_ro):
method extract_key_gameobj (line 66) | def extract_key_gameobj(self, resp):
method gen_reward_and_win (line 73) | def gen_reward_and_win(self, resp):
method item_random_mv (line 119) | def item_random_mv(src,dst,prob,rand=False):
method get_binary_array (line 130) | def get_binary_array(n_int, n_bits=8, dtype=np.float32):
method make_obs (line 140) | def make_obs(self, resp=None, get_shape=False):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapPreyPredatorConf.py
class SubTaskConfig (line 2) | class SubTaskConfig():
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapReproduce.py
function init_position_helper (line 11) | def init_position_helper(x_max, x_min, y_max, y_min, total, this):
class UhmapReproduce (line 23) | class UhmapReproduce(UhmapEnv):
method __init__ (line 24) | def __init__(self, rank) -> None:
method reset (line 32) | def reset(self):
method step (line 79) | def step(self, act):
method parse_event (line 121) | def parse_event(self, event):
method extract_key_gameobj (line 132) | def extract_key_gameobj(self, resp):
method gen_reward_and_win (line 139) | def gen_reward_and_win(self, resp):
method step_skip (line 162) | def step_skip(self):
method find_agent_by_uid (line 171) | def find_agent_by_uid(self, uid):
method parse_response_ob_info (line 184) | def parse_response_ob_info(self, resp):
method item_random_mv (line 231) | def item_random_mv(src,dst,prob,rand=False):
method get_binary_array (line 242) | def get_binary_array(n_int, n_bits=8, dtype=np.float32):
method make_obs (line 252) | def make_obs(self, resp=None, get_shape=False):
method init_attack (line 421) | def init_attack(self, agent_info, pos_ro):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapReproduceConf.py
class SubTaskConfig (line 2) | class SubTaskConfig():
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapWaterdrop.py
class UhmapWaterdrop (line 15) | class UhmapWaterdrop(UhmapCommonFn, UhmapEnv):
method __init__ (line 16) | def __init__(self, rank) -> None:
method init_ship (line 24) | def init_ship(self, agent_info, pos_ro):
method init_waterdrop (line 60) | def init_waterdrop(self, agent_info, pos_ro):
method extract_key_gameobj (line 96) | def extract_key_gameobj(self, resp):
method gen_reward_and_win (line 103) | def gen_reward_and_win(self, resp):
method item_random_mv (line 146) | def item_random_mv(src,dst,prob,rand=False):
method get_binary_array (line 157) | def get_binary_array(n_int, n_bits=8, dtype=np.float32):
method make_obs (line 167) | def make_obs(self, resp=None, get_shape=False):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapWaterdropConf.py
class SubTaskConfig (line 2) | class SubTaskConfig():
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/actionset.py
function strActionToDigits (line 3) | def strActionToDigits(act_string):
function digitsToStrAction (line 10) | def digitsToStrAction(digits):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/actionset_v3.py
function strActionToDigits (line 3) | def strActionToDigits(act_string):
function digitsToStrAction (line 10) | def digitsToStrAction(digits):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/actset_lookup.py
function encode_action_as_digits (line 73) | def encode_action_as_digits(main_cmd, sub_cmd, x=None, y=None, z=None, U...
function decode_action_as_string (line 111) | def decode_action_as_string(digits):
function binary_friendly (line 211) | def binary_friendly(x):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/agent.py
class Agent (line 4) | class Agent(object):
method __init__ (line 5) | def __init__(self, team, team_id, uid) -> None:
method update_agent_attrs (line 14) | def update_agent_attrs(self, dictionary):
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/auto_download.py
function download_from_shared_server (line 7) | def download_from_shared_server(key = 'cat'):
function download_client_binary_on_platform (line 29) | def download_client_binary_on_platform(desired_path, desired_version, is...
function download_client_binary (line 41) | def download_client_binary(desired_path, desired_version, is_render_clie...
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/struct.cpp
type FAgentProperty (line 9) | struct FAgentProperty
type FParsedDataInput (line 89) | struct FParsedDataInput
type FAgentDataOutput (line 130) | struct FAgentDataOutput
type FKeyObjDataOutput (line 199) | struct FKeyObjDataOutput
type FGlobalDataOutput (line 240) | struct FGlobalDataOutput
type FAgentDataOutputArr (line 298) | struct FAgentDataOutputArr
FILE: PythonExample/hmp_minimal_modules/MISSION/uhmap/uhmap_env_wrapper.py
function make_uhmap_env (line 12) | def make_uhmap_env(env_id, rank):
function get_subtask_conf (line 21) | def get_subtask_conf(subtask):
function usual_id_arrangment (line 30) | def usual_id_arrangment(N_AGENT_EACH_TEAM):
class ScenarioConfig (line 44) | class ScenarioConfig(object):
class UhmapEnvParseHelper (line 136) | class UhmapEnvParseHelper:
method parse_response_ob_info (line 137) | def parse_response_ob_info(self, response):
method make_obs (line 140) | def make_obs(self):
class UhmapEnv (line 144) | class UhmapEnv(BaseEnv, UhmapEnvParseHelper):
method __init__ (line 145) | def __init__(self, rank) -> None:
method __del__ (line 179) | def __del__(self):
method activate_simulation (line 182) | def activate_simulation(self, rank, find_port=True):
method terminate_simulation (line 324) | def terminate_simulation(self):
method reset (line 341) | def reset(self):
method sleep (line 349) | def sleep(self):
method step (line 354) | def step(self, act):
FILE: PythonExample/hmp_minimal_modules/UTIL/auto_gpu.py
class sel_gpu (line 18) | class sel_gpu():
method __init__ (line 29) | def __init__(self,qargs=[]):
method _sort_by_memory (line 36) | def _sort_by_memory(self,gpus,by_size=False):
method _sort_by_power (line 53) | def _sort_by_power(self,gpus):
method _sort_by_custom (line 56) | def _sort_by_custom(self,gpus,key,reverse=False,qargs=[]):
method auto_choice (line 63) | def auto_choice(self,mode=0):
method check_gpus (line 104) | def check_gpus():
method parse (line 124) | def parse(line,qargs):
method query_gpu (line 141) | def query_gpu(self, qargs=[]):
method by_power (line 157) | def by_power(d):
FILE: PythonExample/hmp_minimal_modules/UTIL/batch_exp.py
function get_info (line 8) | def get_info(script_path):
function run_batch_exp (line 21) | def run_batch_exp(sum_note, n_run, n_run_mode, base_conf, conf_override,...
FILE: PythonExample/hmp_minimal_modules/UTIL/colorful.py
function print红 (line 11) | def print红(*kw,**kargs):
function print绿 (line 13) | def print绿(*kw,**kargs):
function print黄 (line 15) | def print黄(*kw,**kargs):
function print蓝 (line 17) | def print蓝(*kw,**kargs):
function print紫 (line 19) | def print紫(*kw,**kargs):
function print靛 (line 21) | def print靛(*kw,**kargs):
function print亮红 (line 24) | def print亮红(*kw,**kargs):
function print亮绿 (line 26) | def print亮绿(*kw,**kargs):
function print亮黄 (line 28) | def print亮黄(*kw,**kargs):
function print亮蓝 (line 30) | def print亮蓝(*kw,**kargs):
function print亮紫 (line 32) | def print亮紫(*kw,**kargs):
function print亮靛 (line 34) | def print亮靛(*kw,**kargs):
function print亮红 (line 39) | def print亮红(*kw,**kargs):
function print亮绿 (line 41) | def print亮绿(*kw,**kargs):
function print亮黄 (line 43) | def print亮黄(*kw,**kargs):
function print亮蓝 (line 45) | def print亮蓝(*kw,**kargs):
function print亮紫 (line 47) | def print亮紫(*kw,**kargs):
function print亮靛 (line 49) | def print亮靛(*kw,**kargs):
FILE: PythonExample/hmp_minimal_modules/UTIL/config_args.py
class ChainVar (line 12) | class ChainVar(object):
method __init__ (line 13) | def __init__(self, chain_func, chained_with):
function is_chained_key (line 18) | def is_chained_key(key):
function prepare_args (line 31) | def prepare_args(vb=True):
function load_config_via_json (line 73) | def load_config_via_json(json_data, vb):
function override_config_file (line 84) | def override_config_file(cfg_group, new_cfg, vb):
function secure_chained_vars (line 106) | def secure_chained_vars(default_cfg, new_cfg, vb):
function check_config_relevence (line 131) | def check_config_relevence(json_data):
function random_seed_warning (line 140) | def random_seed_warning(json_data):
function prepare_tmp_folder (line 146) | def prepare_tmp_folder():
function prepare_alg_tmp_folder (line 155) | def prepare_alg_tmp_folder(json_data):
function register_machine_info (line 197) | def register_machine_info(logdir):
function backup_files (line 214) | def backup_files(files, logdir, jsonfile):
function check_experiment_log_path (line 235) | def check_experiment_log_path(logdir):
function askChoice (line 250) | def askChoice():
function arg_summary (line 253) | def arg_summary(config_class, modify_dict = {}, altered_cv = []):
function my_setattr (line 266) | def my_setattr(conf_class, key, new_value, vb):
function find_all_conf (line 297) | def find_all_conf():
function make_json (line 319) | def make_json(conf_list):
FILE: PythonExample/hmp_minimal_modules/UTIL/data_struct.py
class UniqueList (line 3) | class UniqueList():
method __init__ (line 4) | def __init__(self, list_input=None):
method append_unique (line 9) | def append_unique(self, item):
method extend_unique (line 15) | def extend_unique(self, list_input):
method has (line 19) | def has(self, item):
method len (line 22) | def len(self):
method __len__ (line 25) | def __len__(self):
method get (line 28) | def get(self):
method __iter__ (line 31) | def __iter__(self):
function remove_suffix (line 39) | def remove_suffix(s, sub):
function remove_prefix (line 42) | def remove_prefix(s, sub):
FILE: PythonExample/hmp_minimal_modules/UTIL/exp_helper.py
function singleton (line 5) | def singleton(cls):
class ChainVar (line 15) | class ChainVar(object):
method __init__ (line 16) | def __init__(self, chain_func, chained_with):
class DataCentralServer (line 20) | class DataCentralServer(object): # ADD_TO_CONF_SYSTEM //DO NOT remove th...
class changed (line 27) | class changed():
method __init__ (line 28) | def __init__(self):
method check (line 31) | def check(self, value, key):
class MySFTPClient (line 48) | class MySFTPClient(paramiko.SFTPClient):
method put_dir (line 49) | def put_dir(self, source, target, ignore_list=[]):
method isfile (line 63) | def isfile(self, path):
method get_dir (line 70) | def get_dir(self, source, target, ignore_list=[]):
method mkdir (line 87) | def mkdir(self, path, mode=511, ignore_existing=False):
function get_ssh_sftp (line 101) | def get_ssh_sftp(addr, usr, pwd):
function upload_exp (line 112) | def upload_exp(cfg): # shell it to catch error
function upload_exp_ (line 116) | def upload_exp_(cfg):
FILE: PythonExample/hmp_minimal_modules/UTIL/file_lock.py
class FileLock (line 4) | class FileLock(FileLockBase):
method __init__ (line 5) | def __init__(self, lock_file, timeout: float = -1) -> None:
function is_file_empty (line 10) | def is_file_empty(file_path):
FILE: PythonExample/hmp_minimal_modules/UTIL/gpu_eater.py
function validate_path (line 1) | def validate_path():
function check_devices_mem (line 16) | def check_devices_mem():
function occupy_device_mem (line 33) | def occupy_device_mem(cuda_device, mem_info, free=1024):
function occupy_gpus_mem (line 49) | def occupy_gpus_mem(free=4096):
class GPU_Eater (line 55) | class GPU_Eater(Process):
method __init__ (line 56) | def __init__(self, unix_path, party):
method __del__ (line 70) | def __del__(self):
method run_timer (line 75) | def run_timer(self):
method release_gpu (line 84) | def release_gpu(self):
method hold_gpu (line 88) | def hold_gpu(self):
method on_receive_data (line 92) | def on_receive_data(self, data):
method run (line 113) | def run(self):
FILE: PythonExample/hmp_minimal_modules/UTIL/gpu_share.py
function pid_exist (line 5) | def pid_exist(pid_str):
function read_json (line 9) | def read_json(fp):
function write_json (line 22) | def write_json(fp, buf):
function create_eater (line 27) | def create_eater(unix_path):
class GpuHolder (line 35) | class GpuHolder():
method __init__ (line 36) | def __init__(self, device) -> None:
method __del__ (line 53) | def __del__(self):
method need_gpu (line 58) | def need_gpu(self):
method giveup_gpu (line 62) | def giveup_gpu(self):
class GpuShareUnit (line 67) | class GpuShareUnit():
method __init__ (line 69) | def __init__(self, which_gpu, lock_path=None, manual_gpu_ctl=True, gpu...
method __del__ (line 93) | def __del__(self):
method __enter__ (line 109) | def __enter__(self):
method __exit__ (line 113) | def __exit__(self, exc_type, exc_value, traceback):
method get_gpu_lock (line 116) | def get_gpu_lock(self):
method release_gpu_lock (line 128) | def release_gpu_lock(self):
method register_pid (line 138) | def register_pid(self):
method unregister_pid (line 160) | def unregister_pid(self):
FILE: PythonExample/hmp_minimal_modules/UTIL/hidden_print.py
class HiddenPrints (line 2) | class HiddenPrints:
method __enter__ (line 3) | def __enter__(self):
method __exit__ (line 7) | def __exit__(self, exc_type, exc_val, exc_tb):
FILE: PythonExample/hmp_minimal_modules/UTIL/hmp_daemon.py
function kill_process (line 4) | def kill_process(p):
function kill_process_and_its_children (line 23) | def kill_process_and_its_children(p):
function kill_process_children (line 38) | def kill_process_children(p):
function clean_child_process (line 51) | def clean_child_process(pid):
function hmp_clean_up (line 56) | def hmp_clean_up():
function start_periodic_daemon (line 65) | def start_periodic_daemon(cfg):
function periodic_daemon (line 78) | def periodic_daemon(cfg):
function periodic_daemon_ (line 91) | def periodic_daemon_(cfg):
FILE: PythonExample/hmp_minimal_modules/UTIL/legacy/gpu_share_unfin.py
class GpuShareUnit (line 4) | class GpuShareUnit():
method __init__ (line 5) | def __init__(self, which_gpu, lock_path=None, manual_gpu_ctl=True, gpu...
method __exit__ (line 22) | def __exit__(self, exc_type, exc_value, traceback):
method __enter__ (line 26) | def __enter__(self):
method __del__ (line 30) | def __del__(self):
method _get_gpu_locks (line 33) | def _get_gpu_locks(self):
method __find_all_active_party (line 42) | def __find_all_active_party(self, device):
method __get_gpu_lock (line 55) | def __get_gpu_lock(self, device, gpu_party):
method release_gpu_lock (line 66) | def release_gpu_lock(self):
method ___get_party_n_share (line 77) | def ___get_party_n_share(self, device, gpu_party):
method register_uuid_ (line 88) | def register_uuid_(self, device, gpu_party):
method unregister_uuids_ (line 105) | def unregister_uuids_(self, device, gpu_party):
method unregister_uuid__ (line 114) | def unregister_uuid__(self, device, gpu_party):
method req_all_party (line 125) | def req_all_party(self):
FILE: PythonExample/hmp_minimal_modules/UTIL/mem_watcher_ue.py
function validate_path (line 1) | def validate_path():
function thread_dfs (line 16) | def thread_dfs(p, depth=0, info=None):
function print_info (line 40) | def print_info(depth, pp, info=None):
function find_procs_by_name (line 56) | def find_procs_by_name(name):
function main (line 75) | def main(root_name = 'UE4Editor.exe'):
FILE: PythonExample/hmp_minimal_modules/UTIL/memleak_finder.py
function memdb_print_diff (line 4) | def memdb_print_diff():
FILE: PythonExample/hmp_minimal_modules/UTIL/mprofile.py
function worker (line 165) | def worker(ith_run):
function clean_process (line 171) | def clean_process(pid):
function clean_up (line 184) | def clean_up():
FILE: PythonExample/hmp_minimal_modules/UTIL/network.py
function check_pid (line 5) | def check_pid(pid):
function find_free_port (line 16) | def find_free_port():
function find_free_port_no_repeat (line 24) | def find_free_port_no_repeat():
function get_host_ip (line 81) | def get_host_ip():
class UdpServer (line 95) | class UdpServer:
method __init__ (line 96) | def __init__(self, ip_port, obj='bytes') -> None:
method wait_next_dgram (line 105) | def wait_next_dgram(self):
method reply_last_client (line 112) | def reply_last_client(self, data):
method __del__ (line 120) | def __del__(self):
class UdpTargetedClient (line 124) | class UdpTargetedClient:
method __init__ (line 125) | def __init__(self, target_ip_port, obj='bytes') -> None:
method send_dgram_to_target (line 132) | def send_dgram_to_target(self, data):
method send_and_wait_reply (line 139) | def send_and_wait_reply(self, data):
class UnixUdpServer (line 170) | class UnixUdpServer:
method __init__ (line 171) | def __init__(self, unix_path, obj='bytes') -> None:
method wait_next_dgram (line 182) | def wait_next_dgram(self):
method reply_last_client (line 190) | def reply_last_client(self, data):
method __del__ (line 198) | def __del__(self):
class UnixUdpTargetedClient (line 203) | class UnixUdpTargetedClient:
method __init__ (line 204) | def __init__(self, target_unix_path, self_unix_path=None, obj='bytes')...
method send_dgram_to_target (line 216) | def send_dgram_to_target(self, data):
method send_and_wait_reply (line 223) | def send_and_wait_reply(self, data):
method __del__ (line 233) | def __del__(self):
class StreamingPackageSep (line 262) | class StreamingPackageSep:
method __init__ (line 263) | def __init__(self):
method lower_send (line 268) | def lower_send(self, data, connection):
method lowest_recv (line 274) | def lowest_recv(self, connection):
method lower_recv (line 304) | def lower_recv(self, connection, expect_single=True):
method handle_flag_breakdown (line 313) | def handle_flag_breakdown(self):
class UnixTcpServerP2P (line 325) | class UnixTcpServerP2P(StreamingPackageSep):
method __init__ (line 326) | def __init__(self, unix_path, obj='bytes') -> None:
method accept_conn (line 339) | def accept_conn(self):
method wait_next_dgram (line 343) | def wait_next_dgram(self):
method reply_last_client (line 352) | def reply_last_client(self, data):
method __del__ (line 360) | def __del__(self):
class UnixTcpServerMultiClient (line 367) | class UnixTcpServerMultiClient(StreamingPackageSep):
method __init__ (line 368) | def __init__(self, unix_path, obj='bytes') -> None:
method serve_clients (line 382) | def serve_clients(self, most_recent_client):
method be_online (line 393) | def be_online(self):
method __del__ (line 400) | def __del__(self):
class UnixTcpClientP2P (line 406) | class UnixTcpClientP2P(StreamingPackageSep):
method __init__ (line 407) | def __init__(self, target_unix_path, self_unix_path=None, obj='bytes')...
method send_dgram_to_target (line 421) | def send_dgram_to_target(self, data):
method send_and_wait_reply (line 429) | def send_and_wait_reply(self, data):
method __del__ (line 440) | def __del__(self):
class TcpServerP2P (line 480) | class TcpServerP2P(StreamingPackageSep):
method __init__ (line 481) | def __init__(self, ip_port, obj='bytes') -> None:
method accept_conn (line 492) | def accept_conn(self):
method manual_wait_connection (line 496) | def manual_wait_connection(self):
method wait_next_dgram (line 501) | def wait_next_dgram(self):
method wait_multi_dgrams (line 510) | def wait_multi_dgrams(self):
method reply_last_client (line 519) | def reply_last_client(self, data):
method __del__ (line 527) | def __del__(self):
method close (line 531) | def close(self):
class TcpClientP2P (line 534) | class TcpClientP2P(StreamingPackageSep):
method __init__ (line 535) | def __init__(self, target_ip_port, self_ip_port=None, obj='bytes') -> ...
method send_dgram_to_target (line 544) | def send_dgram_to_target(self, data):
method manual_connect (line 552) | def manual_connect(self):
method send_and_wait_reply (line 555) | def send_and_wait_reply(self, data):
method __del__ (line 566) | def __del__(self):
method close (line 570) | def close(self):
class TcpClientP2PWithCompress (line 590) | class TcpClientP2PWithCompress(StreamingPackageSep):
method __init__ (line 591) | def __init__(self, target_ip_port, self_ip_port=None, obj='bytes') -> ...
method decompress (line 603) | def decompress(self, data):
method compress (line 614) | def compress(self, data):
method send_dgram_to_target (line 618) | def send_dgram_to_target(self, data):
method manual_connect (line 627) | def manual_connect(self):
method send_and_wait_reply (line 630) | def send_and_wait_reply(self, data):
method __del__ (line 642) | def __del__(self):
method close (line 646) | def close(self):
class QueueOnTcpClient (line 649) | class QueueOnTcpClient():
method __init__ (line 650) | def __init__(self, ip):
method send_str (line 658) | def send_str(self, b_msg):
method close (line 661) | def close(self):
method __del__ (line 664) | def __del__(self):
class QueueOnTcpServer (line 667) | class QueueOnTcpServer():
method __init__ (line 668) | def __init__(self, ip_port):
method wait_connection (line 675) | def wait_connection(self):
method listening_thread (line 681) | def listening_thread(self):
method set_handler (line 689) | def set_handler(self, handler):
method get_queue (line 692) | def get_queue(self):
method recv (line 697) | def recv(self):
method close (line 700) | def close(self):
method __del__ (line 703) | def __del__(self):
FILE: PythonExample/hmp_minimal_modules/UTIL/pip_find_missing.py
function print红 (line 5) | def print红(*kw):
function print绿 (line 7) | def print绿(*kw):
function print黄 (line 9) | def print黄(*kw):
function print蓝 (line 11) | def print蓝(*kw):
function print紫 (line 13) | def print紫(*kw):
function print靛 (line 15) | def print靛(*kw):
function printX (line 17) | def printX(*kw):
function install (line 21) | def install(package):
function print红 (line 37) | def print红(*kw):
function print绿 (line 39) | def print绿(*kw):
function print黄 (line 41) | def print黄(*kw):
function print蓝 (line 43) | def print蓝(*kw):
function print紫 (line 45) | def print紫(*kw):
function print靛 (line 47) | def print靛(*kw):
function 是否为工程内的文件交叉调用 (line 67) | def 是否为工程内的文件交叉调用(包,python_file):
function config_anaconda (line 237) | def config_anaconda():
FILE: PythonExample/hmp_minimal_modules/UTIL/shm_env.py
class EnvWithRay (line 21) | class EnvWithRay(object):
method __init__ (line 22) | def __init__(self, env_args_dict):
method __del__ (line 32) | def __del__(self):
method step (line 37) | def step(self, act):
method dict_update (line 70) | def dict_update(self, info, info_reset):
method reset (line 76) | def reset(self):
method sleep (line 79) | def sleep(self):
method render (line 82) | def render(self):
method close (line 85) | def close(self):
method get_act_space (line 88) | def get_act_space(self):
method get_obs_space (line 91) | def get_obs_space(self):
method get_act_space_str (line 94) | def get_act_space_str(self):
method get_obs_space_str (line 97) | def get_obs_space_str(self):
class SuperpoolEnv (line 102) | class SuperpoolEnv(object):
method __init__ (line 103) | def __init__(self, process_pool, env_args_dict_list, spaces=None):
method get_space (line 120) | def get_space(self):
method step (line 123) | def step(self, actions):
method reset (line 138) | def reset(self):
method sleep (line 147) | def sleep(self):
FILE: PythonExample/hmp_minimal_modules/UTIL/sync_exp.py
class SynWorker (line 9) | class SynWorker:
method __init__ (line 11) | def __init__(self, mod) -> None:
method dump_sychronize_data (line 31) | def dump_sychronize_data(self):
method sychronize_experiment (line 39) | def sychronize_experiment(self, key, data, reset_when_close=False):
FILE: PythonExample/hmp_minimal_modules/UTIL/tensor_ops.py
class torch (line 11) | class torch():
class ConfigCache (line 16) | class ConfigCache(object):
method __init__ (line 17) | def __init__(self) -> None:
method read_cfg (line 21) | def read_cfg(self):
method device (line 29) | def device(self):
method use_float64 (line 35) | def use_float64(self):
function pt_inf (line 42) | def pt_inf():
function pt_nan (line 47) | def pt_nan():
function vis_mat (line 53) | def vis_mat(mat):
function repeat_at (line 76) | def repeat_at(tensor, insert_dim, n_times, copy_mem=False):
function np_repeat_at (line 86) | def np_repeat_at(array, insert_dim, n_times):
function copy_clone (line 91) | def copy_clone(x):
function my_view (line 143) | def my_view(x, shape):
function add_onehot_id_at_last_dim (line 163) | def add_onehot_id_at_last_dim(x):
function np_add_onehot_id_at_last_dim (line 170) | def np_add_onehot_id_at_last_dim(x):
function add_onehot_id_at_last_dim_fixlen (line 179) | def add_onehot_id_at_last_dim_fixlen(x, fixlen, agent_ids):
function np_one_hot (line 210) | def np_one_hot(x, n):
function add_obs_container_subject (line 214) | def add_obs_container_subject(container_emb, subject_emb, div):
function MayGoWrong (line 229) | def MayGoWrong(f):
function dummy_decorator (line 241) | def dummy_decorator(f=None):
function Args2tensor (line 259) | def Args2tensor(f):
function Return2numpy (line 289) | def Return2numpy(f):
function Args2tensor_Return2numpy (line 318) | def Args2tensor_Return2numpy(f):
function _2cpu2numpy (line 364) | def _2cpu2numpy(x):
function _2tensor (line 382) | def _2tensor(x):
function pad_vec_array (line 407) | def pad_vec_array(arr_list, max_len):
function one_hot_with_nan_np (line 417) | def one_hot_with_nan_np(tensr, num_classes):
function one_hot_with_nan (line 424) | def one_hot_with_nan(tensr, num_classes):
function scatter_with_nan (line 433) | def scatter_with_nan(tensr, num_classes, out_type="binary"):
function process_space (line 443) | def process_space(space):
class Policy_shift_observer (line 470) | class Policy_shift_observer(object):
method __init__ (line 471) | def __init__(self, act_range, act_num):
method new_sample (line 478) | def new_sample(self, act):
function __hash__ (line 498) | def __hash__(x):
function __hashm__ (line 521) | def __hashm__(*args):
function __hashn__ (line 546) | def __hashn__(generator):
function np_softmax (line 571) | def np_softmax(x, axis=None):
function logsumexp (line 581) | def logsumexp(a, axis=None, keepdims=False, return_sign=False):
function sample_balance (line 609) | def sample_balance(x, y, n_class, weight=None):
function gather_righthand (line 659) | def gather_righthand(src, index, check=True):
function np_gather_righthand (line 696) | def np_gather_righthand(src, index, check=True):
function scatter_righthand (line 730) | def scatter_righthand(scatter_into, src, index, check=True):
function distance_mat_between (line 753) | def distance_mat_between(A, B):
function distance_matrix (line 767) | def distance_matrix(A):
function delta_matrix (line 778) | def delta_matrix(A):
function np_normalize_last_dim (line 785) | def np_normalize_last_dim(mat):
function dir2rad_old (line 788) | def dir2rad_old(delta_pos):
function dir2rad (line 799) | def dir2rad(delta_pos):
function dir3d_rad (line 803) | def dir3d_rad(delta_pos):
function reg_deg (line 812) | def reg_deg(deg):
function reg_deg_at (line 816) | def reg_deg_at(rad, ref):
function reg_rad (line 819) | def reg_rad(rad):
function reg_rad_at (line 824) | def reg_rad_at(rad, ref):
function avg_rad (line 828) | def avg_rad(rad1, rad2):
function zeros_like_except_dim (line 831) | def zeros_like_except_dim(array, except_dim, n):
function pad_at_dim (line 837) | def pad_at_dim(array, dim, n):
function stack_vec_with_padding (line 842) | def stack_vec_with_padding(arr_list):
function objdump (line 853) | def objdump(obj):
function objload (line 859) | def objload():
function stack_padding (line 866) | def stack_padding(l, padding=np.nan):
function n_item (line 873) | def n_item(tensor):
function cat_last_dim (line 882) | def cat_last_dim(tensor, cat):
function arrange_id (line 895) | def arrange_id(N_AGENT_EACH_TEAM):
function get_binary (line 911) | def get_binary(n:int, n_bits:int, dtype=np.float32):
function get_binary_n_rows (line 928) | def get_binary_n_rows(n_row, n_bit=8, dtype=np.float32):
FILE: PythonExample/hmp_minimal_modules/UTIL/win_pool.py
function print_red (line 14) | def print_red(*kw,**kargs):
function print_green (line 17) | def print_green(*kw,**kargs):
function child_process_load_config (line 23) | def child_process_load_config(machine_info):
class SuperProc (line 32) | class SuperProc(multiprocessing.Process):
method __init__ (line 33) | def __init__(self, pipe, pipeHelp, index, base_seed, machine_info):
method automatic_generation (line 42) | def automatic_generation(self, name, gen_fn, *arg):
method automatic_execution (line 45) | def automatic_execution(self, name, dowhat, *arg):
method add_targets (line 48) | def add_targets(self, new_target_args):
method execute_target (line 58) | def execute_target(self, recv_args):
method run (line 71) | def run(self):
method __del__ (line 96) | def __del__(self):
class SmartPool (line 102) | class SmartPool(object):
method __init__ (line 103) | def __init__(self, proc_num, fold, base_seed=None):
method add_target (line 127) | def add_target(self, name, lam, args_list=None):
method exec_target (line 141) | def exec_target(self, name, dowhat, args_list = None, index_list = None):
method party_over (line 196) | def party_over(self):
method __del__ (line 199) | def __del__(self):
FILE: PythonExample/hmp_minimal_modules/VISUALIZE/mcom.py
class mcom (line 9) | class mcom():
method __init__ (line 24) | def __init__(self, path=None, digit=-1, rapid_flush=True, draw_mode="I...
method init_draw_subprocess (line 47) | def init_draw_subprocess(self):
method init_2d_kernel (line 65) | def init_2d_kernel(self):
method __del__ (line 90) | def __del__(self):
method disconnect (line 109) | def disconnect(self):
method recall (line 114) | def recall(self, starting_file):
method send (line 130) | def send(self, data):
method rec_init (line 149) | def rec_init(self, color='k'):
method rec_show (line 153) | def rec_show(self):
method rec_end (line 156) | def rec_end(self):
method rec_save (line 159) | def rec_save(self):
method rec_end_hold (line 162) | def rec_end_hold(self):
method rec_clear (line 165) | def rec_clear(self, name):
method rec (line 169) | def rec(self, value, name):
method other_cmd (line 181) | def other_cmd(self, func_name, *args, **kargs):
method _process_scalar (line 198) | def _process_scalar(self, arg, strlist,key=None):
method _process_ndarray (line 228) | def _process_ndarray(self, args, strlist, key=None):
class DrawProcessThreejs (line 258) | class DrawProcessThreejs(Process):
method __init__ (line 259) | def __init__(self, draw_udp_port, draw_mode, **kargs):
method flush_backup (line 276) | def flush_backup(self):
method init_threejs (line 287) | def init_threejs(self):
method run (line 297) | def run(self):
method __del__ (line 314) | def __del__(self):
method run_handler (line 317) | def run_handler(self, new_buff_list):
method run_flask (line 326) | def run_flask(self, port):
class DrawProcess (line 405) | class DrawProcess(Process):
method __init__ (line 406) | def __init__(self, draw_udp_port, draw_mode, **kargs):
method init_matplot_lib (line 416) | def init_matplot_lib(self):
method run (line 454) | def run(self):
method run_handler (line 475) | def run_handler(self, buff_list):
method __del__ (line 484) | def __del__(self):
method process_cmd (line 489) | def process_cmd(self, cmd_str):
method get_cmd_lib (line 498) | def get_cmd_lib(self, cmd):
method rec_init_fn (line 510) | def rec_init_fn(self):
method v2d_init_fn (line 517) | def v2d_init_fn(self):
class MyHttp (line 524) | class MyHttp(Process):
method __init__ (line 525) | def __init__(self, path_to_html, avail_port):
method run (line 530) | def run(self):
FILE: PythonExample/hmp_minimal_modules/VISUALIZE/mcom_def.py
function find_where_to_log (line 24) | def find_where_to_log(path):
FILE: PythonExample/hmp_minimal_modules/VISUALIZE/mcom_rec.py
class rec_family (line 10) | class rec_family(object):
method __init__ (line 11) | def __init__(self, colorC=None, draw_mode='Native', image_path=None, f...
method rec_disable_percentile_clamp (line 63) | def rec_disable_percentile_clamp(self):
method rec_enable_percentile_clamp (line 66) | def rec_enable_percentile_clamp(self):
method rec_init (line 69) | def rec_init(self, colorC=None):
method match_exclude (line 74) | def match_exclude(self, name):
method get_index (line 80) | def get_index(self, name):
method rec (line 83) | def rec(self, var, name):
method handle_all_missing_time (line 120) | def handle_all_missing_time(self):
method handle_missing_time (line 127) | def handle_missing_time(self, line_arr, time_arr):
method get_figure_size (line 132) | def get_figure_size(self, image_num):
method rec_show (line 139) | def rec_show(self):
method smooth (line 208) | def smooth(self, data, sm_lv=1):
method plot_advanced (line 216) | def plot_advanced(self):
method plot_classic (line 316) | def plot_classic(self, image_num, rows, time_explicit, time_var_met, t...
method change_target_figure_lim (line 375) | def change_target_figure_lim(self, target_subplot, limx1, limx2, limy1...
FILE: PythonExample/hmp_minimal_modules/VISUALIZE/mcom_replay.py
class RecallProcessThreejs (line 9) | class RecallProcessThreejs(Process):
method __init__ (line 10) | def __init__(self, file_path, port):
method init_threejs (line 17) | def init_threejs(self):
method __del__ (line 23) | def __del__(self):
method run (line 26) | def run(self):
method run_handler (line 65) | def run_handler(self, new_buff_list):
method run_flask (line 71) | def run_flask(self, port):
FILE: PythonExample/hmp_minimal_modules/VISUALIZE/mcom_rt.py
class mcom (line 29) | class mcom():
method __init__ (line 30) | def __init__(self, path=None, digit=8, rapid_flush=True, draw_mode=Fal...
method __del__ (line 74) | def __del__(self):
method disconnect (line 94) | def disconnect(self):
method recall (line 99) | def recall(self, starting_file):
method send (line 115) | def send(self, data):
method rec_init (line 144) | def rec_init(self, color='k'):
method rec_show (line 148) | def rec_show(self):
method rec_end (line 151) | def rec_end(self):
method rec_save (line 154) | def rec_save(self):
method rec_end_hold (line 157) | def rec_end_hold(self):
method rec_clear (line 160) | def rec_clear(self, name):
method rec (line 164) | def rec(self, value, name):
method 发送虚幻4数据流 (line 174) | def 发送虚幻4数据流(self, x, y, z, pitch, yaw, roll):
method 发送虚幻4数据流_多智能体 (line 184) | def 发送虚幻4数据流_多智能体(self, x_, y_, z_, pitch_, yaw_, roll_):
method other_cmd (line 201) | def other_cmd(self, func_name, *args, **kargs):
method _process_scalar (line 221) | def _process_scalar(self, arg, strlist,key=None):
method _process_ndarray (line 249) | def _process_ndarray(self, args, strlist, key=None):
function find_where_to_log (line 276) | def find_where_to_log(path):
class DrawProcessThreejs (line 298) | class DrawProcessThreejs(Process):
method __init__ (line 299) | def __init__(self, draw_udp_port, draw_mode, **kargs):
method flush_backup (line 316) | def flush_backup(self):
method init_threejs (line 327) | def init_threejs(self):
method run_ws (line 343) | def run_ws(self, port):
method run_flask (line 426) | def run_flask(self, port):
method run (line 460) | def run(self):
method __del__ (line 476) | def __del__(self):
method run_handler (line 479) | def run_handler(self, new_buff_list):
class DrawProcess (line 490) | class DrawProcess(Process):
method __init__ (line 491) | def __init__(self, draw_udp_port, draw_mode, **kargs):
method init_matplot_lib (line 500) | def init_matplot_lib(self):
method run (line 536) | def run(self):
method run_handler (line 556) | def run_handler(self, buff_list):
method __del__ (line 565) | def __del__(self):
method process_cmd (line 570) | def process_cmd(self, cmd_str):
method get_cmd_lib (line 579) | def get_cmd_lib(self, cmd):
method rec_init_fn (line 591) | def rec_init_fn(self):
method v2d_init_fn (line 595) | def v2d_init_fn(self):
class MyHttp (line 602) | class MyHttp(Process):
method __init__ (line 603) | def __init__(self, path_to_html, avail_port):
method run (line 608) | def run(self):
FILE: PythonExample/hmp_minimal_modules/VISUALIZE/mcom_test.py
function validate_path (line 1) | def validate_path():
FILE: PythonExample/hmp_minimal_modules/VISUALIZE/mcom_v2d.py
class v2d_family (line 12) | class v2d_family():
method __init__ (line 13) | def __init__(self, draw_mode) -> None:
method v2d_init (line 25) | def v2d_init(self):
method v2dx (line 28) | def v2dx(self, name, xpos, ypos, dir=0, **kargs):
method init_fig (line 68) | def init_fig(self):
method add_to_style (line 74) | def add_to_style(self, char_index, char_color):
method rec_data (line 81) | def rec_data(self, x,y,r,dir):
method tank_data (line 89) | def tank_data(self, x,y,r,dir,**kargs):
method circle_data (line 130) | def circle_data(self, x,y,r,dir,rad,step=15):
method dotify_vec (line 140) | def dotify_vec(p_arr):
method line (line 150) | def line(p1,p2, sep):
method fan_data (line 161) | def fan_data(self, x,y,r,dir,rad): #to do: dotted line
method get_terrain (line 182) | def get_terrain(arr, theta):
method v2d_add_terrain (line 189) | def v2d_add_terrain(self, theta):
method v2d_draw (line 193) | def v2d_draw(self):
method v2d_line_object (line 254) | def v2d_line_object(self, indexA, indexB):
method v2d_clear (line 266) | def v2d_clear(self):
method v2d_show (line 275) | def v2d_show(self):
FILE: PythonExample/hmp_minimal_modules/VISUALIZE/seaborn_defaults.py
function setTimesNewRomanFont_MustExecuteAtLast (line 9) | def setTimesNewRomanFont_MustExecuteAtLast():
function init (line 14) | def init(font_scale):
function roll_color_palette (line 25) | def roll_color_palette(cp, offset):
function lift_color (line 30) | def lift_color(cp, n):
function find_in_dict_list (line 33) | def find_in_dict_list(dict_list, **kwargs):
function filter_in_dict_list (line 41) | def filter_in_dict_list(dict_list, **kwargs):
function filter_out_dict_list (line 48) | def filter_out_dict_list(dict_list, **kwargs):
function rename_key_in_dict_list (line 57) | def rename_key_in_dict_list(dict_list, from_what, to_what):
function rename_query_in_dict_list (line 65) | def rename_query_in_dict_list(dict_list, from_what, to_what):
function lift_key_in_dict_list (line 82) | def lift_key_in_dict_list(dict_list, key):
function legend (line 94) | def legend(handle, 水平位置百分比, 垂直位置百分比, 边框, 字体大小):
function save_and_push (line 105) | def save_and_push(handle, img_path, check_exist=True):
FILE: PythonExample/hmp_minimal_modules/ZDOCS/test_examples.py
function validate_path (line 1) | def validate_path():
function get_info (line 30) | def get_info(script_path):
function run_batch_exp (line 44) | def run_batch_exp(n_run, n_run_mode, test_subjects, script_path, sum_not...
FILE: PythonExample/hmp_minimal_modules/config.py
class GlobalConfig (line 46) | class GlobalConfig(object): # ADD_TO_CONF_SYSTEM //DO NOT remove this co...
FILE: PythonExample/hmp_minimal_modules/main.py
function SET_NUM_THREADS (line 24) | def SET_NUM_THREADS(internal_threads):
function pytorch_gpu_init (line 32) | def pytorch_gpu_init(cfg):
function register_daemon (line 54) | def register_daemon(cfg):
FILE: PythonExample/hmp_minimal_modules/multi_team.py
class MMPlatform (line 5) | class MMPlatform(object):
method __init__ (line 7) | def __init__(self, mcv, envs):
method act (line 44) | def act(self, runner_info):
method before_terminate (line 69) | def before_terminate(self, runner_info):
method _update_runner (line 75) | def _update_runner(self, runner_info, ENV_PAUSE, t_name, key, content):
method _split_intel (line 85) | def _split_intel(self, runner_info, t_members, t_name, t_index):
method _append_act_to_list (line 132) | def _append_act_to_list(self, _act_, actions_list, t_members):
method deal_with_hook (line 139) | def deal_with_hook(self, hook, t_intel_basic):
method notify_teams (line 151) | def notify_teams(self, message, **kargs):
method __split_obs (line 157) | def __split_obs(self, obs, t_index):
method __split_obs_thread (line 167) | def __split_obs_thread(self, obs, t_index):
FILE: PythonExample/hmp_minimal_modules/multi_team_parallel.py
class alg_parallel_wrapper (line 6) | class alg_parallel_wrapper(object):
method __init__ (line 7) | def __init__(self, t_name, n_agent, n_thread, space, mcv, team) -> None:
method interact_with_env (line 15) | def interact_with_env(self, _input_):
method call_hook_deligate (line 25) | def call_hook_deligate(self, callback_arg):
method init_alg_logger (line 31) | def init_alg_logger(self):
class MMPlatform (line 45) | class MMPlatform(object):
method __init__ (line 47) | def __init__(self, mcv, envs):
method act (line 96) | def act(self, runner_info):
method before_terminate (line 129) | def before_terminate(self, runner_info):
method _update_runner (line 135) | def _update_runner(self, runner_info, ENV_PAUSE, t_name, key, content):
method _split_intel (line 145) | def _split_intel(self, runner_info, t_members, t_name, t_index):
method _append_act_to_list (line 194) | def _append_act_to_list(self, _act_, actions_list, t_members):
method deal_with_hook (line 201) | def deal_with_hook(self, hook, t_intel_basic, t_index):
method notify_teams (line 224) | def notify_teams(self, message, **kargs):
method __split_obs (line 229) | def __split_obs(self, obs, t_index):
method __split_obs_thread (line 239) | def __split_obs_thread(self, obs, t_index):
FILE: PythonExample/hmp_minimal_modules/task_runner.py
class Runner (line 16) | class Runner(object):
method __init__ (line 17) | def __init__(self, process_pool):
method run (line 53) | def run(self):
method init_runner (line 76) | def init_runner(self):
method update_runner (line 94) | def update_runner(self, done, obs, reward, info):
method start_a_test_run (line 148) | def start_a_test_run(self):
method init_test_runner (line 170) | def init_test_runner(self):
method update_test_runner (line 190) | def update_test_runner(self, done, obs, reward, info):
method _init_interested_agent_logging (line 223) | def _init_interested_agent_logging(self):
method _checkout_interested_agents (line 230) | def _checkout_interested_agents(self, info_runner, testing=False):
method get_a_logger (line 292) | def get_a_logger(note):
method heartbeat (line 306) | def heartbeat(self, style=0, beat=None):
method get_fps (line 321) | def get_fps(self, dt):
FILE: Source/Jsonx/Jsonx.Build.cs
class Jsonx (line 5) | public class Jsonx : ModuleRules
method Jsonx (line 7) | public Jsonx(ReadOnlyTargetRules Target) : base(Target)
FILE: Source/Jsonx/Private/Dom/JsonxObject.cpp
function FString (line 56) | FString FJsonxObject::GetStringField( const FString& FieldName ) const
FILE: Source/Jsonx/Private/Dom/JsonxValue.cpp
function FString (line 22) | FString FJsonxValue::AsString() const
function TryConvertNumber (line 80) | bool TryConvertNumber(const FJsonxValue& InValue, T& OutNumber)
FILE: Source/Jsonx/Private/JsonxModule.cpp
class FJsonxModule (line 15) | class FJsonxModule
method StartupModule (line 22) | virtual void StartupModule( ) override { }
method ShutdownModule (line 23) | virtual void ShutdownModule( ) override { }
method SupportsDynamicReloading (line 25) | virtual bool SupportsDynamicReloading( ) override
FILE: Source/Jsonx/Public/Dom/JsonxObject.h
function class (line 14) | class JSONX_API FJsonxObject
function FORCEINLINE (line 119) | FORCEINLINE int32 GetIntegerField(const FString& FieldName) const
FILE: Source/Jsonx/Public/Dom/JsonxValue.h
function class (line 14) | class JSONX_API FJsonxValue
function override (line 117) | const override { if (Value.IsNumeric()) { OutDouble = FCString::Atod(*V...
function override (line 118) | const override { LexFromString(OutValue, *Value); return true; }
function override (line 119) | const override { LexFromString(OutValue, *Value); return true; }
function override (line 120) | const override { LexFromString(OutValue, *Value); return true; }
function override (line 121) | const override { LexFromString(OutValue, *Value); return true; }
function override (line 122) | const override { OutBool = Value.ToBool(); return true; }
function override (line 139) | const override { OutNumber = Value; return true; }
function override (line 140) | const override { OutBool = (Value != 0.0); return true; }
function override (line 157) | const override { OutString = Value; return true; }
function override (line 158) | const override { return LexTryParseString(OutDouble, *Value); }
function override (line 159) | const override { return LexTryParseString(OutDouble, *Value); }
function override (line 160) | const override { return LexTryParseString(OutValue, *Value); }
function override (line 161) | const override { return LexTryParseString(OutValue, *Value); }
function override (line 162) | const override { return LexTryParseString(OutValue, *Value); }
function override (line 163) | const override { return LexTryParseString(OutValue, *Value); }
function override (line 164) | const override { return LexTryParseString(OutValue, *Value); }
function override (line 165) | const override { return LexTryParseString(OutValue, *Value); }
function override (line 166) | const override { return LexTryParseString(OutValue, *Value); }
function override (line 167) | const override { return LexTryParseString(OutValue, *Value); }
function override (line 168) | const override { OutBool = Value.ToBool(); return true; }
function override (line 182) | const override { OutNumber = Value ? 1 : 0; return true; }
function override (line 183) | const override { OutBool = Value; return true; }
function override (line 184) | const override { OutString = Value ? TEXT("true") : TEXT("false"); retur...
function virtual (line 198) | virtual bool TryGetArray(const TArray< TSharedPtr<FJsonxValue> >*& OutAr...
function virtual (line 212) | virtual bool TryGetObject(const TSharedPtr<FJsonxObject>*& OutObject) co...
FILE: Source/Jsonx/Public/Policies/CondensedJsonxPrintPolicy.h
function WriteLineTerminator (line 17) | static inline void WriteLineTerminator(FArchive* Stream) {}
function WriteTabs (line 18) | static inline void WriteTabs(FArchive* Stream, int32 Count) {}
function WriteSpace (line 19) | static inline void WriteSpace(FArchive* Stream) {}
FILE: Source/Jsonx/Public/Policies/JsonxPrintPolicy.h
function WriteChar (line 21) | static inline void WriteChar( FArchive* Stream, CharType Char )
function WriteString (line 32) | static inline void WriteString( FArchive* Stream, const FString& String )
function WriteString (line 48) | inline void TJsonxPrintPolicy<TCHAR>::WriteString( FArchive* Stream, con...
function WriteString (line 60) | inline void TJsonxPrintPolicy<UTF16CHAR>::WriteString(FArchive* Stream, ...
FILE: Source/Jsonx/Public/Policies/PrettyJsonxPrintPolicy.h
function WriteLineTerminator (line 17) | static inline void WriteLineTerminator( FArchive* Stream )
function WriteTabs (line 22) | static inline void WriteTabs( FArchive* Stream, int32 Count )
function WriteSpace (line 32) | static inline void WriteSpace( FArchive* Stream )
FILE: Source/Jsonx/Public/Serialization/JsonxReader.h
function ReadNext (line 50) | bool ReadNext( EJsonxNotation& Notation )
function SkipObject (line 142) | bool SkipObject()
function SkipArray (line 147) | bool SkipArray()
function FString (line 154) | const FString& GetValueAsString() const
function FORCEINLINE (line 166) | FORCEINLINE const FString& GetValueAsNumberString() const
function ReadUntilMatching (line 236) | bool ReadUntilMatching( const EJsonxNotation ExpectedNotation )
function ReadStart (line 275) | bool ReadStart( EJsonxToken& Token )
function ReadNextObjectValue (line 298) | bool ReadNextObjectValue( EJsonxToken& Token )
function ReadNextArrayValue (line 361) | bool ReadNextArrayValue( EJsonxToken& Token )
function NextToken (line 398) | bool NextToken( EJsonxToken& OutToken )
function ParseStringToken (line 554) | bool ParseStringToken()
function ParseNumberToken (line 648) | bool ParseNumberToken( CharType FirstChar )
function ParseWhiteSpace (line 775) | bool ParseWhiteSpace()
function IsLineBreak (line 803) | bool IsLineBreak( const CharType& Char )
function IsWhitespace (line 809) | bool IsWhitespace( const CharType& Char )
function IsJsonxNumber (line 815) | bool IsJsonxNumber( const CharType& Char )
function IsDigit (line 822) | bool IsDigit( const CharType& Char )
function IsNonZeroDigit (line 827) | bool IsNonZeroDigit( const CharType& Char )
function IsAlphaNumber (line 833) | bool IsAlphaNumber( const CharType& Char )
function class (line 867) | class FJsonxStringReader
function FORCEINLINE (line 916) | FORCEINLINE void InitReader()
function TSharedRef (line 945) | static TSharedRef<TJsonxReader<TCHAR>> Create(FString&& JsonxString)
function TSharedRef (line 950) | static TSharedRef<TJsonxReader<CharType>> Create(FArchive* const Stream)
FILE: Source/Jsonx/Public/Serialization/JsonxSerializer.h
function class (line 14) | class FJsonxSerializer
type StackState (line 148) | struct StackState
type FElement (line 156) | struct FElement
FILE: Source/Jsonx/Public/Serialization/JsonxSerializerMacros.h
type FJsonxSerializerBase (line 244) | struct FJsonxSerializerBase
type TArray (line 247) | typedef TArray<FString> FJsonxSerializableArray;
type TArray (line 248) | typedef TArray<int32> FJsonxSerializableArrayInt;
type TMap (line 251) | typedef TMap<FString, FString> FJsonxSerializableKeyValueMap;
type TMap (line 252) | typedef TMap<FString, int32> FJsonxSerializableKeyValueMapInt;
type TMap (line 253) | typedef TMap<FString, int64> FJsonxSerializableKeyValueMapInt64;
type TMap (line 254) | typedef TMap<FString, float> FJsonxSerializableKeyValueMapFloat;
type FJsonxSerializerBase (line 259) | struct FJsonxSerializerBase
function virtual (line 314) | virtual ~FJsonxSerializerWriter()
function virtual (line 323) | virtual TSharedPtr<FJsonxObject> GetObject() override { return TSharedPt...
function virtual (line 328) | virtual void StartObject() override
function virtual (line 336) | virtual void StartObject(const FString& Name) override
function virtual (line 343) | virtual void EndObject() override
function virtual (line 348) | virtual void StartArray() override
function virtual (line 353) | virtual void StartArray(const FString& Name) override
function virtual (line 358) | virtual void EndArray() override
function virtual (line 368) | virtual void Serialize(const TCHAR* Name, int32& Value) override
function virtual (line 378) | virtual void Serialize(const TCHAR* Name, uint32& Value) override
function virtual (line 388) | virtual void Serialize(const TCHAR* Name, int64& Value) override
function virtual (line 398) | virtual void Serialize(const TCHAR* Name, bool& Value) override
function virtual (line 408) | virtual void Serialize(const TCHAR* Name, FString& Value) override
function virtual (line 418) | virtual void Serialize(const TCHAR* Name, FText& Value) override
function virtual (line 428) | virtual void Serialize(const TCHAR* Name, float& Value) override
function virtual (line 438) | virtual void Serialize(const TCHAR* Name, double& Value) override
function virtual (line 448) | virtual void Serialize(const TCHAR* Name, FDateTime& Value) override
function virtual (line 477) | virtual void SerializeArray(const TCHAR* Name, FJsonxSerializableArray& ...
function virtual (line 850) | virtual void SerializeMap(const TCHAR* Name, FJsonxSerializableKeyValueM...
function virtual (line 870) | virtual void SerializeMap(const TCHAR* Name, FJsonxSerializableKeyValueM...
function virtual (line 1015) | virtual bool FromJsonx(const FString& Jsonx)
function FJsonxSerializable (line 1062) | struct FJsonxDataBag
function GetDouble (line 1139) | double GetDouble(const FString& Key) const
function FString (line 1145) | FString GetString(const FString& Key) const
function GetBool (line 1151) | bool GetBool(const FString& Key) const
function SetFieldJsonx (line 1172) | void SetFieldJsonx(const FString& Key, const TSharedPtr<FJsonxValue>& Va...
FILE: Source/Jsonx/Public/Serialization/JsonxTypes.h
type class (line 21) | enum class
type class (line 33) | enum class
function FORCEINLINE (line 53) | FORCEINLINE bool EJsonxToken_IsShortValue(EJsonxToken Token)
type class (line 58) | enum class
FILE: Source/Jsonx/Public/Serialization/JsonxWriter.h
function FString (line 60) | inline FString EscapeJsonxString(const FString& StringVal)
function WriteObjectStart (line 93) | void WriteObjectStart()
function WriteObjectStart (line 113) | void WriteObjectStart( const FString& Identifier )
function WriteObjectEnd (line 126) | void WriteObjectEnd()
function WriteArrayStart (line 139) | void WriteArrayStart()
function WriteArrayStart (line 159) | void WriteArrayStart( const FString& Identifier )
function WriteArrayEnd (line 171) | void WriteArrayEnd()
function WriteValue (line 210) | void WriteValue(const FString& Value)
function WriteValue (line 241) | void WriteValue(const FString& Identifier, const TCHAR* Value)
function WriteRawJSONXValue (line 248) | void WriteRawJSONXValue( const FString& Identifier, const FString& Value )
function WriteNull (line 258) | void WriteNull( const FString& Identifier )
function WriteValue (line 263) | void WriteValue( const TCHAR* Value )
function WriteRawJSONXValue (line 270) | void WriteRawJSONXValue( const FString& Value )
function WriteNull (line 289) | void WriteNull()
function virtual (line 294) | virtual bool Close()
function WriteIdentifierPrefix (line 305) | void WriteIdentifierPrefix(const FString& Identifier)
function FORCEINLINE (line 348) | FORCEINLINE void WriteIdentifier( const FString& Identifier )
function FORCEINLINE (line 358) | FORCEINLINE EJsonxToken WriteValueOnly(bool Value)
function FORCEINLINE (line 366) | FORCEINLINE EJsonxToken WriteValueOnly(float Value)
function FORCEINLINE (line 380) | FORCEINLINE EJsonxToken WriteValueOnly(double Value)
function FORCEINLINE (line 397) | FORCEINLINE EJsonxToken WriteValueOnly(float Value)
function FORCEINLINE (line 404) | FORCEINLINE EJsonxToken WriteValueOnly(double Value)
function FORCEINLINE (line 417) | FORCEINLINE EJsonxToken WriteValueOnly(int32 Value)
function FORCEINLINE (line 422) | FORCEINLINE EJsonxToken WriteValueOnly(int64 Value)
function WriteValueOnly (line 428) | WriteValueOnly(TYPE_OF_NULLPTR)
function virtual (line 440) | virtual void WriteStringValue( const FString& String )
function virtual (line 472) | virtual bool Close() override
FILE: Source/JsonxUtilities/JsonxUtilities.Build.cs
class JsonxUtilities (line 5) | public class JsonxUtilities : ModuleRules
method JsonxUtilities (line 7) | public JsonxUtilities( ReadOnlyTargetRules Target ) : base(Target)
FILE: Source/JsonxUtilities/Private/JsonxObjectConverter.cpp
function FString (line 15) | FString FJsonxObjectConverter::StandardizeCase(const FString &StringIn)
function ConvertScalarFPropertyToJsonxValue (line 30) | TSharedPtr<FJsonxValue> ConvertScalarFPropertyToJsonxValue(FProperty* Pr...
function PRAGMA_DISABLE_DEPRECATION_WARNINGS (line 207) | PRAGMA_DISABLE_DEPRECATION_WARNINGS
function PRAGMA_ENABLE_DEPRECATION_WARNINGS (line 233) | PRAGMA_ENABLE_DEPRECATION_WARNINGS
function UStructToJsonxObjectStringInternal (line 309) | bool UStructToJsonxObjectStringInternal(const TSharedRef<FJsonxObject>& ...
function ConvertScalarJsonxValueToFPropertyWithContainer (line 395) | bool ConvertScalarJsonxValueToFPropertyWithContainer(const TSharedPtr<FJ...
function JsonxValueToFPropertyWithContainer (line 750) | bool JsonxValueToFPropertyWithContainer(const TSharedPtr<FJsonxValue>& J...
function JsonxAttributesToUStructWithContainer (line 803) | bool JsonxAttributesToUStructWithContainer(const TMap< FString, TSharedP...
function FFormatNamedArguments (line 941) | FFormatNamedArguments FJsonxObjectConverter::ParseTextArgumentsFromJsonx...
FILE: Source/JsonxUtilities/Public/JsonxDomBuilder.h
function class (line 31) | class FJsonxDomBuilder
function CopyIf (line 85) | void CopyIf(const FJsonxObject& Src, TFunctionRef<bool (const FString&, ...
FILE: Source/JsonxUtilities/Public/JsonxObjectConverter.h
function class (line 14) | class JSONXUTILITIES_API FJsonxObjectConverter
FILE: Source/JsonxUtilities/Public/JsonxObjectWrapper.h
function JSONXUTILITIES_API (line 16) | JSONXUTILITIES_API FJsonxObjectWrapper
type TStructOpsTypeTraits (line 40) | struct TStructOpsTypeTraits
FILE: Source/UHMP.Target.cs
class UHMPTarget (line 6) | public class UHMPTarget : TargetRules
method UHMPTarget (line 8) | public UHMPTarget(TargetInfo Target) : base(Target)
FILE: Source/UHMP/DataStruct.h
function FAgentProperty (line 8) | USTRUCT(BlueprintType)
function FParsedDataInput (line 88) | USTRUCT(BlueprintType)
function FAgentDataOutput (line 129) | USTRUCT(BlueprintType)
function FKeyObjDataOutput (line 201) | USTRUCT(BlueprintType)
function FGlobalDataOutput (line 242) | USTRUCT(BlueprintType)
function FAgentDataOutputArr (line 300) | USTRUCT(BlueprintType)
FILE: Source/UHMP/HMPAIController.h
function UHMP_API (line 13) | UHMP_API AHMPAIController : public AAIController
FILE: Source/UHMP/HMPLevelScriptActor.h
function FAgentSetting (line 16) | USTRUCT(BlueprintType)
function FParsedTcpInData (line 72) | USTRUCT(BlueprintType)
function FTcpOutAgentData (line 106) | USTRUCT(BlueprintType)
function FTcpOutAgentDataArr (line 186) | USTRUCT(BlueprintType)
function UHMP_API (line 203) | UHMP_API AHMPLevelScriptActor : public ALevelScriptActor
FILE: Source/UHMP/HmpCrowdFollowingComponent.h
function UHMP_API (line 19) | UHMP_API UHmpCrowdFollowingComponent : public UCrowdFollowingComponent
FILE: Source/UHMP/HmpPythonIO.cpp
function FString (line 117) | FString AHmpPythonIO::TcpServerRecvBlocked(bool checkEOF, float& tcpWait...
function FParsedDataInput (line 174) | FParsedDataInput AHmpPythonIO::ParsedTcpInData(FString TcpLatestRecvString)
FILE: Source/UHMP/HmpPythonIO.h
function UHMP_API (line 18) | UHMP_API AHmpPythonIO : public AActor
FILE: Source/UHMP/IOCompress/lz4.c
function XLZ4_isAligned (line 290) | static int XLZ4_isAligned(const void* ptr, size_t alignment)
type BYTE (line 302) | typedef uint8_t BYTE;
type U16 (line 303) | typedef uint16_t U16;
type U32 (line 304) | typedef uint32_t U32;
type S32 (line 305) | typedef int32_t S32;
type U64 (line 306) | typedef uint64_t U64;
type uptrval (line 307) | typedef uintptr_t uptrval;
type BYTE (line 312) | typedef unsigned char BYTE;
type U16 (line 313) | typedef unsigned short U16;
type U32 (line 314) | typedef unsigned int U32;
type S32 (line 315) | typedef signed int S32;
type U64 (line 316) | typedef unsigned long long U64;
type uptrval (line 317) | typedef size_t uptrval;
type U64 (line 321) | typedef U64 reg_t;
type reg_t (line 323) | typedef size_t reg_t;
type limitedOutput_directive (line 326) | typedef enum {
function XLZ4_isLittleEndian (line 361) | static unsigned XLZ4_isLittleEndian(void)
function U16 (line 371) | static U16 XLZ4_read16(const void* memPtr) { return *(const U16*) memPtr; }
function U32 (line 372) | static U32 XLZ4_read32(const void* memPtr) { return *(const U32*) memPtr; }
function reg_t (line 373) | static reg_t XLZ4_read_ARCH(const void* memPtr) { return *(const reg_t*)...
function XLZ4_write16 (line 375) | static void XLZ4_write16(void* memPtr, U16 value) { *(U16*)memPtr = valu...
function XLZ4_write32 (line 376) | static void XLZ4_write32(void* memPtr, U32 value) { *(U32*)memPtr = valu...
type XLZ4_unalign (line 382) | typedef union { U16 u16; U32 u32; reg_t uArch; } __attribute__((packed))...
function U16 (line 384) | static U16 XLZ4_read16(const void* ptr) { return ((const XLZ4_unalign*)p...
function U32 (line 385) | static U32 XLZ4_read32(const void* ptr) { return ((const XLZ4_unalign*)p...
function reg_t (line 386) | static reg_t XLZ4_read_ARCH(const void* ptr) { return ((const XLZ4_unali...
function XLZ4_write16 (line 388) | static void XLZ4_write16(void* memPtr, U16 value) { ((XLZ4_unalign*)memP...
function XLZ4_write32 (line 389) | static void XLZ4_write32(void* memPtr, U32 value) { ((XLZ4_unalign*)memP...
function U16 (line 393) | static U16 XLZ4_read16(const void* memPtr)
function U32 (line 398) | static U32 XLZ4_read32(const void* memPtr)
function reg_t (line 403) | static reg_t XLZ4_read_ARCH(const void* memPtr)
function XLZ4_write16 (line 408) | static void XLZ4_write16(void* memPtr, U16 value)
function XLZ4_write32 (line 413) | static void XLZ4_write32(void* memPtr, U32 value)
function U16 (line 421) | static U16 XLZ4_readLE16(const void* memPtr)
function XLZ4_writeLE16 (line 431) | static void XLZ4_writeLE16(void* memPtr, U16 value)
function XLZ4_FORCE_INLINE (line 443) | XLZ4_FORCE_INLINE
function XLZ4_FORCE_INLINE (line 474) | XLZ4_FORCE_INLINE void
function XLZ4_FORCE_INLINE (line 500) | XLZ4_FORCE_INLINE void
function XLZ4_FORCE_INLINE (line 513) | XLZ4_FORCE_INLINE void
function XLZ4_NbCommonBytes (line 558) | static unsigned XLZ4_NbCommonBytes (reg_t val)
function XLZ4_count (line 658) | XLZ4_FORCE_INLINE
type tableType_t (line 696) | typedef enum { clearedTable = 0, byPtr, byU32, byU16 } tableType_t;
type dict_directive (line 721) | typedef enum { noDict = 0, withPrefix64k, usingExtDict, usingDictCtx } d...
type dictIssue_directive (line 722) | typedef enum { noDictIssue = 0, dictSmall } dictIssue_directive;
function XLZ4_versionNumber (line 728) | int XLZ4_versionNumber (void) { return XLZ4_VERSION_NUMBER; }
function XLZ4_compressBound (line 730) | int XLZ4_compressBound(int isize) { return XLZ4_COMPRESSBOUND(isize); }
function XLZ4_sizeofState (line 731) | int XLZ4_sizeofState(void) { return sizeof(XLZ4_stream_t); }
function XLZ4_FORCE_INLINE (line 756) | XLZ4_FORCE_INLINE U32 XLZ4_hash4(U32 sequence, tableType_t const tableType)
function XLZ4_FORCE_INLINE (line 764) | XLZ4_FORCE_INLINE U32 XLZ4_hash5(U64 sequence, tableType_t const tableType)
function XLZ4_FORCE_INLINE (line 776) | XLZ4_FORCE_INLINE U32 XLZ4_hashPosition(const void* const p, tableType_t...
function XLZ4_FORCE_INLINE (line 782) | XLZ4_FORCE_INLINE void XLZ4_clearHash(U32 h, void* tableBase, tableType_...
function XLZ4_FORCE_INLINE (line 794) | XLZ4_FORCE_INLINE void XLZ4_putIndexOnHash(U32 idx, U32 h, void* tableBa...
function XLZ4_FORCE_INLINE (line 806) | XLZ4_FORCE_INLINE void XLZ4_putPositionOnHash(const BYTE* p, U32 h,
function XLZ4_FORCE_INLINE (line 819) | XLZ4_FORCE_INLINE void XLZ4_putPosition(const BYTE* p, void* tableBase, ...
function XLZ4_FORCE_INLINE (line 831) | XLZ4_FORCE_INLINE U32 XLZ4_getIndexOnHash(U32 h, const void* tableBase, ...
function BYTE (line 847) | static const BYTE* XLZ4_getPositionOnHash(U32 h, const void* tableBase, ...
function XLZ4_FORCE_INLINE (line 854) | XLZ4_FORCE_INLINE const BYTE*
function XLZ4_FORCE_INLINE (line 863) | XLZ4_FORCE_INLINE void
function XLZ4_FORCE_INLINE (line 910) | XLZ4_FORCE_INLINE int XLZ4_compress_generic_validated(
function XLZ4_FORCE_INLINE (line 1308) | XLZ4_FORCE_INLINE int XLZ4_compress_generic(
function XLZ4_compress_fast_extState (line 1346) | int XLZ4_compress_fast_extState(void* state, const char* source, char* d...
function XLZ4_compress_fast_extState_fastReset (line 1378) | int XLZ4_compress_fast_extState_fastReset(void* state, const char* src, ...
function XLZ4_compress_fast (line 1416) | int XLZ4_compress_fast(const char* source, char* dest, int inputSize, in...
function XLZ4_compress_default (line 1435) | int XLZ4_compress_default(const char* src, char* dst, int srcSize, int m...
function XLZ4_compress_destSize_extState (line 1444) | static int XLZ4_compress_destSize_extState (XLZ4_stream_t* state, const ...
function XLZ4_compress_destSize (line 1461) | int XLZ4_compress_destSize(const char* src, char* dst, int* srcSizePtr, ...
function XLZ4_stream_t (line 1486) | XLZ4_stream_t* XLZ4_createStream(void)
function XLZ4_stream_t_alignment (line 1497) | static size_t XLZ4_stream_t_alignment(void)
function XLZ4_stream_t (line 1507) | XLZ4_stream_t* XLZ4_initStream (void* buffer, size_t size)
function XLZ4_resetStream (line 1519) | void XLZ4_resetStream (XLZ4_stream_t* XLZ4_stream)
function XLZ4_resetStream_fast (line 1525) | void XLZ4_resetStream_fast(XLZ4_stream_t* ctx) {
function XLZ4_freeStream (line 1530) | int XLZ4_freeStream (XLZ4_stream_t* XLZ4_stream)
function XLZ4_loadDict (line 1541) | int XLZ4_loadDict (XLZ4_stream_t* XLZ4_dict, const char* dictionary, int...
function XLZ4_attach_dictionary (line 1583) | void XLZ4_attach_dictionary(XLZ4_stream_t* workingStream, const XLZ4_str...
function XLZ4_renormDictT (line 1612) | static void XLZ4_renormDictT(XLZ4_stream_t_internal* XLZ4_dict, int next...
function XLZ4_compress_fast_continue (line 1632) | int XLZ4_compress_fast_continue (XLZ4_stream_t* XLZ4_stream,
function XLZ4_compress_forceExtDict (line 1712) | int XLZ4_compress_forceExtDict (XLZ4_stream_t* XLZ4_dict, const char* so...
function XLZ4_saveDict (line 1739) | int XLZ4_saveDict (XLZ4_stream_t* XLZ4_dict, char* safeBuffer, int dictS...
type earlyEnd_directive (line 1767) | typedef enum { decode_full_block = 0, partial_decode = 1 } earlyEnd_dire...
function read_long_length_no_check (line 1777) | size_t read_long_length_no_check(const BYTE** pp)
function XLZ4_FORCE_INLINE (line 1794) | XLZ4_FORCE_INLINE int
type Rvl_t (line 1901) | typedef size_t Rvl_t;
function XLZ4_FORCE_INLINE (line 1903) | XLZ4_FORCE_INLINE Rvl_t
function XLZ4_FORCE_O2 (line 2344) | XLZ4_FORCE_O2
function XLZ4_FORCE_O2 (line 2352) | XLZ4_FORCE_O2
function XLZ4_FORCE_O2 (line 2361) | XLZ4_FORCE_O2
function XLZ4_FORCE_O2 (line 2372) | XLZ4_FORCE_O2 /* Exported, an obsolete API function. */
function XLZ4_FORCE_O2 (line 2380) | XLZ4_FORCE_O2
function XLZ4_decompress_fast_withPrefix64k (line 2390) | int XLZ4_decompress_fast_withPrefix64k(const char* source, char* dest, i...
function XLZ4_FORCE_O2 (line 2397) | XLZ4_FORCE_O2
function XLZ4_FORCE_O2 (line 2406) | XLZ4_FORCE_O2
function XLZ4_FORCE_O2 (line 2416) | XLZ4_FORCE_O2
function XLZ4_FORCE_O2 (line 2426) | XLZ4_FORCE_O2
function XLZ4_FORCE_O2 (line 2437) | XLZ4_FORCE_O2
function XLZ4_FORCE_INLINE (line 2450) | XLZ4_FORCE_INLINE
function XLZ4_streamDecode_t (line 2462) | XLZ4_streamDecode_t* XLZ4_createStreamDecode(void)
function XLZ4_freeStreamDecode (line 2468) | int XLZ4_freeStreamDecode (XLZ4_streamDecode_t* XLZ4_stream)
function XLZ4_setStreamDecode (line 2482) | int XLZ4_setStreamDecode (XLZ4_streamDecode_t* XLZ4_streamDecode, const ...
function XLZ4_decoderRingBufferSize (line 2508) | int XLZ4_decoderRingBufferSize(int maxBlockSize)
function XLZ4_FORCE_O2 (line 2523) | XLZ4_FORCE_O2
function XLZ4_FORCE_O2 (line 2563) | XLZ4_FORCE_O2 int
function XLZ4_decompress_safe_usingDict (line 2612) | int XLZ4_decompress_safe_usingDict(const char* source, char* dest, int c...
function XLZ4_decompress_safe_partial_usingDict (line 2627) | int XLZ4_decompress_safe_partial_usingDict(const char* source, char* des...
function XLZ4_decompress_fast_usingDict (line 2642) | int XLZ4_decompress_fast_usingDict(const char* source, char* dest, int o...
function XLZ4_compress_limitedOutput (line 2657) | int XLZ4_compress_limitedOutput(const char* source, char* dest, int inpu...
function XLZ4_compress (line 2661) | int XLZ4_compress(const char* src, char* dest, int srcSize)
function XLZ4_compress_limitedOutput_withState (line 2665) | int XLZ4_compress_limitedOutput_withState (void* state, const char* src,...
function XLZ4_compress_withState (line 2669) | int XLZ4_compress_withState (void* state, const char* src, char* dst, in...
function XLZ4_compress_limitedOutput_continue (line 2673) | int XLZ4_compress_limitedOutput_continue (XLZ4_stream_t* XLZ4_stream, co...
function XLZ4_compress_continue (line 2677) | int XLZ4_compress_continue (XLZ4_stream_t* XLZ4_stream, const char* sour...
function XLZ4_uncompress (line 2688) | int XLZ4_uncompress (const char* source, char* dest, int outputSize)
function XLZ4_uncompress_unknownOutputSize (line 2692) | int XLZ4_uncompress_unknownOutputSize (const char* source, char* dest, i...
function XLZ4_sizeofStreamState (line 2699) | int XLZ4_sizeofStreamState(void) { return sizeof(XLZ4_stream_t); }
function XLZ4_resetStreamState (line 2701) | int XLZ4_resetStreamState(void* state, char* inputBuffer)
FILE: Source/UHMP/IOCompress/lz4.h
type XLZ4_stream_t (line 312) | typedef union XLZ4_stream_u XLZ4_stream_t;
type XLZ4_streamDecode_t (line 410) | typedef union XLZ4_streamDecode_u XLZ4_streamDecode_t;
type XLZ4_i8 (line 660) | typedef int8_t XLZ4_i8;
type XLZ4_byte (line 661) | typedef uint8_t XLZ4_byte;
type XLZ4_u16 (line 662) | typedef uint16_t XLZ4_u16;
type XLZ4_u32 (line 663) | typedef uint32_t XLZ4_u32;
type XLZ4_i8 (line 665) | typedef signed char XLZ4_i8;
type XLZ4_byte (line 666) | typedef unsigned char XLZ4_byte;
type XLZ4_u16 (line 667) | typedef unsigned short XLZ4_u16;
type XLZ4_u32 (line 668) | typedef unsigned int XLZ4_u32;
type XLZ4_stream_t_internal (line 677) | typedef struct XLZ4_stream_t_internal XLZ4_stream_t_internal;
type XLZ4_stream_t_internal (line 678) | struct XLZ4_stream_t_internal {
type XLZ4_streamDecode_t_internal (line 717) | typedef struct {
FILE: Source/UHMP/UHMP.Build.cs
class UHMP (line 5) | public class UHMP : ModuleRules
method UHMP (line 7) | public UHMP(ReadOnlyTargetRules Target) : base(Target)
FILE: Source/UHMP/UHMPBlueprintFunctionLibrary.cpp
function FVector (line 69) | FVector UUHMPBlueprintFunctionLibrary::VectorClearZ(FVector Vector)
function FGenericTeamId (line 113) | FGenericTeamId UUHMPBlueprintFunctionLibrary::GetAITeamForPerceptionFilt...
function FVector (line 150) | FVector UUHMPBlueprintFunctionLibrary::FlyingTracking(FVector self_pos, ...
FILE: Source/UHMP/UHMPBlueprintFunctionLibrary.h
function UHMP_API (line 31) | UHMP_API UUHMPBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
FILE: Source/UHMPEditor.Target.cs
class UHMPEditorTarget (line 6) | public class UHMPEditorTarget : TargetRules
method UHMPEditorTarget (line 8) | public UHMPEditorTarget(TargetInfo Target) : base(Target)
FILE: Source/UHMPServer.Target.cs
class UHMPServerTarget (line 6) | public class UHMPServerTarget : TargetRules //Change this line according...
method UHMPServerTarget (line 8) | public UHMPServerTarget(TargetInfo Target) : base(Target) //Change thi...
FILE: build.py
function print亮绿 (line 6) | def print亮绿(*kw,**kargs):
FILE: onedrive_util.py
class Main (line 14) | class Main:
method __init__ (line 16) | def __init__(self, email : str, password : str, endpoint : str, type :...
method __root (line 23) | def __root(self):
method auth (line 28) | def auth(self):
method create_folder (line 40) | def create_folder(self, folder_name):
method get_folders (line 54) | def get_folders(self, folder_name : str = ""):
method get_files (line 67) | def get_files(self, folder_name : str = ""):
method download_file (line 80) | def download_file(self, file_url : str):
method download_files_from_folder (line 102) | def download_files_from_folder(self, folder_name : str = ""):
method check_exist_folder (line 117) | def check_exist_folder(self, folder_name):
method upload_file_on_folder (line 133) | def upload_file_on_folder(self, path_file_abs : str = "", folder_name ...
method upload_files_on_folder (line 156) | def upload_files_on_folder(self, folder_name_local : str = "", folder_...
class OneDrive (line 169) | class OneDrive(Main):
method __init__ (line 171) | def __init__(self, email, password, endpoint, type):
method share_folder (line 176) | def share_folder(self, folder_name : str = "", is_edit = False):
class SharePoint (line 187) | class SharePoint(Main):
method __init__ (line 189) | def __init__(self, email, password, endpoint, type):
method create_team_website_sharepoint (line 193) | def create_team_website_sharepoint(self, title : str, is_public = False):
method create_communication_website_sharepoint (line 206) | def create_communication_website_sharepoint(self, title : str):
FILE: upload_big_file.py
function get_onedrive_handle (line 8) | def get_onedrive_handle():
function add_file_to_onedrive (line 19) | def add_file_to_onedrive(session, key, path_file_name_local):
function get_current_version (line 49) | def get_current_version():
function shutil_rmtree (line 56) | def shutil_rmtree(p):
Condensed preview — 402 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,325K chars).
[
{
"path": ".gitignore",
"chars": 542,
"preview": "Binaries\nBuild\nDerivedDataCache\nIntermediate\nSaved\nTEMP\nTemp\nPy\n.vscode\n.vs\n*.VC.db\n*.opensdf\n*.opendb\n*.sdf\n*.sln\n*.suo"
},
{
"path": "BuildLinuxRender.py",
"chars": 1914,
"preview": "\"\"\"\nAfter you have installed the toolchain for cross-compilation, \nyou must open the solution for the engine in Rider (o"
},
{
"path": "BuildLinuxServer.py",
"chars": 1918,
"preview": "\"\"\"\nAfter you have installed the toolchain for cross-compilation, \nyou must open the solution for the engine in Rider (o"
},
{
"path": "BuildWindowsRender.py",
"chars": 1549,
"preview": "import subprocess, sys, shutil, time, os\n\nEnginePath = \"F:/UnrealEngine-4.27.2-release/Engine\"\nassert os.path.exists(Eng"
},
{
"path": "BuildWindowsServer.py",
"chars": 1553,
"preview": "import subprocess, sys, shutil, time, os\n\nEnginePath = \"F:/UnrealEngine-4.27.2-release/Engine\"\nassert os.path.exists(Eng"
},
{
"path": "Config/DefaultEditor.ini",
"chars": 1,
"preview": "\n"
},
{
"path": "Config/DefaultEditorPerProjectUserSettings.ini",
"chars": 1156,
"preview": "[/Script/BlueprintGraph.BlueprintEditorSettings]\nbDrawMidpointArrowsInBlueprints=False\nbShowGraphInstructionText=True\nbH"
},
{
"path": "Config/DefaultEngine.ini",
"chars": 17168,
"preview": "[/Script/EngineSettings.GameMapsSettings]\nGameDefaultMap=/Game/Maps/AutoEntry.AutoEntry\nEditorStartupMap=/Game/Maps/Uhma"
},
{
"path": "Config/DefaultGame.ini",
"chars": 3662,
"preview": "\n\n[/Script/EngineSettings.GeneralProjectSettings]\nProjectID=2433E6A446E19AAC82A379AF7E021098\n\n[StartupActions]\nbAddPacks"
},
{
"path": "Config/DefaultInput.ini",
"chars": 10034,
"preview": "[/Script/Engine.InputSettings]\n-AxisConfig=(AxisKeyName=\"Gamepad_LeftX\",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensi"
},
{
"path": "Docs/git_coop.md",
"chars": 1058,
"preview": "# 如何将修改同步到远程\n### 0. 首先关闭虚幻引擎!\n\n### 1. 打开vscode,切换到git页面\n<div align=\"center\">\n<img src=\"Docs/2022-10-17-17-14-13.png\" wid"
},
{
"path": "Docs/old_install_method/README.md",
"chars": 2240,
"preview": "# UHMAP\n\nDeveloped with Unreal Engine 4\n\n# How to install | 如何安装自定义版本的虚幻引擎\n另见视频:\nhttps://ageasga-my.sharepoint.com/:v:/g"
},
{
"path": "Please_Run_This_First_To_Fetch_Big_Files.py",
"chars": 921,
"preview": "import os, commentjson, shutil, subprocess, tqdm, shutil\nimport zipfile\nfrom modelscope import snapshot_download\ntry: os"
},
{
"path": "PythonExample/README.md",
"chars": 178,
"preview": "This demo program can connect to developing/compiled U-MAP environment to debug your simulation.\n\nThis program is a copy"
},
{
"path": "PythonExample/hmp_minimal_modules/.gitattributes",
"chars": 31,
"preview": "*.js linguist-detectable=false\n"
},
{
"path": "PythonExample/hmp_minimal_modules/.gitignore",
"chars": 3170,
"preview": "# Build and Release Folders\nbin-debug/\nbin-release/\n\n*/__pycache__\n[Oo]bj/\n[Bb]in/\n\n# Other files and folders\n.settings/"
},
{
"path": "PythonExample/hmp_minimal_modules/.gitmodules",
"chars": 161,
"preview": "[submodule \"THIRDPARTY/pymarl2/pymarl2src\"]\n\tpath = THIRDPARTY/pymarl2/pymarl2src\n\turl = https://github.com/binary-husky"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/common/alg_base.py",
"chars": 588,
"preview": "import os, time, torch, traceback\nimport numpy as np\nfrom config import GlobalConfig\nfrom UTIL.colorful import *\n\nclass "
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/common/attention.py",
"chars": 6603,
"preview": "import math\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nfrom torch.distributions.categorical impo"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/common/conc.py",
"chars": 5867,
"preview": "import math\nimport torch,time,random\nimport torch.nn as nn\nimport torch.nn.functional as F\nfrom UTIL.tensor_ops import m"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/common/dl_pool.py",
"chars": 2502,
"preview": "\"\"\"\n Author: Fu Qingxu,CASIA\n Description: deep learning sample manager\n\n\"\"\"\nimport torch\nimport numpy as np\n\nclas"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/common/his.py",
"chars": 605,
"preview": "import matplotlib.pyplot as plt\nimport numpy as np\nimport matplotlib\n\n# 设置matplotlib正常显示中文和负号\nmatplotlib.rcParams['font."
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/common/hyper_net.py",
"chars": 3919,
"preview": "from re import X\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nfrom UTIL.tensor_ops import my_view\n"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/common/logit2act.py",
"chars": 2270,
"preview": "import torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nfrom torch.distributions.categorical import Categoric"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/common/mlp.py",
"chars": 2441,
"preview": "import torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nfrom .norm import DynamicNorm\n\nclass SimpleMLP(nn.Mod"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/common/net_manifest.py",
"chars": 1355,
"preview": "\nimport torch.nn as nn\ndef weights_init(m):\n def init_Linear(m, final_layer=False):\n nn.init.orthogonal_(m.wei"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/common/norm.py",
"chars": 12014,
"preview": "\"\"\"\n CASIA, fuqingxu\n live vector normalization using pytorch, \n therefore the parameter of normalization (mean"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/common/pca.py",
"chars": 415,
"preview": "import numpy as np\n\ndef pca(samples, target_dim):\n assert len(samples.shape) == 2\n data = samples - np.mean(sample"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/common/ppo_sampler.py",
"chars": 6097,
"preview": "import torch, math\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport torch.optim as optim\nimport numpy as np\n"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/common/rl_alg_base.py",
"chars": 5712,
"preview": "import time\nfrom UTIL.tensor_ops import __hash__, repeat_at\nfrom UTIL.colorful import *\nfrom .alg_base import AlgorithmB"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/common/traj.py",
"chars": 4323,
"preview": "# cython: language_level=3\nimport numpy as np\nfrom UTIL.colorful import *\nfrom UTIL.tensor_ops import __hash__\n\nclass TR"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/common/traj_gae.py",
"chars": 12666,
"preview": "# cython: language_level=3\nimport numpy as np\nfrom ALGORITHM.common.traj import TRAJ_BASE\nimport copy\nfrom UTIL.colorful"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/common/traj_manager.py",
"chars": 0,
"preview": ""
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/example_foundation.py",
"chars": 583,
"preview": "import numpy as np\nimport copy\nimport math\nimport random\n\nclass ExampleFoundation():\n def __init__(self, n_agent, n_t"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/ccategorical.py",
"chars": 3528,
"preview": "from torch.distributions.categorical import Categorical\nimport torch\nfrom .foundation import AlgorithmConfig\nfrom UTIL.t"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/cython_func.pyx",
"chars": 1643,
"preview": "import numpy as np\ncimport numpy as np\ncimport cython\nfrom cython.parallel import prange\nnp.import_array()\nctypedef fuse"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/div_tree.py",
"chars": 5765,
"preview": "import torch\nimport torch.nn as nn\nimport numpy as np\nfrom ALGORITHM.common.mlp import LinearFinal\nfrom UTIL.tensor_ops "
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/foundation.py",
"chars": 18662,
"preview": "import os, time, torch, traceback, shutil, pickle, io\nimport numpy as np\nfrom UTIL.colorful import *\nfrom config import "
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/hete_assignment.py",
"chars": 2603,
"preview": "import copy\nimport numpy as np\nfrom UTIL.tensor_ops import my_view, __hash__, repeat_at, gather_righthand\nfrom .foundati"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/hete_net.py",
"chars": 15923,
"preview": "import torch, math, copy, pickle\nimport numpy as np\nimport torch.nn as nn\nfrom config import GlobalConfig as cfg\nfrom to"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/net.py",
"chars": 9053,
"preview": "import torch, math, copy\nimport numpy as np\nimport torch.nn as nn\nfrom torch.distributions.categorical import Categorica"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/ppo.py",
"chars": 10844,
"preview": "import torch, math, traceback\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport torch.optim as optim\nimport n"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/ppo_sampler.py",
"chars": 5681,
"preview": "import torch, math, traceback\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport torch.optim as optim\nimport n"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/shell_env.py",
"chars": 10724,
"preview": "import numpy as np\nfrom config import GlobalConfig\nfrom UTIL.colorful import *\nfrom UTIL.tensor_ops import my_view, __ha"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/stage_planner.py",
"chars": 3774,
"preview": "import math\nfrom .foundation import AlgorithmConfig\nfrom UTIL.colorful import *\n\nclass PolicyRsnConfig:\n resonance_st"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/hete_league_onenet_fix/trajectory.py",
"chars": 12034,
"preview": "# cython: language_level=3\nfrom config import GlobalConfig\nimport numpy as np\nfrom numpy.core.numeric import indices\nfro"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/my_ai/foundation.py",
"chars": 3413,
"preview": "import numpy as np\nfrom UTIL.colorful import *\nfrom UTIL.tensor_ops import my_view, __hash__\nfrom config import GlobalCo"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/ccategorical.py",
"chars": 3528,
"preview": "from torch.distributions.categorical import Categorical\nimport torch\nfrom .foundation import AlgorithmConfig\nfrom UTIL.t"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/cython_func.pyx",
"chars": 1653,
"preview": "import numpy as np\ncimport numpy as np\ncimport cython\nfrom cython.parallel import prange\nnp.import_array()\nctypedef fuse"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/div_tree.py",
"chars": 5765,
"preview": "import torch\nimport torch.nn as nn\nimport numpy as np\nfrom ALGORITHM.common.mlp import LinearFinal\nfrom UTIL.tensor_ops "
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/foundation.py",
"chars": 11651,
"preview": "import os, time, torch, traceback, shutil\nimport numpy as np\nfrom UTIL.colorful import *\nfrom config import GlobalConfig"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/net.py",
"chars": 6387,
"preview": "import torch, math, copy\nimport numpy as np\nimport torch.nn as nn\nfrom torch.distributions.categorical import Categorica"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/ppo.py",
"chars": 7902,
"preview": "import torch, math, traceback\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport torch.optim as optim\nimport n"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/ppo_sampler.py",
"chars": 5593,
"preview": "import torch, math, traceback\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport torch.optim as optim\nimport n"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/shell_env.py",
"chars": 9421,
"preview": "import numpy as np\nfrom config import GlobalConfig\nfrom UTIL.colorful import *\nfrom UTIL.tensor_ops import my_view, __ha"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/stage_planner.py",
"chars": 3413,
"preview": "import math\nfrom .foundation import AlgorithmConfig\nfrom UTIL.colorful import *\n\nclass PolicyRsnConfig:\n resonance_st"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/ppo_ma/trajectory.py",
"chars": 12034,
"preview": "# cython: language_level=3\nfrom config import GlobalConfig\nimport numpy as np\nfrom numpy.core.numeric import indices\nfro"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/random/actionset.py",
"chars": 10785,
"preview": "# ====================================================================\n# random moving \n# =============================="
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/random/foundation.py",
"chars": 6608,
"preview": "import numpy as np\nfrom UTIL.colorful import *\nfrom UTIL.tensor_ops import my_view, __hash__\nfrom config import GlobalCo"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/a_attackpost.py",
"chars": 3202,
"preview": "import numpy as np\nfrom UTIL.colorful import *\nfrom UTIL.tensor_ops import my_view, __hash__\nfrom config import GlobalCo"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/a_escape.py",
"chars": 4510,
"preview": "import numpy as np\nfrom UTIL.colorful import *\nfrom UTIL.tensor_ops import my_view, __hash__\nfrom config import GlobalCo"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/a_test_reproduce.py",
"chars": 6108,
"preview": "import numpy as np\nfrom UTIL.colorful import *\nfrom UTIL.tensor_ops import my_view, __hash__\nfrom config import GlobalCo"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/assignment.py",
"chars": 9607,
"preview": "import copy\nimport random\nimport numpy as np\nimport datetime\nimport time\nfrom ALGORITHM.script_ai.module_evaluation impo"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/blue_strategy.py",
"chars": 9622,
"preview": "import numpy as np\nimport math\n\n\ndef offense_combat(self_data, ally_agents_data, enemy_agents_data, key_points, blue_ali"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/decision.py",
"chars": 10858,
"preview": "import copy\nimport random\nimport numpy as np\nimport datetime\nimport time\nfrom ALGORITHM.script_ai.assignment import *\nfr"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/dummy.py",
"chars": 2653,
"preview": "import numpy as np\nfrom UTIL.tensor_ops import copy_clone\n\nclass DummyAlgConfig():\n reserve = \"\"\n\nclass DummyAlgorith"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/dummy_uhmap.py",
"chars": 22936,
"preview": "import numpy as np\nfrom UTIL.tensor_ops import copy_clone\nfrom MISSION.uhmap.actset_lookup import encode_action_as_digit"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/global_params.py",
"chars": 563,
"preview": "# # expel dist\n# DRIVE_AWAY_DIST = 1.2\n#\n# # defend dist\n# DEFEND_DIST = 2\n#\n# # retreat to the safe entrance\n# ATTA_RET"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/manual.py",
"chars": 19611,
"preview": "import numpy as np\nfrom UTIL.tensor_ops import my_view, copy_clone\ntry:\n from numba import jit\nexcept:\n from UTIL."
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/module_evaluation.py",
"chars": 16240,
"preview": "import copy\nimport random\nimport numpy as np\nimport datetime\nimport time\nimport math\n\n#态势评估模块\n#接口输入:全局状态信息,包括进攻方无人车各种状态,"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/red_strategy.py",
"chars": 10252,
"preview": "import numpy as np\nimport math\nfrom scipy.optimize import linear_sum_assignment\n\n\ndef defense_combat(self_data, ally_age"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/stance.py",
"chars": 18671,
"preview": "import copy\nimport random\nimport numpy as np\nimport datetime\nimport time\nimport math\n\n#态势评估模块\n#接口输入:全局状态信息,包括进攻方无人车各种状态,"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/uhmap_bb.py",
"chars": 8241,
"preview": "import copy\nfrom math import sqrt\nimport numpy as np\nfrom MISSION.uhmap.actset_lookup import encode_action_as_digits\nfro"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/uhmap_island.py",
"chars": 16356,
"preview": "from cmath import isinf, pi\nfrom turtle import done\nimport numpy as np\nimport math\nfrom MISSION.uhmap.actionset_v3 impor"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/uhmap_ls.py",
"chars": 12442,
"preview": "import copy\nimport numpy as np\nfrom UTIL.tensor_ops import distance_mat_between\nfrom scipy.optimize import linear_sum_as"
},
{
"path": "PythonExample/hmp_minimal_modules/ALGORITHM/script_ai/uhmap_ls_mp.py",
"chars": 13453,
"preview": "import copy, atexit\nimport numpy as np\nfrom UTIL.tensor_ops import distance_mat_between\nfrom scipy.optimize import linea"
},
{
"path": "PythonExample/hmp_minimal_modules/LICENSE",
"chars": 1067,
"preview": "MIT License\n\nCopyright (c) 2020 Ankur Deka\n\nPermission is hereby granted, free of charge, to any person obtaining a copy"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/common/base_env.py",
"chars": 2043,
"preview": "import numpy as np\nclass BaseEnv(object):\n def __init__(self, rank) -> None:\n self.observation_space = None\n "
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/env_router.py",
"chars": 6722,
"preview": "import_path_ref = {\n \"collective_assult\": (\"MISSION.collective_assult.collective_assult_parallel_run\", 'Scen"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/readme.md",
"chars": 8718,
"preview": "# Task Configuration Core Fields:\n\n## Parameter Internal Relationship\n* You may notice some configuration field ends wit"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/SubtaskCommonFn.py",
"chars": 20170,
"preview": "import json, copy, re, os, inspect, os\nimport numpy as np\nfrom UTIL.tensor_ops import my_view, repeat_at\nfrom ...common."
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapAdversial.py",
"chars": 18304,
"preview": "import json, copy, re, inspect, os\nimport numpy as np\nfrom UTIL.tensor_ops import my_view, repeat_at\nfrom ...common.base"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapAdversialConf.py",
"chars": 1928,
"preview": "\nclass SubTaskConfig():\n agent_list = [\n { \"team\": 0, \"type\": \"RLA_UAV_Support\", \"init_fn_name\": \"init"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapAttackPost.py",
"chars": 20668,
"preview": "import json, copy, re, os, inspect, os\nimport numpy as np\nfrom UTIL.tensor_ops import my_view, repeat_at\nfrom ...common."
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapAttackPostConf.py",
"chars": 2002,
"preview": "\nclass SubTaskConfig():\n agent_list = [\n { 'team':0, 'type':'PosAttacker', 'init_fn_name':'init_attack',"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapBreakingBad.py",
"chars": 17847,
"preview": "import json, os, subprocess, time, copy, re, inspect, os\nimport numpy as np\nfrom UTIL.tensor_ops import my_view, repeat_"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapBreakingBadConf.py",
"chars": 117,
"preview": "\nclass SubTaskConfig():\n empty = \"\"\n obs_vec_length = 23\n obs_n_entity = 11\n ActionFormat = 'Multi-Digit'"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapCarrier.py",
"chars": 16031,
"preview": "import json, copy, re, inspect, os\nimport numpy as np\nfrom UTIL.tensor_ops import my_view, repeat_at\nfrom ...common.base"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapCarrierConf.py",
"chars": 3734,
"preview": "\nclass SubTaskConfig():\n agent_list = [\n { \"team\": 0, \"type\": \"Carrier\", \"init_fn_name\": \"init"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapEscape.py",
"chars": 21069,
"preview": "import json, copy, re, os, inspect, os\nimport numpy as np\nfrom UTIL.tensor_ops import my_view, repeat_at\nfrom ...common."
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapEscapeConf.py",
"chars": 2247,
"preview": "\nclass SubTaskConfig():\n agent_list = [\n { 'team':0, 'type':'PosAttacker', 'init_fn_name':'init_attack',"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapFormation.py",
"chars": 13790,
"preview": "import json, copy, re, inspect, os\nimport numpy as np\nfrom UTIL.tensor_ops import my_view, repeat_at\nfrom ...common.base"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapFormationConf.py",
"chars": 3886,
"preview": "\nclass SubTaskConfig():\n agent_list = [\n { \"team\": 0, \"type\": \"Lv3_MomentumAgentWithHp\", \"init_fn_name\": \""
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapHuge.py",
"chars": 16147,
"preview": "import json, copy, re, os, inspect, os\nimport numpy as np\nfrom UTIL.tensor_ops import my_view, repeat_at\nfrom ...common."
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapHugeConf.py",
"chars": 1937,
"preview": "\nclass SubTaskConfig():\n agent_list = [\n { 'team':0, 'tid':0, 'type':'RLA_CAR_Laser', 'init_fn_name':'init_"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapIntercept.py",
"chars": 21151,
"preview": "import json, copy, re, os, inspect, os\nimport numpy as np\nfrom UTIL.tensor_ops import my_view, repeat_at\nfrom ...common."
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapInterceptConf.py",
"chars": 2559,
"preview": "\nclass SubTaskConfig():\n agent_list = [\n { 'team':0, 'type':'Landmark', 'init_fn_name':'init_landmark', },\n"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapJustAnIsland.py",
"chars": 20425,
"preview": "import json, copy, re, os, inspect, os\nimport numpy as np\nfrom UTIL.tensor_ops import my_view, repeat_at\nfrom ...common."
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapJustAnIslandConf.py",
"chars": 2383,
"preview": "\nclass SubTaskConfig():\n agent_list = [\n { 'team':0, 'tid':0, 'uid':0, 'n_team_agent':10, 'type':'PlaneAgen"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapLargeScale.py",
"chars": 16344,
"preview": "import json, copy, re, inspect, os\nimport numpy as np\nfrom UTIL.tensor_ops import my_view, repeat_at\nfrom ...common.base"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapLargeScaleConf.py",
"chars": 2558,
"preview": "\nclass SubTaskConfig():\n agent_list = [\n { 'team':0, 'tid':0, 'uid':0, 'n_team_agent':10, 'type':'RLA_CAR"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapPreyPredator.py",
"chars": 12892,
"preview": "import json, copy, re, os, inspect, os\nimport numpy as np\nfrom UTIL.tensor_ops import my_view, repeat_at\nfrom ...common."
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapPreyPredatorConf.py",
"chars": 2194,
"preview": "\nclass SubTaskConfig():\n agent_list = [\n { 'team':0, 'type':'Prey', 'init_fn_name':'init_ground', },\n "
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapReproduce.py",
"chars": 18140,
"preview": "import json, copy, re, os, inspect, os\nimport numpy as np\nfrom UTIL.tensor_ops import my_view, repeat_at\nfrom ...common."
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapReproduceConf.py",
"chars": 1352,
"preview": "\nclass SubTaskConfig():\n agent_list = [\n { 'team':0, 'type':'DummyAgent', 'init_fn_name':'init_attack', "
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapWaterdrop.py",
"chars": 13952,
"preview": "import json, copy, re, os, inspect, os\nimport numpy as np\nfrom UTIL.tensor_ops import my_view, repeat_at\nfrom ...common."
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/UhmapWaterdropConf.py",
"chars": 2132,
"preview": "\nclass SubTaskConfig():\n agent_list = [\n { 'team':0, 'type':'Ship', 'init_fn_name':'init_ship', }, # 0 \n"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/SubTasks/cython_func.pyx",
"chars": 2110,
"preview": "import numpy as np\ncimport numpy as np\ncimport cython\nnp.import_array()\n\n\nctypedef fused DTYPE_all_t:\n np.float32_t\n "
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/actionset.py",
"chars": 533,
"preview": "import numpy as np\nActDigitLen = 100\ndef strActionToDigits(act_string):\n t = [ord(c) for c in act_string]\n d_len ="
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/actionset_v3.py",
"chars": 533,
"preview": "import numpy as np\nActDigitLen = 100\ndef strActionToDigits(act_string):\n t = [ord(c) for c in act_string]\n d_len ="
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/actset_lookup.py",
"chars": 10728,
"preview": "import numpy as np\n\n# # # # # # # # # # # # # # # # # # # # # # #\n# # # # # Part 1, interface for RL # # # # # \n# # # # "
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/agent.py",
"chars": 1103,
"preview": "import numpy as np\nfrom .actset_lookup import agent_json2local_attrs\n\nclass Agent(object):\n def __init__(self, team, "
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/auto_download.py",
"chars": 1967,
"preview": "import os, commentjson, shutil, subprocess, tqdm, shutil, distutils\nfrom onedrivedownloader import download\n\ntry: os.mak"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/struct.cpp",
"chars": 6642,
"preview": "#pragma once\n\n#include \"CoreMinimal.h\"\n#include \"Containers/UnrealString.h\"\n#include \"XtensorAPIBPLibrary.h\"\n#include \"D"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/uhmap.md",
"chars": 6266,
"preview": "# Unreal HMAP (UHMAP) 混合多智能体平台-虚幻仿真模块\n\n## UHMAP 中对虚幻源代码的修改\n\n- (1) 将lz4的接口暴露在外,方便使用\n```\nF:\\UnrealSourceCode\\UnrealEngine-"
},
{
"path": "PythonExample/hmp_minimal_modules/MISSION/uhmap/uhmap_env_wrapper.py",
"chars": 15889,
"preview": "import json, os, subprocess, time, stat, platform, importlib\nimport numpy as np\nfrom UTIL.colorful import print蓝, print靛"
},
{
"path": "PythonExample/hmp_minimal_modules/README.md",
"chars": 502,
"preview": "# HMP:Hybrid Multi-agent Playground\n\nSee https://github.com/binary-husky/hmp2g\n\n\n\n# Run demo in Editor mode\n```\n(Open ma"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/auto_gpu.py",
"chars": 5642,
"preview": "\"\"\"\nCreated on Tue Aug 22 19:41:55 2017\n@author: Quantum Liu\n\"\"\"\n'''\nExample:\ngm=GPUManager()\nwith torch.cuda.device(gm."
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/batch_exp.py",
"chars": 7487,
"preview": "import subprocess\nimport threading\nimport copy, os\nimport time\nimport json\nfrom UTIL.network import get_host_ip\nfrom UTI"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/colorful.py",
"chars": 2393,
"preview": "import platform\nfrom sys import stdout\n\nif platform.system()==\"Linux\":\n pass\nelse: \n from colorama import init\n "
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/config_args.py",
"chars": 14172,
"preview": "import argparse, os, time, func_timeout\nfrom ast import Global\nfrom shutil import copyfile, copytree, ignore_patterns, r"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/data_struct.py",
"chars": 1136,
"preview": "\n\nclass UniqueList():\n def __init__(self, list_input=None):\n self._list = []\n if list_input is not None"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/exp_helper.py",
"chars": 5528,
"preview": "import paramiko, os, time\nfrom UTIL.colorful import print亮紫, print亮靛\nfrom UTIL.tensor_ops import __hash__\n\ndef singleton"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/fetch_multiserver.py",
"chars": 2161,
"preview": "from UTIL.exp_helper import get_ssh_sftp\nfrom UTIL.colorful import *\nimport time,os\n\n'''\nFetch experiment results from w"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/file_lock.py",
"chars": 460,
"preview": "# pip install filelock\nfrom filelock import FileLock as FileLockBase\n\nclass FileLock(FileLockBase):\n def __init__(sel"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/gpu_eater.py",
"chars": 4146,
"preview": "def validate_path():\n import os, sys\n dir_name = os.path.dirname(__file__)\n root_dir_assume = os.path.abspath(o"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/gpu_share.py",
"chars": 5684,
"preview": "import platform, os, torch, uuid, time, psutil, json, random\nfrom UTIL.network import UnixTcpClientP2P, UnixTcpServerP2P"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/hidden_print.py",
"chars": 267,
"preview": "import sys, os\nclass HiddenPrints:\n def __enter__(self):\n self._original_stdout = sys.stdout\n sys.stdou"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/hmp_daemon.py",
"chars": 3546,
"preview": "import time, requests, threading, os, atexit, psutil\nfrom UTIL.colorful import *\n\ndef kill_process(p):\n try:\n "
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/legacy/gpu_share_unfin.py",
"chars": 5341,
"preview": "import flock, os, torch, uuid, time, glob\nfrom atexit import register\n\nclass GpuShareUnit():\n def __init__(self, whic"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/mem_watcher_ue.py",
"chars": 2493,
"preview": "def validate_path():\n import os, sys\n # '/home/hmp/xx/hmp2g-heterogeneous-phase2/UTIL'\n dir_name = os.path.dirn"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/memleak_finder.py",
"chars": 108,
"preview": "from pympler import tracker\ntr = tracker.SummaryTracker()\n\ndef memdb_print_diff():\n tr.print_diff()\n\n "
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/mprofile.py",
"chars": 7327,
"preview": "import subprocess\nimport threading\nimport copy, os\nimport time\nimport json\nfrom UTIL.colorful import *\n# test sync to gi"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/mserver_launcher.sh",
"chars": 29,
"preview": "byobu new-session -d -s $USER"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/network.py",
"chars": 25252,
"preview": "import socket, threading, pickle, uuid, os, atexit, time, json, psutil\nfrom UTIL.file_lock import FileLock\nport_finder ="
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/pip_find_missing.py",
"chars": 9545,
"preview": "#coding=utf-8\nimport glob,os,sys,re,subprocess,platform\n\n\ndef print红(*kw):\n print(\"\\033[0;31m\",*kw,\"\\033[0m\")\ndef pri"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/shm_env.py",
"chars": 5752,
"preview": "import numpy as np\nimport time\nfrom MISSION.env_router import make_env_function\nfrom UTIL.colorful import print亮红\n\nN = l"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/shm_pool.pyx",
"chars": 18611,
"preview": "\"\"\"\n Author: Fu Qingxu,CASIA\n Description: Efficient parallel execting tool, \n it resembles Ray but:\n "
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/sync_exp.py",
"chars": 2970,
"preview": "import torch, time\nimport pickle, os\n\nfrom UTIL.colorful import print亮红\nfrom .tensor_ops import __hash__\nfrom UTIL.exp_h"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/tensor_ops.py",
"chars": 27783,
"preview": "import copy, json\nimport numpy as np\nfrom functools import lru_cache\n\ntry:\n import torch\n import torch.nn.function"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/tensor_ops_c.pyx",
"chars": 2682,
"preview": "import numpy as np\ncimport numpy as np\ncimport cython\nfrom cython.parallel import prange\nfrom libc.math cimport cos, ata"
},
{
"path": "PythonExample/hmp_minimal_modules/UTIL/win_pool.py",
"chars": 9395,
"preview": "\"\"\"\n Author: Fu Qingxu, CASIA\n Description: Efficient parallel execting tool, \n Less efficient than the shm_poo"
},
{
"path": "PythonExample/hmp_minimal_modules/VISUALIZE/README.md",
"chars": 7924,
"preview": "# Visual Hybrid Multi-Agent Playground (VHMAP 使用说明书)\n## 面向场景和特点\n面向场景:\n- 科研,尤其是多智能体强化学习领域\n- 3D演示\n- 娱乐\n\n应用特点:\n- Python接口简化"
},
{
"path": "PythonExample/hmp_minimal_modules/VISUALIZE/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "PythonExample/hmp_minimal_modules/VISUALIZE/color.html",
"chars": 40654,
"preview": "<div align=\"center\">\n <center>\n <div class=\"table-box\">\n <table id=\"color\" border=\"1\" cellspacing=\""
},
{
"path": "PythonExample/hmp_minimal_modules/VISUALIZE/mcom.py",
"chars": 19930,
"preview": "import os, copy, atexit, time, gzip, threading, setproctitle\nimport numpy as np\nfrom multiprocessing import Process\nfrom"
},
{
"path": "PythonExample/hmp_minimal_modules/VISUALIZE/mcom_def.py",
"chars": 1522,
"preview": "import os\n\nfn_names = [\n \"v2dx\", \"flash\", \"plot\", \"figure\", \"hold\", \"box\", \"pause\", \"clf\", \"xlim\", \"ylim\", \"xlabel\", "
},
{
"path": "PythonExample/hmp_minimal_modules/VISUALIZE/mcom_rec.py",
"chars": 15330,
"preview": "import os, fnmatch, matplotlib\nimport numpy as np\nfrom functools import lru_cache\nfrom config import GlobalConfig\n# 设置ma"
},
{
"path": "PythonExample/hmp_minimal_modules/VISUALIZE/mcom_replay.py",
"chars": 5469,
"preview": "# import os\n# print(os.getcwd())\nimport os, sys, gzip\nimport argparse\nfrom VISUALIZE.mcom import *\n\n# DEBUG_OOM = True\n\n"
},
{
"path": "PythonExample/hmp_minimal_modules/VISUALIZE/mcom_rt.py",
"chars": 22657,
"preview": "import os, copy, atexit, time, gzip, threading, zlib, asyncio\nimport numpy as np\nfrom colorama import init\nfrom multipro"
},
{
"path": "PythonExample/hmp_minimal_modules/VISUALIZE/mcom_test.py",
"chars": 967,
"preview": "def validate_path():\n import os, sys\n dir_name = os.path.dirname(__file__)\n root_dir_assume = os.path.abspath(o"
},
{
"path": "PythonExample/hmp_minimal_modules/VISUALIZE/mcom_v2d.py",
"chars": 19107,
"preview": "import numpy as np\nimport matplotlib\nimport matplotlib.pyplot as plt\nimport time\nplt.ion()\nV2dPlotFig = 3\n# import matpl"
},
{
"path": "PythonExample/hmp_minimal_modules/VISUALIZE/read_group_replay.ipynb",
"chars": 86358,
"preview": "{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 5,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n "
},
{
"path": "PythonExample/hmp_minimal_modules/VISUALIZE/seaborn_defaults.py",
"chars": 7821,
"preview": "# %matplotlib inline\nimport os\nimport copy\nimport subprocess\nimport matplotlib\nimport matplotlib.pyplot as plt\nimport pa"
},
{
"path": "PythonExample/hmp_minimal_modules/VISUALIZE/threejs_replay.py",
"chars": 1891,
"preview": "import os, sys\nimport argparse\nfrom VISUALIZE.mcom import *\nfrom VISUALIZE.mcom_replay import RecallProcessThreejs\nfrom "
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/Dockerfile",
"chars": 4109,
"preview": "# how to build: docker build --network=host -progress=plain -t hmp-from-scrach . \n\n# 此文件用于构建 HMAP + Starcraft(难易两个版本) + "
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/DockerfilePython311",
"chars": 4909,
"preview": "# how to build: docker build --network=host --progress=plain -t py311 . \n\n# 此文件用于构建 HMAP + Starcraft(难易两个版本) + 虚幻引擎组件\n# "
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/bashrc_suffix",
"chars": 828,
"preview": "ulimit -n 4096\nalias nv='watch -n 0.35 nvidia-smi'\nalias xrdp_reset='rm -f /var/run/xrdp/xrdp-sesman.pid'\nalias fq='prox"
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/examples/uhmap/AirAttack.jsonc",
"chars": 15273,
"preview": "{\n \"config.py->GlobalConfig\": {\n \"note\": \"xxxx\",\n \"env_name\": \"uhmap\",\n \"env_path\": \"MISSION.uhm"
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/examples/uhmap/AirShow.jsonc",
"chars": 13598,
"preview": "{\n \"config.py->GlobalConfig\": {\n \"note\": \"xxxx\",\n \"env_name\": \"uhmap\",\n \"env_path\": \"MISSION.uhm"
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/examples/uhmap/hlt+50vs50.jsonc",
"chars": 12648,
"preview": "{\n // --- Part1: config HMP core --- \n \"config.py->GlobalConfig\": {\n \"note\": \"z-hete-50\",// http://localhos"
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/examples/uhmap/ppoma+50vs50.jsonc",
"chars": 12450,
"preview": "{\n // --- Part1: config HMP core --- \n \"config.py->GlobalConfig\": {\n \"note\": \"ppoma-uhmap50vs50\",// http://"
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/examples/uhmap/ppoma+intercept.jsonc",
"chars": 2819,
"preview": "{\n // --- Part1: config HMP core --- \n \"config.py->GlobalConfig\": {\n \"note\": \"ppoma-intercept\",// http://lo"
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/examples/uhmap/ppoma+predatorprey.jsonc",
"chars": 2826,
"preview": "{\n // --- Part1: config HMP core --- \n \"config.py->GlobalConfig\": {\n \"note\": \"ppoma-predatorprey\",// http:/"
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/examples/uhmap/ppoma+uhmap10vs10hete.jsonc",
"chars": 4146,
"preview": "{\n \"config.py->GlobalConfig\": {\n \"note\": \"ppoma-uhmap10vs10\",\n \"env_name\": \"uhmap\",\n \"env_path\":"
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/examples/uhmap/ppoma_waterdrop.jsonc",
"chars": 1835,
"preview": "{\n // --- Part1: config HMP core --- \n \"config.py->GlobalConfig\": {\n \"note\": \"ppoma-waterdorp\",// http://lo"
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/examples/uhmap/qmix+uhmap10vs10hete.jsonc",
"chars": 4053,
"preview": "{\n \"config.py->GlobalConfig\": {\n \"note\": \"RVE-drone2-qmix-fixstate-run1\",\n \"env_name\": \"uhmap\",\n "
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/examples/uhmap/qmix+uhmap20vs20.jsonc",
"chars": 6216,
"preview": "{\n // --- Part1: config HMP core --- \n \"config.py->GlobalConfig\": {\n \"note\": \"qmix-uhmap50vs50\",//\n "
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/examples/uhmap/qmix+uhmap50vs50+debug.jsonc",
"chars": 11634,
"preview": "{\n // --- Part1: config HMP core --- \n \"config.py->GlobalConfig\": {\n \"note\": \"qmix-uhmap50vs50\",//\n "
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/examples/uhmap/qmix+uhmap50vs50.jsonc",
"chars": 10795,
"preview": "{\n // --- Part1: config HMP core --- \n \"config.py->GlobalConfig\": {\n \"note\": \"qmix-uhmap50vs50\",//\n "
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/examples/uhmap/qplex+uhmap10vs10hete.jsonc",
"chars": 4173,
"preview": "{\n \"config.py->GlobalConfig\": {\n \"note\": \"qplex-uhmap\",\n \"env_name\": \"uhmap\",\n \"env_path\": \"MISS"
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/examples/uhmap/qtran+uhmap10vs10hete.jsonc",
"chars": 4172,
"preview": "{\n \"config.py->GlobalConfig\": {\n \"note\": \"qtran-cat\",\n \"env_name\": \"uhmap\",\n \"env_path\": \"MISSIO"
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/examples/uhmap/random_waterdrop.jsonc",
"chars": 1819,
"preview": "{\n // --- Part1: config HMP core --- \n \"config.py->GlobalConfig\": {\n \"note\": \"ppoma-waterdorp\",// http://lo"
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/pip_requirement.md",
"chars": 796,
"preview": "# all pip requirements\n\nFirst of all, python version must >= 3.8, then, use pip to install following packages:\n\n## Group"
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/sc2checkversion",
"chars": 69029,
"preview": "from __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nfrom smac."
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/setup_docker.md",
"chars": 4518,
"preview": "\n# 1. Install nvidia docker runtime\nCuda is needed inside our docker container, which need toolkits from Nvidia for GPU "
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/setup_no_docker.md",
"chars": 1125,
"preview": "# setup on ubuntu without docker\n\nWarning! Always use docker if possible! \n\n如果可以选择,请一定先尝试docker方案\n\nThis file is written "
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/setup_ubuntu.md",
"chars": 1241,
"preview": "# 1. install docker \n```\nsudo apt update\nsudo apt install docker docker.io curl\n```\n\n# 2. intsall nvidia-runtime \n\n``` s"
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/setup_ue_docker.md",
"chars": 760,
"preview": "# Start up UE Docker Container | \nWarning! Unreal engine is included in this docker, 500GB disk space is needed.\n\n\n```sh"
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/ssh_pubkey.sh",
"chars": 277,
"preview": "key_name=home2\nmkdir -p ./TEMP\nwget --user=fuqingxu --password=PASSWORD_FOR_NEXTCLOUD http://cloud.fuqingxu.top:4080/"
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/test_examples.py",
"chars": 7586,
"preview": "def validate_path():\n import os, sys\n dir_name = os.path.dirname(__file__)\n root_dir_assume = os.path.abspath(o"
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/use_pymarl2.md",
"chars": 4684,
"preview": "# Using pymarl2 as Algorithm\n\n## step 1: clone hmap code\n```\ngit clone https://github.com/binary-husky/hmp2g.git\n\ncd hmp"
},
{
"path": "PythonExample/hmp_minimal_modules/ZDOCS/use_unreal_hmap.md",
"chars": 821,
"preview": "\n\n# Get Unreal-HMAP Binary Client (Win & Linux)\n\n- Method 1: \n``` python \nfrom MISSION.uhmap.auto_download import downlo"
},
{
"path": "PythonExample/hmp_minimal_modules/ZHECKPOINT/uhmap_hete10vs10/experiment_test.jsonc",
"chars": 6283,
"preview": "{\n \"config.py->GlobalConfig\": {\n \"note\": \"prob0d2-cos-run1\",\n \"env_name\": \"uhmap\",\n \"env_path\": "
},
{
"path": "PythonExample/hmp_minimal_modules/ZHECKPOINT/uhmap_hete10vs10/render_result.jsonc",
"chars": 4878,
"preview": "{\n \"config.py->GlobalConfig\": {\n \"note\": \"uhmap_hete10vs10\",\n \"env_name\": \"uhmap\",\n \"env_path\": "
},
{
"path": "PythonExample/hmp_minimal_modules/ZHECKPOINT/uhmap_hete10vs10/render_result_editor.jsonc",
"chars": 4864,
"preview": "{\n \"config.py->GlobalConfig\": {\n \"note\": \"uhmap_hete10vs10\",\n \"env_name\": \"uhmap\",\n \"env_path\": "
},
{
"path": "PythonExample/hmp_minimal_modules/ZHECKPOINT/uhmap_hete10vs10/render_result_editor2.jsonc",
"chars": 4862,
"preview": "{\n \"config.py->GlobalConfig\": {\n \"note\": \"uhmap_hete10vs10\",\n \"env_name\": \"uhmap\",\n \"env_path\": "
},
{
"path": "PythonExample/hmp_minimal_modules/agent_with_sensor.jsonc",
"chars": 3129,
"preview": "{\n \"config.py->GlobalConfig\": {\n \"note\": \"ppoma-uhmap10vs10\",\n \"env_name\": \"uhmap\",\n \"env_path\":"
},
{
"path": "PythonExample/hmp_minimal_modules/attack_post.jsonc",
"chars": 2069,
"preview": "{\n // --- Part1: config HMP core --- \n \"config.py->GlobalConfig\": {\n \"note\": \"random-attackpost\",// http://"
},
{
"path": "PythonExample/hmp_minimal_modules/carrier.jsonc",
"chars": 1920,
"preview": "{\n // --- Part1: config HMP core --- \n \"config.py->GlobalConfig\": {\n \"note\": \"random-attackpost\",// http://"
},
{
"path": "PythonExample/hmp_minimal_modules/config.py",
"chars": 7412,
"preview": "import time\nimport numpy as np\nfrom UTIL.colorful import *\nfrom UTIL.config_args import ChainVar\n\n\n\n'''\n GlobalConfig"
},
{
"path": "PythonExample/hmp_minimal_modules/cradle.ipynb",
"chars": 194384,
"preview": "{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 6,\n \"metadata\": {},\n \"outputs\": [\n {\n \"name\":"
},
{
"path": "PythonExample/hmp_minimal_modules/cradle.py",
"chars": 74,
"preview": "from UTIL.network import UnixTcpClientP2P, UnixTcpServerP2P\nimport time\n\n\n"
},
{
"path": "PythonExample/hmp_minimal_modules/escape.jsonc",
"chars": 1851,
"preview": "{\n // --- Part1: config HMP core --- \n \"config.py->GlobalConfig\": {\n \"note\": \"random-escape\",// http://loca"
},
{
"path": "PythonExample/hmp_minimal_modules/formation.jsonc",
"chars": 1926,
"preview": "{\n // --- Part1: config HMP core --- \n \"config.py->GlobalConfig\": {\n \"note\": \"random-attackpost\",// http://"
},
{
"path": "PythonExample/hmp_minimal_modules/main.py",
"chars": 3859,
"preview": "# This Python file uses the following encoding: utf-8\n\"\"\"\n Author: Fu Qingxu,CASIA\n Description: Enterance for eve"
},
{
"path": "PythonExample/hmp_minimal_modules/multi_server.py",
"chars": 3214,
"preview": "base = \"\"\"\n{\n \"config.py->GlobalConfig\": {\n \"note\": \"sc-MMM2-conc-db1\", // experiment note, also"
},
{
"path": "PythonExample/hmp_minimal_modules/multi_team.py",
"chars": 8602,
"preview": "import numpy as np\nimport importlib\nfrom UTIL.data_struct import UniqueList\n\nclass MMPlatform(object):\n\n def __init__"
},
{
"path": "PythonExample/hmp_minimal_modules/multi_team_parallel.py",
"chars": 11548,
"preview": "import numpy as np\nimport importlib, copy\nfrom UTIL.data_struct import UniqueList\nfrom UTIL.shm_pool import SmartPool\n\nc"
}
]
// ... and 202 more files (download for full content)
About this extraction
This page contains the full source code of the binary-husky/unreal-map GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 402 files (96.2 MB), approximately 558.6k tokens, and a symbol index with 1684 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.