Upload folder using huggingface_hub
Browse files- AIController.gd +2 -33
- FlyCam.gd +1 -1
- addons/godot_rl_agents/controller/ai_controller_2d.gd +76 -2
- addons/godot_rl_agents/controller/ai_controller_3d.gd +74 -2
- addons/godot_rl_agents/onnx/csharp/ONNXInference.cs +85 -75
- addons/godot_rl_agents/onnx/csharp/SessionConfigurator.cs +121 -96
- addons/godot_rl_agents/onnx/wrapper/ONNX_wrapper.gd +6 -1
- addons/godot_rl_agents/sensors/sensors_2d/ExampleRaycastSensor2D.tscn +1 -1
- addons/godot_rl_agents/sensors/sensors_3d/RaycastSensor3D.gd +7 -3
- addons/godot_rl_agents/sync.gd +15 -13
- bin/FPS.console.exe +0 -0
- bin/FPS.exe +2 -2
- bin/FPS.pck +2 -2
- bin/FPS.x86_64 +2 -2
- main.tscn +7 -7
- managers/camera_manager.gd +1 -1
- player.gd +1 -1
- player.tscn +2 -1
- project.godot +21 -99
- projectile.gd +2 -2
    	
        AIController.gd
    CHANGED
    
    | @@ -1,11 +1,7 @@ | |
| 1 | 
            -
            extends  | 
| 2 | 
            -
            class_name AIController
         | 
| 3 |  | 
| 4 | 
            -
            var _player : Player
         | 
| 5 |  | 
| 6 | 
             
            # ------------------ Godot RL Agents Logic ------------------------------------#
         | 
| 7 | 
            -
            var heuristic := "human"
         | 
| 8 | 
            -
            var done := false
         | 
| 9 | 
             
            # example actions
         | 
| 10 |  | 
| 11 | 
             
            var movement_action := Vector2(0.0, 0.0)
         | 
| @@ -13,10 +9,7 @@ var look_action := Vector2(0.0, 0.0) | |
| 13 | 
             
            var jump_action := false
         | 
| 14 | 
             
            var shoot_action := false
         | 
| 15 |  | 
| 16 | 
            -
            var needs_reset := false
         | 
| 17 | 
            -
            var reward := 0.0
         | 
| 18 | 
             
            var n_steps_without_positive_reward = 0
         | 
| 19 | 
            -
            var n_steps = 0
         | 
| 20 |  | 
| 21 | 
             
            @onready var wide_raycast_sensor = $WideRaycastSensor
         | 
| 22 | 
             
            @onready var narrow_raycast_sensor = $NarrowRaycastSensor
         | 
| @@ -43,10 +36,6 @@ func reset(): | |
| 43 | 
             
            	n_steps_without_positive_reward = 0
         | 
| 44 | 
             
            	n_steps = 0
         | 
| 45 |  | 
| 46 | 
            -
            func reset_if_done():
         | 
| 47 | 
            -
            	if done:
         | 
| 48 | 
            -
            		reset()
         | 
| 49 | 
            -
             | 
| 50 | 
             
            func get_obs():
         | 
| 51 | 
             
            	var obs = []
         | 
| 52 | 
             
            	obs.append_array(wide_raycast_sensor.get_observation())
         | 
| @@ -64,27 +53,12 @@ func get_reward(): | |
| 64 | 
             
            		n_steps_without_positive_reward = max(0, n_steps_without_positive_reward)
         | 
| 65 | 
             
            	return total_reward
         | 
| 66 |  | 
| 67 | 
            -
            func zero_reward():
         | 
| 68 | 
            -
            	reward = 0.0
         | 
| 69 |  | 
| 70 | 
             
            func shaping_reward():
         | 
| 71 | 
             
            	var s_reward = 0.0
         | 
| 72 | 
             
            	return s_reward
         | 
| 73 |  | 
| 74 |  | 
| 75 | 
            -
            func set_heuristic(h):
         | 
| 76 | 
            -
            	# sets the heuristic from "human" or "model" nothing to change here
         | 
| 77 | 
            -
            	heuristic = h
         | 
| 78 | 
            -
               
         | 
| 79 | 
            -
            func get_obs_space():
         | 
| 80 | 
            -
            	var obs = get_obs()
         | 
| 81 | 
            -
            	return {
         | 
| 82 | 
            -
            		"obs": {
         | 
| 83 | 
            -
            			"size": [len(obs["obs"])],
         | 
| 84 | 
            -
            			"space": "box"
         | 
| 85 | 
            -
            		},
         | 
| 86 | 
            -
            	}
         | 
| 87 | 
            -
             | 
| 88 | 
             
            func get_action_space():
         | 
| 89 | 
             
            	return {
         | 
| 90 | 
             
            		"movement_action" : {
         | 
| @@ -105,11 +79,6 @@ func get_action_space(): | |
| 105 | 
             
            		},
         | 
| 106 | 
             
            	}
         | 
| 107 |  | 
| 108 | 
            -
            func get_done():
         | 
| 109 | 
            -
            	return done
         | 
| 110 | 
            -
            	
         | 
| 111 | 
            -
            func set_done_false():
         | 
| 112 | 
            -
            	done = false
         | 
| 113 |  | 
| 114 | 
             
            func set_action(action):	
         | 
| 115 | 
             
            	movement_action = Vector2(clamp(action["movement_action"][0],-1.0,1.0), clamp(action["movement_action"][1],-1.0,1.0))
         | 
| @@ -118,7 +87,7 @@ func set_action(action): | |
| 118 | 
             
            	shoot_action = action["shoot_action"] == 1
         | 
| 119 |  | 
| 120 |  | 
| 121 | 
            -
            func _physics_process( | 
| 122 | 
             
            	n_steps += 1
         | 
| 123 | 
             
            	if n_steps > 4000:
         | 
| 124 | 
             
            		_player.needs_respawn = true
         | 
|  | |
| 1 | 
            +
            extends AIController3D
         | 
|  | |
| 2 |  | 
|  | |
| 3 |  | 
| 4 | 
             
            # ------------------ Godot RL Agents Logic ------------------------------------#
         | 
|  | |
|  | |
| 5 | 
             
            # example actions
         | 
| 6 |  | 
| 7 | 
             
            var movement_action := Vector2(0.0, 0.0)
         | 
|  | |
| 9 | 
             
            var jump_action := false
         | 
| 10 | 
             
            var shoot_action := false
         | 
| 11 |  | 
|  | |
|  | |
| 12 | 
             
            var n_steps_without_positive_reward = 0
         | 
|  | |
| 13 |  | 
| 14 | 
             
            @onready var wide_raycast_sensor = $WideRaycastSensor
         | 
| 15 | 
             
            @onready var narrow_raycast_sensor = $NarrowRaycastSensor
         | 
|  | |
| 36 | 
             
            	n_steps_without_positive_reward = 0
         | 
| 37 | 
             
            	n_steps = 0
         | 
| 38 |  | 
|  | |
|  | |
|  | |
|  | |
| 39 | 
             
            func get_obs():
         | 
| 40 | 
             
            	var obs = []
         | 
| 41 | 
             
            	obs.append_array(wide_raycast_sensor.get_observation())
         | 
|  | |
| 53 | 
             
            		n_steps_without_positive_reward = max(0, n_steps_without_positive_reward)
         | 
| 54 | 
             
            	return total_reward
         | 
| 55 |  | 
|  | |
|  | |
| 56 |  | 
| 57 | 
             
            func shaping_reward():
         | 
| 58 | 
             
            	var s_reward = 0.0
         | 
| 59 | 
             
            	return s_reward
         | 
| 60 |  | 
| 61 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 62 | 
             
            func get_action_space():
         | 
| 63 | 
             
            	return {
         | 
| 64 | 
             
            		"movement_action" : {
         | 
|  | |
| 79 | 
             
            		},
         | 
| 80 | 
             
            	}
         | 
| 81 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
| 82 |  | 
| 83 | 
             
            func set_action(action):	
         | 
| 84 | 
             
            	movement_action = Vector2(clamp(action["movement_action"][0],-1.0,1.0), clamp(action["movement_action"][1],-1.0,1.0))
         | 
|  | |
| 87 | 
             
            	shoot_action = action["shoot_action"] == 1
         | 
| 88 |  | 
| 89 |  | 
| 90 | 
            +
            func _physics_process(_delta):
         | 
| 91 | 
             
            	n_steps += 1
         | 
| 92 | 
             
            	if n_steps > 4000:
         | 
| 93 | 
             
            		_player.needs_respawn = true
         | 
    	
        FlyCam.gd
    CHANGED
    
    | @@ -12,7 +12,7 @@ func set_control(value): | |
| 12 | 
             
            	$Camera3D.current = value
         | 
| 13 |  | 
| 14 |  | 
| 15 | 
            -
            func _process( | 
| 16 | 
             
            	var input_dir = Input.get_vector("move_left", "move_right", "move_forward", "move_backward")
         | 
| 17 | 
             
            	var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
         | 
| 18 | 
             
            	direction.y =  Input.get_axis("cam_down", "cam_up")
         | 
|  | |
| 12 | 
             
            	$Camera3D.current = value
         | 
| 13 |  | 
| 14 |  | 
| 15 | 
            +
            func _process(_delta):
         | 
| 16 | 
             
            	var input_dir = Input.get_vector("move_left", "move_right", "move_forward", "move_backward")
         | 
| 17 | 
             
            	var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
         | 
| 18 | 
             
            	direction.y =  Input.get_axis("cam_down", "cam_up")
         | 
    	
        addons/godot_rl_agents/controller/ai_controller_2d.gd
    CHANGED
    
    | @@ -1,8 +1,82 @@ | |
| 1 | 
            -
            extends  | 
| 2 | 
             
            class_name AIController2D
         | 
| 3 |  | 
| 4 | 
            -
             | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 5 | 
             
            var _player: Node2D
         | 
| 6 |  | 
|  | |
|  | |
|  | |
| 7 | 
             
            func init(player: Node2D):
         | 
| 8 | 
             
            	_player = player
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            extends Node2D
         | 
| 2 | 
             
            class_name AIController2D
         | 
| 3 |  | 
| 4 | 
            +
            @export var reset_after := 1000
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            var heuristic := "human"
         | 
| 7 | 
            +
            var done := false
         | 
| 8 | 
            +
            var reward := 0.0
         | 
| 9 | 
            +
            var n_steps := 0
         | 
| 10 | 
            +
            var needs_reset := false
         | 
| 11 | 
            +
             | 
| 12 | 
             
            var _player: Node2D
         | 
| 13 |  | 
| 14 | 
            +
            func _ready():
         | 
| 15 | 
            +
            	add_to_group("AGENT")
         | 
| 16 | 
            +
            	
         | 
| 17 | 
             
            func init(player: Node2D):
         | 
| 18 | 
             
            	_player = player
         | 
| 19 | 
            +
            	
         | 
| 20 | 
            +
            #-- Methods that need implementing using the "extend script" option in Godot --#
         | 
| 21 | 
            +
            func get_obs() -> Dictionary:
         | 
| 22 | 
            +
            	assert(false, "the get_obs method is not implemented when extending from ai_controller") 
         | 
| 23 | 
            +
            	return {"obs":[]}
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            func get_reward() -> float:	
         | 
| 26 | 
            +
            	assert(false, "the get_reward method is not implemented when extending from ai_controller") 
         | 
| 27 | 
            +
            	return 0.0
         | 
| 28 | 
            +
            	
         | 
| 29 | 
            +
            func get_action_space() -> Dictionary:
         | 
| 30 | 
            +
            	assert(false, "the get get_action_space method is not implemented when extending from ai_controller") 
         | 
| 31 | 
            +
            	return {
         | 
| 32 | 
            +
            		"example_actions_continous" : {
         | 
| 33 | 
            +
            			"size": 2,
         | 
| 34 | 
            +
            			"action_type": "continuous"
         | 
| 35 | 
            +
            		},
         | 
| 36 | 
            +
            		"example_actions_discrete" : {
         | 
| 37 | 
            +
            			"size": 2,
         | 
| 38 | 
            +
            			"action_type": "discrete"
         | 
| 39 | 
            +
            		},
         | 
| 40 | 
            +
            		}
         | 
| 41 | 
            +
            	
         | 
| 42 | 
            +
            func set_action(action) -> void:	
         | 
| 43 | 
            +
            	assert(false, "the get set_action method is not implemented when extending from ai_controller") 	
         | 
| 44 | 
            +
            # -----------------------------------------------------------------------------#
         | 
| 45 | 
            +
            	
         | 
| 46 | 
            +
            func _physics_process(delta):
         | 
| 47 | 
            +
            	n_steps += 1
         | 
| 48 | 
            +
            	if n_steps > reset_after:
         | 
| 49 | 
            +
            		needs_reset = true
         | 
| 50 | 
            +
            		
         | 
| 51 | 
            +
            func get_obs_space():
         | 
| 52 | 
            +
            	# may need overriding if the obs space is complex
         | 
| 53 | 
            +
            	var obs = get_obs()
         | 
| 54 | 
            +
            	return {
         | 
| 55 | 
            +
            		"obs": {
         | 
| 56 | 
            +
            			"size": [len(obs["obs"])],
         | 
| 57 | 
            +
            			"space": "box"
         | 
| 58 | 
            +
            		},
         | 
| 59 | 
            +
            	}
         | 
| 60 | 
            +
             | 
| 61 | 
            +
            func reset():
         | 
| 62 | 
            +
            	n_steps = 0
         | 
| 63 | 
            +
            	needs_reset = false
         | 
| 64 | 
            +
             | 
| 65 | 
            +
            func reset_if_done():
         | 
| 66 | 
            +
            	if done:
         | 
| 67 | 
            +
            		reset()
         | 
| 68 | 
            +
            		
         | 
| 69 | 
            +
            func set_heuristic(h):
         | 
| 70 | 
            +
            	# sets the heuristic from "human" or "model" nothing to change here
         | 
| 71 | 
            +
            	heuristic = h
         | 
| 72 | 
            +
             | 
| 73 | 
            +
            func get_done():
         | 
| 74 | 
            +
            	return done
         | 
| 75 | 
            +
            	
         | 
| 76 | 
            +
            func set_done_false():
         | 
| 77 | 
            +
            	done = false
         | 
| 78 | 
            +
             | 
| 79 | 
            +
            func zero_reward():
         | 
| 80 | 
            +
            	reward = 0.0
         | 
| 81 | 
            +
            	
         | 
| 82 | 
            +
             | 
    	
        addons/godot_rl_agents/controller/ai_controller_3d.gd
    CHANGED
    
    | @@ -1,8 +1,80 @@ | |
| 1 | 
            -
            extends  | 
| 2 | 
             
            class_name AIController3D
         | 
| 3 |  | 
| 4 | 
            -
             | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 5 | 
             
            var _player: Node3D
         | 
| 6 |  | 
|  | |
|  | |
|  | |
| 7 | 
             
            func init(player: Node3D):
         | 
| 8 | 
             
            	_player = player
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            extends Node3D
         | 
| 2 | 
             
            class_name AIController3D
         | 
| 3 |  | 
| 4 | 
            +
            @export var reset_after := 1000
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            var heuristic := "human"
         | 
| 7 | 
            +
            var done := false
         | 
| 8 | 
            +
            var reward := 0.0
         | 
| 9 | 
            +
            var n_steps := 0
         | 
| 10 | 
            +
            var needs_reset := false
         | 
| 11 | 
            +
             | 
| 12 | 
             
            var _player: Node3D
         | 
| 13 |  | 
| 14 | 
            +
            func _ready():
         | 
| 15 | 
            +
            	add_to_group("AGENT")
         | 
| 16 | 
            +
            	
         | 
| 17 | 
             
            func init(player: Node3D):
         | 
| 18 | 
             
            	_player = player
         | 
| 19 | 
            +
            	
         | 
| 20 | 
            +
            #-- Methods that need implementing using the "extend script" option in Godot --#
         | 
| 21 | 
            +
            func get_obs() -> Dictionary:
         | 
| 22 | 
            +
            	assert(false, "the get_obs method is not implemented when extending from ai_controller") 
         | 
| 23 | 
            +
            	return {"obs":[]}
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            func get_reward() -> float:	
         | 
| 26 | 
            +
            	assert(false, "the get_reward method is not implemented when extending from ai_controller") 
         | 
| 27 | 
            +
            	return 0.0
         | 
| 28 | 
            +
            	
         | 
| 29 | 
            +
            func get_action_space() -> Dictionary:
         | 
| 30 | 
            +
            	assert(false, "the get get_action_space method is not implemented when extending from ai_controller") 
         | 
| 31 | 
            +
            	return {
         | 
| 32 | 
            +
            		"example_actions_continous" : {
         | 
| 33 | 
            +
            			"size": 2,
         | 
| 34 | 
            +
            			"action_type": "continuous"
         | 
| 35 | 
            +
            		},
         | 
| 36 | 
            +
            		"example_actions_discrete" : {
         | 
| 37 | 
            +
            			"size": 2,
         | 
| 38 | 
            +
            			"action_type": "discrete"
         | 
| 39 | 
            +
            		},
         | 
| 40 | 
            +
            		}
         | 
| 41 | 
            +
            	
         | 
| 42 | 
            +
            func set_action(action) -> void:	
         | 
| 43 | 
            +
            	assert(false, "the get set_action method is not implemented when extending from ai_controller") 	
         | 
| 44 | 
            +
            # -----------------------------------------------------------------------------#
         | 
| 45 | 
            +
            	
         | 
| 46 | 
            +
            func _physics_process(delta):
         | 
| 47 | 
            +
            	n_steps += 1
         | 
| 48 | 
            +
            	if n_steps > reset_after:
         | 
| 49 | 
            +
            		needs_reset = true
         | 
| 50 | 
            +
            		
         | 
| 51 | 
            +
            func get_obs_space():
         | 
| 52 | 
            +
            	# may need overriding if the obs space is complex
         | 
| 53 | 
            +
            	var obs = get_obs()
         | 
| 54 | 
            +
            	return {
         | 
| 55 | 
            +
            		"obs": {
         | 
| 56 | 
            +
            			"size": [len(obs["obs"])],
         | 
| 57 | 
            +
            			"space": "box"
         | 
| 58 | 
            +
            		},
         | 
| 59 | 
            +
            	}
         | 
| 60 | 
            +
             | 
| 61 | 
            +
            func reset():
         | 
| 62 | 
            +
            	n_steps = 0
         | 
| 63 | 
            +
            	needs_reset = false
         | 
| 64 | 
            +
             | 
| 65 | 
            +
            func reset_if_done():
         | 
| 66 | 
            +
            	if done:
         | 
| 67 | 
            +
            		reset()
         | 
| 68 | 
            +
            		
         | 
| 69 | 
            +
            func set_heuristic(h):
         | 
| 70 | 
            +
            	# sets the heuristic from "human" or "model" nothing to change here
         | 
| 71 | 
            +
            	heuristic = h
         | 
| 72 | 
            +
             | 
| 73 | 
            +
            func get_done():
         | 
| 74 | 
            +
            	return done
         | 
| 75 | 
            +
            	
         | 
| 76 | 
            +
            func set_done_false():
         | 
| 77 | 
            +
            	done = false
         | 
| 78 | 
            +
             | 
| 79 | 
            +
            func zero_reward():
         | 
| 80 | 
            +
            	reward = 0.0
         | 
    	
        addons/godot_rl_agents/onnx/csharp/ONNXInference.cs
    CHANGED
    
    | @@ -1,93 +1,103 @@ | |
| 1 | 
             
            using Godot;
         | 
| 2 | 
            -
            using System.Collections.Generic;
         | 
| 3 | 
            -
            using System.Linq;
         | 
| 4 | 
             
            using Microsoft.ML.OnnxRuntime;
         | 
| 5 | 
             
            using Microsoft.ML.OnnxRuntime.Tensors;
         | 
|  | |
|  | |
| 6 |  | 
| 7 | 
            -
            namespace GodotONNX | 
| 8 | 
            -
            	/// <include file='docs/ONNXInference.xml' path='docs/members[@name="ONNXInference"]/ONNXInference/*'/>
         | 
| 9 | 
            -
             	public partial class ONNXInference : Node
         | 
| 10 | 
             
            {
         | 
| 11 | 
            -
             | 
| 12 | 
            -
            	 | 
| 13 | 
            -
            	 | 
| 14 | 
            -
            	/// Path to the ONNX model. Use Initialize to change it. 
         | 
| 15 | 
            -
            	/// </summary>
         | 
| 16 | 
            -
            	private string modelPath;
         | 
| 17 | 
            -
            	private int batchSize;
         | 
| 18 |  | 
| 19 | 
            -
             | 
|  | |
|  | |
|  | |
|  | |
|  | |
| 20 |  | 
| 21 | 
            -
             | 
| 22 | 
            -
            /// <include file='docs/ONNXInference.xml' path='docs/members[@name="ONNXInference"]/Initialize/*'/>
         | 
| 23 | 
            -
            	public void Initialize(string Path, int BatchSize)
         | 
| 24 | 
            -
            	{
         | 
| 25 | 
            -
            		modelPath = Path;
         | 
| 26 | 
            -
            		batchSize = BatchSize;
         | 
| 27 | 
            -
            		SessionConfigurator.SystemCheck();
         | 
| 28 | 
            -
            		SessionOpt = SessionConfigurator.GetSessionOptions();
         | 
| 29 | 
            -
            		session = LoadModel(modelPath);
         | 
| 30 |  | 
| 31 | 
            -
             | 
| 32 | 
            -
            /// <include file='docs/ONNXInference.xml' path='docs/members[@name="ONNXInference"]/ | 
| 33 | 
            -
             | 
| 34 | 
            -
            	{
         | 
| 35 | 
            -
            		//Current model: Any (Godot Rl Agents)
         | 
| 36 | 
            -
            		//Expects a tensor of shape [batch_size, input_size] type float named obs and a tensor of shape [batch_size] type float named state_ins
         | 
| 37 | 
            -
            		
         | 
| 38 | 
            -
            		//Fill the input tensors
         | 
| 39 | 
            -
            		// create span from inputSize
         | 
| 40 | 
            -
            		var span = new float[obs.Count]; //There's probably a better way to do this
         | 
| 41 | 
            -
            		for (int i = 0; i < obs.Count; i++)
         | 
| 42 | 
             
            		{
         | 
| 43 | 
            -
            			 | 
|  | |
|  | |
|  | |
|  | |
| 44 | 
             
            		}
         | 
| 45 | 
            -
             | 
| 46 | 
            -
            		 | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 47 | 
             
            			{
         | 
| 48 | 
             
            			NamedOnnxValue.CreateFromTensor("obs", new DenseTensor<float>(span, new int[] { batchSize, obs.Count })),
         | 
| 49 | 
             
            			NamedOnnxValue.CreateFromTensor("state_ins", new DenseTensor<float>(new float[] { state_ins }, new int[] { batchSize }))
         | 
| 50 | 
            -
            			}; | 
| 51 | 
            -
             | 
| 52 |  | 
| 53 | 
            -
            			IDisposableReadOnlyCollection<DisposableNamedOnnxValue> results;
         | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
            			 | 
| 57 | 
            -
             | 
| 58 | 
            -
             | 
| 59 | 
            -
            			 | 
| 60 | 
            -
            			 | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
|  | |
|  | |
| 69 |  | 
| 70 | 
            -
             | 
| 71 | 
            -
            			 | 
| 72 | 
            -
             | 
|  | |
| 73 |  | 
| 74 | 
            -
             | 
| 75 | 
            -
            			 | 
| 76 | 
            -
             | 
|  | |
| 77 |  | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 86 | 
            -
             | 
| 87 | 
            -
            		 | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 92 | 
             
            	}
         | 
| 93 | 
            -
            } | 
|  | |
| 1 | 
             
            using Godot;
         | 
|  | |
|  | |
| 2 | 
             
            using Microsoft.ML.OnnxRuntime;
         | 
| 3 | 
             
            using Microsoft.ML.OnnxRuntime.Tensors;
         | 
| 4 | 
            +
            using System.Collections.Generic;
         | 
| 5 | 
            +
            using System.Linq;
         | 
| 6 |  | 
| 7 | 
            +
            namespace GodotONNX
         | 
|  | |
|  | |
| 8 | 
             
            {
         | 
| 9 | 
            +
            	/// <include file='docs/ONNXInference.xml' path='docs/members[@name="ONNXInference"]/ONNXInference/*'/>
         | 
| 10 | 
            +
            	public partial class ONNXInference : GodotObject
         | 
| 11 | 
            +
            	{
         | 
|  | |
|  | |
|  | |
|  | |
| 12 |  | 
| 13 | 
            +
            		private InferenceSession session;
         | 
| 14 | 
            +
            		/// <summary>
         | 
| 15 | 
            +
            		/// Path to the ONNX model. Use Initialize to change it. 
         | 
| 16 | 
            +
            		/// </summary>
         | 
| 17 | 
            +
            		private string modelPath;
         | 
| 18 | 
            +
            		private int batchSize;
         | 
| 19 |  | 
| 20 | 
            +
            		private SessionOptions SessionOpt;
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 21 |  | 
| 22 | 
            +
            		//init function
         | 
| 23 | 
            +
            		/// <include file='docs/ONNXInference.xml' path='docs/members[@name="ONNXInference"]/Initialize/*'/>
         | 
| 24 | 
            +
            		public void Initialize(string Path, int BatchSize)
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 25 | 
             
            		{
         | 
| 26 | 
            +
            			modelPath = Path;
         | 
| 27 | 
            +
            			batchSize = BatchSize;
         | 
| 28 | 
            +
                        SessionOpt = SessionConfigurator.MakeConfiguredSessionOptions();
         | 
| 29 | 
            +
                        session = LoadModel(modelPath);
         | 
| 30 | 
            +
             | 
| 31 | 
             
            		}
         | 
| 32 | 
            +
            		/// <include file='docs/ONNXInference.xml' path='docs/members[@name="ONNXInference"]/Run/*'/>
         | 
| 33 | 
            +
            		public Godot.Collections.Dictionary<string, Godot.Collections.Array<float>> RunInference(Godot.Collections.Array<float> obs, int state_ins)
         | 
| 34 | 
            +
            		{
         | 
| 35 | 
            +
            			//Current model: Any (Godot Rl Agents)
         | 
| 36 | 
            +
            			//Expects a tensor of shape [batch_size, input_size] type float named obs and a tensor of shape [batch_size] type float named state_ins
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            			//Fill the input tensors
         | 
| 39 | 
            +
            			// create span from inputSize
         | 
| 40 | 
            +
            			var span = new float[obs.Count]; //There's probably a better way to do this
         | 
| 41 | 
            +
            			for (int i = 0; i < obs.Count; i++)
         | 
| 42 | 
            +
            			{
         | 
| 43 | 
            +
            				span[i] = obs[i];
         | 
| 44 | 
            +
            			}
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            			IReadOnlyCollection<NamedOnnxValue> inputs = new List<NamedOnnxValue>
         | 
| 47 | 
             
            			{
         | 
| 48 | 
             
            			NamedOnnxValue.CreateFromTensor("obs", new DenseTensor<float>(span, new int[] { batchSize, obs.Count })),
         | 
| 49 | 
             
            			NamedOnnxValue.CreateFromTensor("state_ins", new DenseTensor<float>(new float[] { state_ins }, new int[] { batchSize }))
         | 
| 50 | 
            +
            			};
         | 
| 51 | 
            +
            			IReadOnlyCollection<string> outputNames = new List<string> { "output", "state_outs" }; //ONNX is sensible to these names, as well as the input names
         | 
| 52 |  | 
| 53 | 
            +
            			IDisposableReadOnlyCollection<DisposableNamedOnnxValue> results; 
         | 
| 54 | 
            +
            			//We do not use "using" here so we get a better exception explaination later
         | 
| 55 | 
            +
            			try
         | 
| 56 | 
            +
            			{
         | 
| 57 | 
            +
            				results = session.Run(inputs, outputNames);
         | 
| 58 | 
            +
            			}
         | 
| 59 | 
            +
            			catch (OnnxRuntimeException e)
         | 
| 60 | 
            +
            			{
         | 
| 61 | 
            +
            				//This error usually means that the model is not compatible with the input, beacause of the input shape (size)
         | 
| 62 | 
            +
            				GD.Print("Error at inference: ", e);
         | 
| 63 | 
            +
            				return null;
         | 
| 64 | 
            +
            			}
         | 
| 65 | 
            +
            			//Can't convert IEnumerable<float> to Variant, so we have to convert it to an array or something
         | 
| 66 | 
            +
            			Godot.Collections.Dictionary<string, Godot.Collections.Array<float>> output = new Godot.Collections.Dictionary<string, Godot.Collections.Array<float>>();
         | 
| 67 | 
            +
            			DisposableNamedOnnxValue output1 = results.First();
         | 
| 68 | 
            +
            			DisposableNamedOnnxValue output2 = results.Last();
         | 
| 69 | 
            +
            			Godot.Collections.Array<float> output1Array = new Godot.Collections.Array<float>();
         | 
| 70 | 
            +
            			Godot.Collections.Array<float> output2Array = new Godot.Collections.Array<float>();
         | 
| 71 |  | 
| 72 | 
            +
            			foreach (float f in output1.AsEnumerable<float>())
         | 
| 73 | 
            +
            			{
         | 
| 74 | 
            +
            				output1Array.Add(f);
         | 
| 75 | 
            +
            			}
         | 
| 76 |  | 
| 77 | 
            +
            			foreach (float f in output2.AsEnumerable<float>())
         | 
| 78 | 
            +
            			{
         | 
| 79 | 
            +
            				output2Array.Add(f);
         | 
| 80 | 
            +
            			}
         | 
| 81 |  | 
| 82 | 
            +
            			output.Add(output1.Name, output1Array);
         | 
| 83 | 
            +
            			output.Add(output2.Name, output2Array);
         | 
| 84 | 
            +
             | 
| 85 | 
            +
            			//Output is a dictionary of arrays, ex: { "output" : [0.1, 0.2, 0.3, 0.4, ...], "state_outs" : [0.5, ...]}
         | 
| 86 | 
            +
            			results.Dispose();
         | 
| 87 | 
            +
            			return output;
         | 
| 88 | 
            +
            		}
         | 
| 89 | 
            +
            		/// <include file='docs/ONNXInference.xml' path='docs/members[@name="ONNXInference"]/Load/*'/>
         | 
| 90 | 
            +
            		public InferenceSession LoadModel(string Path)
         | 
| 91 | 
            +
            		{
         | 
| 92 | 
            +
            			using Godot.FileAccess file = FileAccess.Open(Path, Godot.FileAccess.ModeFlags.Read);
         | 
| 93 | 
            +
            			byte[] model = file.GetBuffer((int)file.GetLength());
         | 
| 94 | 
            +
            			//file.Close(); file.Dispose(); //Close the file, then dispose the reference.
         | 
| 95 | 
            +
            			return new InferenceSession(model, SessionOpt); //Load the model
         | 
| 96 | 
            +
            		}
         | 
| 97 | 
            +
            		public void FreeDisposables()
         | 
| 98 | 
            +
            		{
         | 
| 99 | 
            +
            			session.Dispose();
         | 
| 100 | 
            +
            			SessionOpt.Dispose();
         | 
| 101 | 
            +
            		}
         | 
| 102 | 
             
            	}
         | 
| 103 | 
            +
            }
         | 
    	
        addons/godot_rl_agents/onnx/csharp/SessionConfigurator.cs
    CHANGED
    
    | @@ -1,106 +1,131 @@ | |
| 1 | 
             
            using Godot;
         | 
| 2 | 
             
            using Microsoft.ML.OnnxRuntime;
         | 
| 3 |  | 
| 4 | 
            -
            namespace GodotONNX | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
            	public static class SessionConfigurator {
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            		private static SessionOptions options = new SessionOptions();
         | 
| 10 | 
            -
            		
         | 
| 11 | 
            -
            /// <include file='docs/SessionConfigurator.xml' path='docs/members[@name="SessionConfigurator"]/GetSessionOptions/*'/>
         | 
| 12 | 
            -
            		public static SessionOptions GetSessionOptions() {
         | 
| 13 | 
            -
            			options = new SessionOptions();
         | 
| 14 | 
            -
            			options.LogSeverityLevel = OrtLoggingLevel.ORT_LOGGING_LEVEL_WARNING; 
         | 
| 15 | 
            -
            			// see warnings
         | 
| 16 | 
            -
            			SystemCheck();
         | 
| 17 | 
            -
            			return options;
         | 
| 18 | 
            -
            		}
         | 
| 19 | 
            -
            /// <include file='docs/SessionConfigurator.xml' path='docs/members[@name="SessionConfigurator"]/SystemCheck/*'/>
         | 
| 20 |  | 
| 21 | 
            -
            static  | 
| 22 | 
             
            	{
         | 
| 23 | 
            -
            		 | 
| 24 | 
            -
            		//implementation progress of the different compute APIs.
         | 
| 25 | 
            -
             | 
| 26 | 
            -
            		//December 2022: CUDA is not working. 
         | 
| 27 | 
            -
             | 
| 28 | 
            -
            		string OSName = OS.GetName(); //Get OS Name
         | 
| 29 | 
            -
            		int ComputeAPIID = ComputeCheck(); //Get Compute API
         | 
| 30 | 
            -
            		//TODO: Get CPU architecture
         | 
| 31 | 
            -
             | 
| 32 | 
            -
            		//Linux can use OpenVINO (C#) on x64 and ROCm on x86 (GDNative/C++)
         | 
| 33 | 
            -
            		//Windows can use OpenVINO (C#) on x64
         | 
| 34 | 
            -
            		//TODO: try TensorRT instead of CUDA
         | 
| 35 | 
            -
            		//TODO: Use OpenVINO for Intel Graphics
         | 
| 36 | 
            -
            		
         | 
| 37 | 
            -
            		string [] ComputeNames = {"CUDA", "DirectML/ROCm", "DirectML", "CoreML", "CPU"};
         | 
| 38 | 
            -
            		//match OS and Compute API
         | 
| 39 | 
            -
            		options.AppendExecutionProvider_CPU(0); // Always use CPU
         | 
| 40 | 
            -
            		GD.Print("OS: " + OSName, " | Compute API: " + ComputeNames[ComputeAPIID]);
         | 
| 41 | 
            -
             | 
| 42 | 
            -
            		switch (OSName) 
         | 
| 43 | 
             
            		{
         | 
| 44 | 
            -
             | 
| 45 | 
            -
            			 | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
            				options.AppendExecutionProvider_DML(0);
         | 
| 50 | 
            -
            					}
         | 
| 51 | 
            -
            			else if (ComputeAPIID == 1) 
         | 
| 52 | 
            -
            				{ 
         | 
| 53 | 
            -
            				//DirectML
         | 
| 54 | 
            -
            				options.AppendExecutionProvider_DML(0);
         | 
| 55 | 
            -
            				}
         | 
| 56 | 
            -
            			break;
         | 
| 57 | 
            -
            		case "X11": //Can use CUDA, ROCm
         | 
| 58 | 
            -
            			if (ComputeAPIID == 0) 
         | 
| 59 | 
            -
            				{ 
         | 
| 60 | 
            -
            				//CUDA
         | 
| 61 | 
            -
            				//options.AppendExecutionProvider_CUDA(0);
         | 
| 62 | 
            -
            				}
         | 
| 63 | 
            -
            			if (ComputeAPIID == 1) 
         | 
| 64 | 
            -
            				{
         | 
| 65 | 
            -
            				//ROCm, only works on x86 
         | 
| 66 | 
            -
            				//Research indicates that this has to be compiled as a GDNative plugin
         | 
| 67 | 
            -
            				GD.Print("ROCm not supported yet, using CPU.");
         | 
| 68 | 
            -
            				options.AppendExecutionProvider_CPU(0);
         | 
| 69 | 
            -
            				}
         | 
| 70 | 
            -
            			
         | 
| 71 | 
            -
            			break;
         | 
| 72 | 
            -
            		case "OSX": //Can use CoreML
         | 
| 73 | 
            -
            			if (ComputeAPIID == 0) { //CoreML
         | 
| 74 | 
            -
            			//TODO: Needs testing
         | 
| 75 | 
            -
            				options.AppendExecutionProvider_CoreML(0); 
         | 
| 76 | 
            -
            				//CoreML on ARM64, out of the box, on x64 needs .tar file from GitHub
         | 
| 77 | 
            -
            				}
         | 
| 78 | 
            -
            			break;
         | 
| 79 | 
            -
            		default:
         | 
| 80 | 
            -
            			GD.Print("OS not Supported.");
         | 
| 81 | 
            -
            			break;
         | 
| 82 | 
             
            		}
         | 
| 83 | 
            -
            	}
         | 
| 84 | 
            -
            /// <include file='docs/SessionConfigurator.xml' path='docs/members[@name="SessionConfigurator"]/ComputeCheck/*'/>
         | 
| 85 |  | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 101 | 
            -
             | 
| 102 | 
            -
             | 
| 103 | 
            -
             | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 104 | 
             
            			}
         | 
|  | |
|  | |
|  | |
| 105 | 
             
            		}
         | 
| 106 | 
            -
            } | 
|  | 
|  | |
| 1 | 
             
            using Godot;
         | 
| 2 | 
             
            using Microsoft.ML.OnnxRuntime;
         | 
| 3 |  | 
| 4 | 
            +
            namespace GodotONNX
         | 
| 5 | 
            +
            {
         | 
| 6 | 
            +
            	/// <include file='docs/SessionConfigurator.xml' path='docs/members[@name="SessionConfigurator"]/SessionConfigurator/*'/>
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 7 |  | 
| 8 | 
            +
            	public static class SessionConfigurator
         | 
| 9 | 
             
            	{
         | 
| 10 | 
            +
            		public enum ComputeName
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 11 | 
             
            		{
         | 
| 12 | 
            +
            			CUDA,
         | 
| 13 | 
            +
            			ROCm,
         | 
| 14 | 
            +
            			DirectML,
         | 
| 15 | 
            +
            			CoreML,
         | 
| 16 | 
            +
            			CPU
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 17 | 
             
            		}
         | 
|  | |
|  | |
| 18 |  | 
| 19 | 
            +
                    /// <include file='docs/SessionConfigurator.xml' path='docs/members[@name="SessionConfigurator"]/GetSessionOptions/*'/>
         | 
| 20 | 
            +
                    public static SessionOptions MakeConfiguredSessionOptions()
         | 
| 21 | 
            +
                    {
         | 
| 22 | 
            +
                        SessionOptions sessionOptions = new();
         | 
| 23 | 
            +
                        SetOptions(sessionOptions);
         | 
| 24 | 
            +
                        return sessionOptions;
         | 
| 25 | 
            +
                    }
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                    private static void SetOptions(SessionOptions sessionOptions)
         | 
| 28 | 
            +
                    {
         | 
| 29 | 
            +
                        sessionOptions.LogSeverityLevel = OrtLoggingLevel.ORT_LOGGING_LEVEL_WARNING;
         | 
| 30 | 
            +
                        ApplySystemSpecificOptions(sessionOptions);
         | 
| 31 | 
            +
                    }
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                    /// <include file='docs/SessionConfigurator.xml' path='docs/members[@name="SessionConfigurator"]/SystemCheck/*'/>
         | 
| 34 | 
            +
                    static public void ApplySystemSpecificOptions(SessionOptions sessionOptions)
         | 
| 35 | 
            +
                    {
         | 
| 36 | 
            +
                        //Most code for this function is verbose only, the only reason it exists is to track
         | 
| 37 | 
            +
                        //implementation progress of the different compute APIs.
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                        //December 2022: CUDA is not working. 
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                        string OSName = OS.GetName(); //Get OS Name
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                        //ComputeName ComputeAPI = ComputeCheck(); //Get Compute API
         | 
| 44 | 
            +
                        //                                         //TODO: Get CPU architecture
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                        //Linux can use OpenVINO (C#) on x64 and ROCm on x86 (GDNative/C++)
         | 
| 47 | 
            +
                        //Windows can use OpenVINO (C#) on x64
         | 
| 48 | 
            +
                        //TODO: try TensorRT instead of CUDA
         | 
| 49 | 
            +
                        //TODO: Use OpenVINO for Intel Graphics
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                        // Temporarily using CPU on all platforms to avoid errors detected with DML
         | 
| 52 | 
            +
                        ComputeName ComputeAPI = ComputeName.CPU;
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                        //match OS and Compute API
         | 
| 55 | 
            +
                        GD.Print($"OS: {OSName} Compute API: {ComputeAPI}");
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                        // CPU is set by default without appending necessary
         | 
| 58 | 
            +
                        // sessionOptions.AppendExecutionProvider_CPU(0);
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                        /*
         | 
| 61 | 
            +
                        switch (OSName)
         | 
| 62 | 
            +
                        {
         | 
| 63 | 
            +
                            case "Windows": //Can use CUDA, DirectML
         | 
| 64 | 
            +
                                if (ComputeAPI is ComputeName.CUDA)
         | 
| 65 | 
            +
                                {
         | 
| 66 | 
            +
                                    //CUDA 
         | 
| 67 | 
            +
                                    //sessionOptions.AppendExecutionProvider_CUDA(0);
         | 
| 68 | 
            +
                                    //sessionOptions.AppendExecutionProvider_DML(0);
         | 
| 69 | 
            +
                                }
         | 
| 70 | 
            +
                                else if (ComputeAPI is ComputeName.DirectML)
         | 
| 71 | 
            +
                                {
         | 
| 72 | 
            +
                                    //DirectML
         | 
| 73 | 
            +
                                    //sessionOptions.AppendExecutionProvider_DML(0);
         | 
| 74 | 
            +
                                }
         | 
| 75 | 
            +
                                break;
         | 
| 76 | 
            +
                            case "X11": //Can use CUDA, ROCm
         | 
| 77 | 
            +
                                if (ComputeAPI is ComputeName.CUDA)
         | 
| 78 | 
            +
                                {
         | 
| 79 | 
            +
                                    //CUDA
         | 
| 80 | 
            +
                                    //sessionOptions.AppendExecutionProvider_CUDA(0);
         | 
| 81 | 
            +
                                }
         | 
| 82 | 
            +
                                if (ComputeAPI is ComputeName.ROCm)
         | 
| 83 | 
            +
                                {
         | 
| 84 | 
            +
                                    //ROCm, only works on x86 
         | 
| 85 | 
            +
                                    //Research indicates that this has to be compiled as a GDNative plugin
         | 
| 86 | 
            +
                                    //GD.Print("ROCm not supported yet, using CPU.");
         | 
| 87 | 
            +
                                    //sessionOptions.AppendExecutionProvider_CPU(0);
         | 
| 88 | 
            +
                                }
         | 
| 89 | 
            +
                                break;
         | 
| 90 | 
            +
                            case "macOS": //Can use CoreML
         | 
| 91 | 
            +
                                if (ComputeAPI is ComputeName.CoreML)
         | 
| 92 | 
            +
                                { //CoreML
         | 
| 93 | 
            +
                                  //TODO: Needs testing
         | 
| 94 | 
            +
                                    //sessionOptions.AppendExecutionProvider_CoreML(0);
         | 
| 95 | 
            +
                                    //CoreML on ARM64, out of the box, on x64 needs .tar file from GitHub
         | 
| 96 | 
            +
                                }
         | 
| 97 | 
            +
                                break;
         | 
| 98 | 
            +
                            default:
         | 
| 99 | 
            +
                                GD.Print("OS not Supported.");
         | 
| 100 | 
            +
                                break;
         | 
| 101 | 
            +
                        }
         | 
| 102 | 
            +
                        */
         | 
| 103 | 
            +
                    }
         | 
| 104 | 
            +
             | 
| 105 | 
            +
             | 
| 106 | 
            +
                    /// <include file='docs/SessionConfigurator.xml' path='docs/members[@name="SessionConfigurator"]/ComputeCheck/*'/>
         | 
| 107 | 
            +
                    public static ComputeName ComputeCheck()
         | 
| 108 | 
            +
            		{
         | 
| 109 | 
            +
            			string adapterName = Godot.RenderingServer.GetVideoAdapterName();
         | 
| 110 | 
            +
            			//string adapterVendor = Godot.RenderingServer.GetVideoAdapterVendor();
         | 
| 111 | 
            +
            			adapterName = adapterName.ToUpper(new System.Globalization.CultureInfo(""));
         | 
| 112 | 
            +
            			//TODO: GPU vendors for MacOS, what do they even use these days?
         | 
| 113 | 
            +
            		  
         | 
| 114 | 
            +
            			if (adapterName.Contains("INTEL"))
         | 
| 115 | 
            +
            			{
         | 
| 116 | 
            +
            				return ComputeName.DirectML;
         | 
| 117 | 
            +
            			}
         | 
| 118 | 
            +
            			if (adapterName.Contains("AMD") || adapterName.Contains("RADEON"))
         | 
| 119 | 
            +
            			{
         | 
| 120 | 
            +
            				return ComputeName.DirectML;
         | 
| 121 | 
            +
            			}
         | 
| 122 | 
            +
            			if (adapterName.Contains("NVIDIA"))
         | 
| 123 | 
            +
            			{
         | 
| 124 | 
            +
            				return ComputeName.CUDA;
         | 
| 125 | 
             
            			}
         | 
| 126 | 
            +
             | 
| 127 | 
            +
            			GD.Print("Graphics Card not recognized."); //Should use CPU
         | 
| 128 | 
            +
            			return ComputeName.CPU;
         | 
| 129 | 
             
            		}
         | 
| 130 | 
            +
            	}
         | 
| 131 | 
            +
            }
         | 
    	
        addons/godot_rl_agents/onnx/wrapper/ONNX_wrapper.gd
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            extends  | 
| 2 | 
             
            class_name ONNXModel
         | 
| 3 | 
             
            var inferencer_script = load("res://addons/godot_rl_agents/onnx/csharp/ONNXInference.cs")
         | 
| 4 |  | 
| @@ -17,3 +17,8 @@ func run_inference(obs : Array, state_ins : int) -> Dictionary: | |
| 17 | 
             
            		printerr("Inferencer not initialized")
         | 
| 18 | 
             
            		return {}
         | 
| 19 | 
             
            	return inferencer.RunInference(obs, state_ins)
         | 
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            extends Resource
         | 
| 2 | 
             
            class_name ONNXModel
         | 
| 3 | 
             
            var inferencer_script = load("res://addons/godot_rl_agents/onnx/csharp/ONNXInference.cs")
         | 
| 4 |  | 
|  | |
| 17 | 
             
            		printerr("Inferencer not initialized")
         | 
| 18 | 
             
            		return {}
         | 
| 19 | 
             
            	return inferencer.RunInference(obs, state_ins)
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            func _notification(what):
         | 
| 22 | 
            +
            	if what == NOTIFICATION_PREDELETE:
         | 
| 23 | 
            +
            		inferencer.FreeDisposables()
         | 
| 24 | 
            +
            		inferencer.free()
         | 
    	
        addons/godot_rl_agents/sensors/sensors_2d/ExampleRaycastSensor2D.tscn
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 | 
             
            [gd_scene load_steps=5 format=3 uid="uid://ddeq7mn1ealyc"]
         | 
| 2 |  | 
| 3 | 
            -
            [ext_resource type="Script" path="res://sensors/sensors_2d/RaycastSensor2D.gd" id="1"]
         | 
| 4 |  | 
| 5 | 
             
            [sub_resource type="GDScript" id="2"]
         | 
| 6 | 
             
            script/source = "extends Node2D
         | 
|  | |
| 1 | 
             
            [gd_scene load_steps=5 format=3 uid="uid://ddeq7mn1ealyc"]
         | 
| 2 |  | 
| 3 | 
            +
            [ext_resource type="Script" path="res://addons/godot_rl_agents/sensors/sensors_2d/RaycastSensor2D.gd" id="1"]
         | 
| 4 |  | 
| 5 | 
             
            [sub_resource type="GDScript" id="2"]
         | 
| 6 | 
             
            script/source = "extends Node2D
         | 
    	
        addons/godot_rl_agents/sensors/sensors_3d/RaycastSensor3D.gd
    CHANGED
    
    | @@ -61,11 +61,15 @@ var geo = null | |
| 61 |  | 
| 62 | 
             
            func _update():
         | 
| 63 | 
             
            	if Engine.is_editor_hint():
         | 
| 64 | 
            -
            		 | 
| 65 | 
            -
             | 
| 66 |  | 
| 67 | 
             
            func _ready() -> void:
         | 
| 68 | 
            -
            	 | 
|  | |
|  | |
|  | |
|  | |
| 69 |  | 
| 70 | 
             
            func _spawn_nodes():
         | 
| 71 | 
             
            	print("spawning nodes")
         | 
|  | |
| 61 |  | 
| 62 | 
             
            func _update():
         | 
| 63 | 
             
            	if Engine.is_editor_hint():
         | 
| 64 | 
            +
            		if is_node_ready():
         | 
| 65 | 
            +
            			_spawn_nodes()	
         | 
| 66 |  | 
| 67 | 
             
            func _ready() -> void:
         | 
| 68 | 
            +
            	if Engine.is_editor_hint():	
         | 
| 69 | 
            +
            		if get_child_count() == 0:
         | 
| 70 | 
            +
            			_spawn_nodes()
         | 
| 71 | 
            +
            	else:
         | 
| 72 | 
            +
            		_spawn_nodes()
         | 
| 73 |  | 
| 74 | 
             
            func _spawn_nodes():
         | 
| 75 | 
             
            	print("spawning nodes")
         | 
    	
        addons/godot_rl_agents/sync.gd
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 | 
             
            extends Node
         | 
| 2 | 
             
            # --fixed-fps 2000 --disable-render-loop
         | 
| 3 | 
            -
            @ | 
| 4 | 
            -
            @ | 
| 5 | 
             
            @export var onnx_model_path := ""
         | 
| 6 |  | 
| 7 | 
             
            @onready var start_time = Time.get_ticks_msec()
         | 
| @@ -10,7 +10,6 @@ const MAJOR_VERSION := "0" | |
| 10 | 
             
            const MINOR_VERSION := "3" 
         | 
| 11 | 
             
            const DEFAULT_PORT := "11008"
         | 
| 12 | 
             
            const DEFAULT_SEED := "1"
         | 
| 13 | 
            -
            const DEFAULT_ACTION_REPEAT := "8"
         | 
| 14 | 
             
            var stream : StreamPeerTCP = null
         | 
| 15 | 
             
            var connected = false
         | 
| 16 | 
             
            var message_center
         | 
| @@ -44,17 +43,20 @@ func _initialize(): | |
| 44 | 
             
            	Engine.time_scale = _get_speedup() * 1.0
         | 
| 45 | 
             
            	prints("physics ticks", Engine.physics_ticks_per_second, Engine.time_scale, _get_speedup(), speed_up)
         | 
| 46 |  | 
| 47 | 
            -
             | 
| 48 | 
            -
            	 | 
| 49 | 
            -
            	if  | 
| 50 | 
            -
            		 | 
| 51 | 
            -
            		_handshake()
         | 
| 52 | 
            -
            		_send_env_info()
         | 
| 53 | 
            -
            	elif onnx_model_path != "":
         | 
| 54 | 
             
            		onnx_model = ONNXModel.new(onnx_model_path, 1)
         | 
| 55 | 
             
            		_set_heuristic("model")
         | 
| 56 | 
            -
            	else:
         | 
| 57 | 
            -
            		 | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 58 |  | 
| 59 | 
             
            	_set_seed()
         | 
| 60 | 
             
            	_set_action_repeat()
         | 
| @@ -232,7 +234,7 @@ func _set_seed(): | |
| 232 | 
             
            	seed(_seed)
         | 
| 233 |  | 
| 234 | 
             
            func _set_action_repeat():
         | 
| 235 | 
            -
            	action_repeat = args.get("action_repeat",  | 
| 236 |  | 
| 237 | 
             
            func disconnect_from_server():
         | 
| 238 | 
             
            	stream.disconnect_from_host()
         | 
|  | |
| 1 | 
             
            extends Node
         | 
| 2 | 
             
            # --fixed-fps 2000 --disable-render-loop
         | 
| 3 | 
            +
            @export_range(1, 10, 1, "or_greater") var action_repeat := 8
         | 
| 4 | 
            +
            @export_range(1, 10, 1, "or_greater") var speed_up = 1
         | 
| 5 | 
             
            @export var onnx_model_path := ""
         | 
| 6 |  | 
| 7 | 
             
            @onready var start_time = Time.get_ticks_msec()
         | 
|  | |
| 10 | 
             
            const MINOR_VERSION := "3" 
         | 
| 11 | 
             
            const DEFAULT_PORT := "11008"
         | 
| 12 | 
             
            const DEFAULT_SEED := "1"
         | 
|  | |
| 13 | 
             
            var stream : StreamPeerTCP = null
         | 
| 14 | 
             
            var connected = false
         | 
| 15 | 
             
            var message_center
         | 
|  | |
| 43 | 
             
            	Engine.time_scale = _get_speedup() * 1.0
         | 
| 44 | 
             
            	prints("physics ticks", Engine.physics_ticks_per_second, Engine.time_scale, _get_speedup(), speed_up)
         | 
| 45 |  | 
| 46 | 
            +
            	# Run inference if onnx model path is set, otherwise wait for server connection
         | 
| 47 | 
            +
            	var run_onnx_model_inference : bool = onnx_model_path != ""
         | 
| 48 | 
            +
            	if run_onnx_model_inference:
         | 
| 49 | 
            +
            		assert(FileAccess.file_exists(onnx_model_path), "Onnx Model Path set on Sync node does not exist: " + onnx_model_path)
         | 
|  | |
|  | |
|  | |
| 50 | 
             
            		onnx_model = ONNXModel.new(onnx_model_path, 1)
         | 
| 51 | 
             
            		_set_heuristic("model")
         | 
| 52 | 
            +
            	else:		
         | 
| 53 | 
            +
            		connected = connect_to_server()
         | 
| 54 | 
            +
            		if connected:
         | 
| 55 | 
            +
            			_set_heuristic("model")
         | 
| 56 | 
            +
            			_handshake()
         | 
| 57 | 
            +
            			_send_env_info()
         | 
| 58 | 
            +
            		else:
         | 
| 59 | 
            +
            			_set_heuristic("human")  
         | 
| 60 |  | 
| 61 | 
             
            	_set_seed()
         | 
| 62 | 
             
            	_set_action_repeat()
         | 
|  | |
| 234 | 
             
            	seed(_seed)
         | 
| 235 |  | 
| 236 | 
             
            func _set_action_repeat():
         | 
| 237 | 
            +
            	action_repeat = args.get("action_repeat", str(action_repeat)).to_int()
         | 
| 238 |  | 
| 239 | 
             
            func disconnect_from_server():
         | 
| 240 | 
             
            	stream.disconnect_from_host()
         | 
    	
        bin/FPS.console.exe
    CHANGED
    
    | Binary files a/bin/FPS.console.exe and b/bin/FPS.console.exe differ | 
|  | 
    	
        bin/FPS.exe
    CHANGED
    
    | @@ -1,3 +1,3 @@ | |
| 1 | 
             
            version https://git-lfs.github.com/spec/v1
         | 
| 2 | 
            -
            oid sha256: | 
| 3 | 
            -
            size  | 
|  | |
| 1 | 
             
            version https://git-lfs.github.com/spec/v1
         | 
| 2 | 
            +
            oid sha256:910d1661cf406eb788be65369b4784b8bde02dd16e327fac690b501d08e9e886
         | 
| 3 | 
            +
            size 69051392
         | 
    	
        bin/FPS.pck
    CHANGED
    
    | @@ -1,3 +1,3 @@ | |
| 1 | 
             
            version https://git-lfs.github.com/spec/v1
         | 
| 2 | 
            -
            oid sha256: | 
| 3 | 
            -
            size  | 
|  | |
| 1 | 
             
            version https://git-lfs.github.com/spec/v1
         | 
| 2 | 
            +
            oid sha256:e6b978e714972f45467cbc92ef2d560540d318806bcfad736e61eff512c97641
         | 
| 3 | 
            +
            size 17453776
         | 
    	
        bin/FPS.x86_64
    CHANGED
    
    | @@ -1,3 +1,3 @@ | |
| 1 | 
             
            version https://git-lfs.github.com/spec/v1
         | 
| 2 | 
            -
            oid sha256: | 
| 3 | 
            -
            size  | 
|  | |
| 1 | 
             
            version https://git-lfs.github.com/spec/v1
         | 
| 2 | 
            +
            oid sha256:fb6fa01639dd98489aac3e0dd5f9ecf0691b25b37a717f7380b1350d91ed23a4
         | 
| 3 | 
            +
            size 61637496
         | 
    	
        main.tscn
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 | 
             
            [gd_scene load_steps=35 format=3 uid="uid://bcdqrmxwwtqio"]
         | 
| 2 |  | 
| 3 | 
             
            [ext_resource type="Script" path="res://main.gd" id="1_46kri"]
         | 
| 4 | 
            -
            [ext_resource type="Texture2D" uid="uid:// | 
| 5 | 
            -
            [ext_resource type="Texture2D" uid="uid:// | 
| 6 | 
             
            [ext_resource type="Script" path="res://Objects.gd" id="2_wbkwf"]
         | 
| 7 | 
            -
            [ext_resource type="Texture2D" uid="uid:// | 
| 8 | 
            -
            [ext_resource type="Texture2D" uid="uid:// | 
| 9 | 
            -
            [ext_resource type="Texture2D" uid="uid:// | 
| 10 | 
            -
            [ext_resource type="Texture2D" uid="uid:// | 
| 11 | 
            -
            [ext_resource type="Texture2D" uid="uid:// | 
| 12 | 
             
            [ext_resource type="Script" path="res://SpawnPoint.gd" id="10_4gs1i"]
         | 
| 13 | 
             
            [ext_resource type="Script" path="res://FlyCam.gd" id="10_faad2"]
         | 
| 14 | 
             
            [ext_resource type="Script" path="res://OrbitCam.gd" id="11_gr5me"]
         | 
|  | |
| 1 | 
             
            [gd_scene load_steps=35 format=3 uid="uid://bcdqrmxwwtqio"]
         | 
| 2 |  | 
| 3 | 
             
            [ext_resource type="Script" path="res://main.gd" id="1_46kri"]
         | 
| 4 | 
            +
            [ext_resource type="Texture2D" uid="uid://dreawusx30mcc" path="res://assets/prototype_textures/PNG/Dark/texture_02.png" id="1_gbd6o"]
         | 
| 5 | 
            +
            [ext_resource type="Texture2D" uid="uid://be8a55rsgn7dx" path="res://assets/prototype_textures/PNG/Dark/texture_01.png" id="1_tqhff"]
         | 
| 6 | 
             
            [ext_resource type="Script" path="res://Objects.gd" id="2_wbkwf"]
         | 
| 7 | 
            +
            [ext_resource type="Texture2D" uid="uid://cjk77jctcs1x6" path="res://assets/prototype_textures/PNG/Red/texture_01.png" id="3_16cyc"]
         | 
| 8 | 
            +
            [ext_resource type="Texture2D" uid="uid://bmpbyv1gjufhv" path="res://assets/prototype_textures/PNG/Dark/texture_13.png" id="3_iiro4"]
         | 
| 9 | 
            +
            [ext_resource type="Texture2D" uid="uid://dmmaecg6quxrk" path="res://assets/prototype_textures/PNG/Purple/texture_01.png" id="4_dfkyr"]
         | 
| 10 | 
            +
            [ext_resource type="Texture2D" uid="uid://dj2uiciie2iqt" path="res://assets/prototype_textures/PNG/Orange/texture_01.png" id="4_gfq4c"]
         | 
| 11 | 
            +
            [ext_resource type="Texture2D" uid="uid://btcy1cyimq1m5" path="res://assets/prototype_textures/PNG/Green/texture_01.png" id="7_wu0n4"]
         | 
| 12 | 
             
            [ext_resource type="Script" path="res://SpawnPoint.gd" id="10_4gs1i"]
         | 
| 13 | 
             
            [ext_resource type="Script" path="res://FlyCam.gd" id="10_faad2"]
         | 
| 14 | 
             
            [ext_resource type="Script" path="res://OrbitCam.gd" id="11_gr5me"]
         | 
    	
        managers/camera_manager.gd
    CHANGED
    
    | @@ -11,7 +11,7 @@ func register_player(player): | |
| 11 | 
             
            	player_camera_slots.append(player)
         | 
| 12 |  | 
| 13 |  | 
| 14 | 
            -
            func _process( | 
| 15 |  | 
| 16 | 
             
            	if Input.is_action_just_pressed("toggle_next_player"):
         | 
| 17 | 
             
            		prints("toggle_next_player", current_id)
         | 
|  | |
| 11 | 
             
            	player_camera_slots.append(player)
         | 
| 12 |  | 
| 13 |  | 
| 14 | 
            +
            func _process(_delta):
         | 
| 15 |  | 
| 16 | 
             
            	if Input.is_action_just_pressed("toggle_next_player"):
         | 
| 17 | 
             
            		prints("toggle_next_player", current_id)
         | 
    	
        player.gd
    CHANGED
    
    | @@ -15,7 +15,7 @@ const JUMP_VELOCITY : float = 4.5 | |
| 15 | 
             
            @onready var third_person_camera : Camera3D = $CameraPivot/ThirdPersonCamera3d
         | 
| 16 | 
             
            @onready var camera_raycast : RayCast3D = $CameraPivot/FirstPersonCamera3d/RayCast3D
         | 
| 17 | 
             
            @onready var Proj = preload("res://projectile.tscn")
         | 
| 18 | 
            -
            @onready var ai_controller:  | 
| 19 | 
             
            @onready var health_system = $HealthSystem
         | 
| 20 |  | 
| 21 | 
             
            # Get the gravity from the project settings to be synced with RigidBody nodes.
         | 
|  | |
| 15 | 
             
            @onready var third_person_camera : Camera3D = $CameraPivot/ThirdPersonCamera3d
         | 
| 16 | 
             
            @onready var camera_raycast : RayCast3D = $CameraPivot/FirstPersonCamera3d/RayCast3D
         | 
| 17 | 
             
            @onready var Proj = preload("res://projectile.tscn")
         | 
| 18 | 
            +
            @onready var ai_controller: AIController3D = $CameraPivot/AIController
         | 
| 19 | 
             
            @onready var health_system = $HealthSystem
         | 
| 20 |  | 
| 21 | 
             
            # Get the gravity from the project settings to be synced with RigidBody nodes.
         | 
    	
        player.tscn
    CHANGED
    
    | @@ -45,9 +45,10 @@ current = true | |
| 45 | 
             
            [node name="RayCast3D" type="RayCast3D" parent="CameraPivot/FirstPersonCamera3d"]
         | 
| 46 | 
             
            target_position = Vector3(0, 0, -100)
         | 
| 47 |  | 
| 48 | 
            -
            [node name="AIController" type="Node3D" parent="CameraPivot" | 
| 49 | 
             
            transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.40586, 0.0894096)
         | 
| 50 | 
             
            script = ExtResource("5_mm0y5")
         | 
|  | |
| 51 |  | 
| 52 | 
             
            [node name="WideRaycastSensor" type="Node3D" parent="CameraPivot/AIController"]
         | 
| 53 | 
             
            transform = Transform3D(-1, 0, -8.74228e-08, -1.77636e-15, 1, 0, 8.74228e-08, 0, -1, 0, 1.54159, -0.124174)
         | 
|  | |
| 45 | 
             
            [node name="RayCast3D" type="RayCast3D" parent="CameraPivot/FirstPersonCamera3d"]
         | 
| 46 | 
             
            target_position = Vector3(0, 0, -100)
         | 
| 47 |  | 
| 48 | 
            +
            [node name="AIController" type="Node3D" parent="CameraPivot"]
         | 
| 49 | 
             
            transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.40586, 0.0894096)
         | 
| 50 | 
             
            script = ExtResource("5_mm0y5")
         | 
| 51 | 
            +
            reset_after = 0
         | 
| 52 |  | 
| 53 | 
             
            [node name="WideRaycastSensor" type="Node3D" parent="CameraPivot/AIController"]
         | 
| 54 | 
             
            transform = Transform3D(-1, 0, -8.74228e-08, -1.77636e-15, 1, 0, 8.74228e-08, 0, -1, 0, 1.54159, -0.124174)
         | 
    	
        project.godot
    CHANGED
    
    | @@ -8,93 +8,11 @@ | |
| 8 |  | 
| 9 | 
             
            config_version=5
         | 
| 10 |  | 
| 11 | 
            -
            _global_script_classes=[{
         | 
| 12 | 
            -
            "base": "Node3D",
         | 
| 13 | 
            -
            "class": &"AIController",
         | 
| 14 | 
            -
            "language": &"GDScript",
         | 
| 15 | 
            -
            "path": "res://AIController.gd"
         | 
| 16 | 
            -
            }, {
         | 
| 17 | 
            -
            "base": "Node3D",
         | 
| 18 | 
            -
            "class": &"CharacterModel",
         | 
| 19 | 
            -
            "language": &"GDScript",
         | 
| 20 | 
            -
            "path": "res://tbot_model.gd"
         | 
| 21 | 
            -
            }, {
         | 
| 22 | 
            -
            "base": "Node2D",
         | 
| 23 | 
            -
            "class": &"ISensor2D",
         | 
| 24 | 
            -
            "language": &"GDScript",
         | 
| 25 | 
            -
            "path": "res://addons/godot_rl_agents/sensors/sensors_2d/ISensor2D.gd"
         | 
| 26 | 
            -
            }, {
         | 
| 27 | 
            -
            "base": "Node3D",
         | 
| 28 | 
            -
            "class": &"ISensor3D",
         | 
| 29 | 
            -
            "language": &"GDScript",
         | 
| 30 | 
            -
            "path": "res://addons/godot_rl_agents/sensors/sensors_3d/ISensor3D.gd"
         | 
| 31 | 
            -
            }, {
         | 
| 32 | 
            -
            "base": "CharacterBody3D",
         | 
| 33 | 
            -
            "class": &"Player",
         | 
| 34 | 
            -
            "language": &"GDScript",
         | 
| 35 | 
            -
            "path": "res://player.gd"
         | 
| 36 | 
            -
            }, {
         | 
| 37 | 
            -
            "base": "Area3D",
         | 
| 38 | 
            -
            "class": &"PlayerHitBox",
         | 
| 39 | 
            -
            "language": &"GDScript",
         | 
| 40 | 
            -
            "path": "res://PlayerHitBox.gd"
         | 
| 41 | 
            -
            }, {
         | 
| 42 | 
            -
            "base": "State",
         | 
| 43 | 
            -
            "class": &"PlayerState",
         | 
| 44 | 
            -
            "language": &"GDScript",
         | 
| 45 | 
            -
            "path": "res://state_machine/player_state.gd"
         | 
| 46 | 
            -
            }, {
         | 
| 47 | 
            -
            "base": "Node3D",
         | 
| 48 | 
            -
            "class": &"Projectile",
         | 
| 49 | 
            -
            "language": &"GDScript",
         | 
| 50 | 
            -
            "path": "res://projectile.gd"
         | 
| 51 | 
            -
            }, {
         | 
| 52 | 
            -
            "base": "Node3D",
         | 
| 53 | 
            -
            "class": &"RGBCameraSensor3D",
         | 
| 54 | 
            -
            "language": &"GDScript",
         | 
| 55 | 
            -
            "path": "res://addons/godot_rl_agents/sensors/sensors_3d/RGBCameraSensor3D.gd"
         | 
| 56 | 
            -
            }, {
         | 
| 57 | 
            -
            "base": "ISensor3D",
         | 
| 58 | 
            -
            "class": &"RayCastSensor3D",
         | 
| 59 | 
            -
            "language": &"GDScript",
         | 
| 60 | 
            -
            "path": "res://addons/godot_rl_agents/sensors/sensors_3d/RaycastSensor3D.gd"
         | 
| 61 | 
            -
            }, {
         | 
| 62 | 
            -
            "base": "ISensor2D",
         | 
| 63 | 
            -
            "class": &"RaycastSensor2D",
         | 
| 64 | 
            -
            "language": &"GDScript",
         | 
| 65 | 
            -
            "path": "res://addons/godot_rl_agents/sensors/sensors_2d/RaycastSensor2D.gd"
         | 
| 66 | 
            -
            }, {
         | 
| 67 | 
            -
            "base": "Node",
         | 
| 68 | 
            -
            "class": &"State",
         | 
| 69 | 
            -
            "language": &"GDScript",
         | 
| 70 | 
            -
            "path": "res://state_machine/state.gd"
         | 
| 71 | 
            -
            }, {
         | 
| 72 | 
            -
            "base": "Node",
         | 
| 73 | 
            -
            "class": &"StateMachine",
         | 
| 74 | 
            -
            "language": &"GDScript",
         | 
| 75 | 
            -
            "path": "res://state_machine/state_machine.gd"
         | 
| 76 | 
            -
            }]
         | 
| 77 | 
            -
            _global_script_class_icons={
         | 
| 78 | 
            -
            "AIController": "",
         | 
| 79 | 
            -
            "CharacterModel": "",
         | 
| 80 | 
            -
            "ISensor2D": "",
         | 
| 81 | 
            -
            "ISensor3D": "",
         | 
| 82 | 
            -
            "Player": "",
         | 
| 83 | 
            -
            "PlayerHitBox": "",
         | 
| 84 | 
            -
            "PlayerState": "",
         | 
| 85 | 
            -
            "Projectile": "",
         | 
| 86 | 
            -
            "RGBCameraSensor3D": "",
         | 
| 87 | 
            -
            "RayCastSensor3D": "",
         | 
| 88 | 
            -
            "RaycastSensor2D": "",
         | 
| 89 | 
            -
            "State": "",
         | 
| 90 | 
            -
            "StateMachine": ""
         | 
| 91 | 
            -
            }
         | 
| 92 | 
            -
             | 
| 93 | 
             
            [application]
         | 
| 94 |  | 
| 95 | 
             
            config/name="FPS"
         | 
| 96 | 
             
            run/main_scene="res://train.tscn"
         | 
| 97 | 
            -
            config/features=PackedStringArray("4. | 
| 98 | 
             
            config/icon="res://icon.svg"
         | 
| 99 |  | 
| 100 | 
             
            [autoload]
         | 
| @@ -102,85 +20,89 @@ config/icon="res://icon.svg" | |
| 102 | 
             
            CameraManager="*res://managers/camera_manager.gd"
         | 
| 103 | 
             
            GameManager="*res://managers/game_manager.gd"
         | 
| 104 |  | 
|  | |
|  | |
|  | |
|  | |
| 105 | 
             
            [editor_plugins]
         | 
| 106 |  | 
| 107 | 
            -
            enabled=PackedStringArray()
         | 
| 108 |  | 
| 109 | 
             
            [input]
         | 
| 110 |  | 
| 111 | 
             
            move_left={
         | 
| 112 | 
             
            "deadzone": 0.5,
         | 
| 113 | 
            -
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"unicode":0,"echo":false,"script":null)
         | 
| 114 | 
             
            ]
         | 
| 115 | 
             
            }
         | 
| 116 | 
             
            move_right={
         | 
| 117 | 
             
            "deadzone": 0.5,
         | 
| 118 | 
            -
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"unicode":0,"echo":false,"script":null)
         | 
| 119 | 
             
            ]
         | 
| 120 | 
             
            }
         | 
| 121 | 
             
            move_forward={
         | 
| 122 | 
             
            "deadzone": 0.5,
         | 
| 123 | 
            -
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"unicode":0,"echo":false,"script":null)
         | 
| 124 | 
             
            ]
         | 
| 125 | 
             
            }
         | 
| 126 | 
             
            move_backward={
         | 
| 127 | 
             
            "deadzone": 0.5,
         | 
| 128 | 
            -
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"unicode":0,"echo":false,"script":null)
         | 
| 129 | 
             
            ]
         | 
| 130 | 
             
            }
         | 
| 131 | 
             
            jump={
         | 
| 132 | 
             
            "deadzone": 0.5,
         | 
| 133 | 
            -
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"unicode":0,"echo":false,"script":null)
         | 
| 134 | 
             
            ]
         | 
| 135 | 
             
            }
         | 
| 136 | 
             
            shoot={
         | 
| 137 | 
             
            "deadzone": 0.5,
         | 
| 138 | 
            -
            "events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"pressed":false,"double_click":false,"script":null)
         | 
| 139 | 
             
            ]
         | 
| 140 | 
             
            }
         | 
| 141 | 
             
            toggle_next_player={
         | 
| 142 | 
             
            "deadzone": 0.5,
         | 
| 143 | 
            -
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"unicode":0,"echo":false,"script":null)
         | 
| 144 | 
             
            ]
         | 
| 145 | 
             
            }
         | 
| 146 | 
             
            toggle_previous_player={
         | 
| 147 | 
             
            "deadzone": 0.5,
         | 
| 148 | 
            -
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"unicode":0,"echo":false,"script":null)
         | 
| 149 | 
             
            ]
         | 
| 150 | 
             
            }
         | 
| 151 | 
             
            toggle_first_person_camera={
         | 
| 152 | 
             
            "deadzone": 0.5,
         | 
| 153 | 
            -
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"unicode":0,"echo":false,"script":null)
         | 
| 154 | 
             
            ]
         | 
| 155 | 
             
            }
         | 
| 156 | 
             
            toggle_third_person_camera={
         | 
| 157 | 
             
            "deadzone": 0.5,
         | 
| 158 | 
            -
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"unicode":0,"echo":false,"script":null)
         | 
| 159 | 
             
            ]
         | 
| 160 | 
             
            }
         | 
| 161 | 
             
            toggle_flycam={
         | 
| 162 | 
             
            "deadzone": 0.5,
         | 
| 163 | 
            -
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":67,"unicode":0,"echo":false,"script":null)
         | 
| 164 | 
             
            ]
         | 
| 165 | 
             
            }
         | 
| 166 | 
             
            cam_down={
         | 
| 167 | 
             
            "deadzone": 0.5,
         | 
| 168 | 
            -
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194326,"unicode":0,"echo":false,"script":null)
         | 
| 169 | 
             
            ]
         | 
| 170 | 
             
            }
         | 
| 171 | 
             
            cam_up={
         | 
| 172 | 
             
            "deadzone": 0.5,
         | 
| 173 | 
            -
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"unicode":0,"echo":false,"script":null)
         | 
| 174 | 
             
            ]
         | 
| 175 | 
             
            }
         | 
| 176 | 
             
            human_control={
         | 
| 177 | 
             
            "deadzone": 0.5,
         | 
| 178 | 
            -
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":72,"unicode":0,"echo":false,"script":null)
         | 
| 179 | 
             
            ]
         | 
| 180 | 
             
            }
         | 
| 181 | 
             
            toggle_orbitcam={
         | 
| 182 | 
             
            "deadzone": 0.5,
         | 
| 183 | 
            -
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":79,"unicode":0,"echo":false,"script":null)
         | 
| 184 | 
             
            ]
         | 
| 185 | 
             
            }
         | 
| 186 |  | 
|  | |
| 8 |  | 
| 9 | 
             
            config_version=5
         | 
| 10 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 11 | 
             
            [application]
         | 
| 12 |  | 
| 13 | 
             
            config/name="FPS"
         | 
| 14 | 
             
            run/main_scene="res://train.tscn"
         | 
| 15 | 
            +
            config/features=PackedStringArray("4.1")
         | 
| 16 | 
             
            config/icon="res://icon.svg"
         | 
| 17 |  | 
| 18 | 
             
            [autoload]
         | 
|  | |
| 20 | 
             
            CameraManager="*res://managers/camera_manager.gd"
         | 
| 21 | 
             
            GameManager="*res://managers/game_manager.gd"
         | 
| 22 |  | 
| 23 | 
            +
            [dotnet]
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            project/assembly_name="FPS"
         | 
| 26 | 
            +
             | 
| 27 | 
             
            [editor_plugins]
         | 
| 28 |  | 
| 29 | 
            +
            enabled=PackedStringArray("res://addons/godot_rl_agents/plugin.cfg")
         | 
| 30 |  | 
| 31 | 
             
            [input]
         | 
| 32 |  | 
| 33 | 
             
            move_left={
         | 
| 34 | 
             
            "deadzone": 0.5,
         | 
| 35 | 
            +
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":0,"echo":false,"script":null)
         | 
| 36 | 
             
            ]
         | 
| 37 | 
             
            }
         | 
| 38 | 
             
            move_right={
         | 
| 39 | 
             
            "deadzone": 0.5,
         | 
| 40 | 
            +
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":0,"echo":false,"script":null)
         | 
| 41 | 
             
            ]
         | 
| 42 | 
             
            }
         | 
| 43 | 
             
            move_forward={
         | 
| 44 | 
             
            "deadzone": 0.5,
         | 
| 45 | 
            +
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":0,"echo":false,"script":null)
         | 
| 46 | 
             
            ]
         | 
| 47 | 
             
            }
         | 
| 48 | 
             
            move_backward={
         | 
| 49 | 
             
            "deadzone": 0.5,
         | 
| 50 | 
            +
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":0,"echo":false,"script":null)
         | 
| 51 | 
             
            ]
         | 
| 52 | 
             
            }
         | 
| 53 | 
             
            jump={
         | 
| 54 | 
             
            "deadzone": 0.5,
         | 
| 55 | 
            +
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":0,"echo":false,"script":null)
         | 
| 56 | 
             
            ]
         | 
| 57 | 
             
            }
         | 
| 58 | 
             
            shoot={
         | 
| 59 | 
             
            "deadzone": 0.5,
         | 
| 60 | 
            +
            "events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null)
         | 
| 61 | 
             
            ]
         | 
| 62 | 
             
            }
         | 
| 63 | 
             
            toggle_next_player={
         | 
| 64 | 
             
            "deadzone": 0.5,
         | 
| 65 | 
            +
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
         | 
| 66 | 
             
            ]
         | 
| 67 | 
             
            }
         | 
| 68 | 
             
            toggle_previous_player={
         | 
| 69 | 
             
            "deadzone": 0.5,
         | 
| 70 | 
            +
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
         | 
| 71 | 
             
            ]
         | 
| 72 | 
             
            }
         | 
| 73 | 
             
            toggle_first_person_camera={
         | 
| 74 | 
             
            "deadzone": 0.5,
         | 
| 75 | 
            +
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
         | 
| 76 | 
             
            ]
         | 
| 77 | 
             
            }
         | 
| 78 | 
             
            toggle_third_person_camera={
         | 
| 79 | 
             
            "deadzone": 0.5,
         | 
| 80 | 
            +
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
         | 
| 81 | 
             
            ]
         | 
| 82 | 
             
            }
         | 
| 83 | 
             
            toggle_flycam={
         | 
| 84 | 
             
            "deadzone": 0.5,
         | 
| 85 | 
            +
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":67,"key_label":0,"unicode":0,"echo":false,"script":null)
         | 
| 86 | 
             
            ]
         | 
| 87 | 
             
            }
         | 
| 88 | 
             
            cam_down={
         | 
| 89 | 
             
            "deadzone": 0.5,
         | 
| 90 | 
            +
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194326,"key_label":0,"unicode":0,"echo":false,"script":null)
         | 
| 91 | 
             
            ]
         | 
| 92 | 
             
            }
         | 
| 93 | 
             
            cam_up={
         | 
| 94 | 
             
            "deadzone": 0.5,
         | 
| 95 | 
            +
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":0,"echo":false,"script":null)
         | 
| 96 | 
             
            ]
         | 
| 97 | 
             
            }
         | 
| 98 | 
             
            human_control={
         | 
| 99 | 
             
            "deadzone": 0.5,
         | 
| 100 | 
            +
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":72,"key_label":0,"unicode":0,"echo":false,"script":null)
         | 
| 101 | 
             
            ]
         | 
| 102 | 
             
            }
         | 
| 103 | 
             
            toggle_orbitcam={
         | 
| 104 | 
             
            "deadzone": 0.5,
         | 
| 105 | 
            +
            "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":79,"key_label":0,"unicode":0,"echo":false,"script":null)
         | 
| 106 | 
             
            ]
         | 
| 107 | 
             
            }
         | 
| 108 |  | 
    	
        projectile.gd
    CHANGED
    
    | @@ -32,7 +32,7 @@ func _on_projectile_area_entered(area): | |
| 32 | 
             
            	#explode()  
         | 
| 33 | 
             
            	queue_free()
         | 
| 34 |  | 
| 35 | 
            -
            func _on_body_entered( | 
| 36 | 
             
            	#explode()
         | 
| 37 | 
             
            	queue_free()
         | 
| 38 |  | 
| @@ -44,5 +44,5 @@ func explode(): | |
| 44 | 
             
            	proj_impact.set_as_top_level(true)
         | 
| 45 |  | 
| 46 |  | 
| 47 | 
            -
            func _on_area_shape_entered( | 
| 48 | 
             
            	queue_free()
         | 
|  | |
| 32 | 
             
            	#explode()  
         | 
| 33 | 
             
            	queue_free()
         | 
| 34 |  | 
| 35 | 
            +
            func _on_body_entered(_body):
         | 
| 36 | 
             
            	#explode()
         | 
| 37 | 
             
            	queue_free()
         | 
| 38 |  | 
|  | |
| 44 | 
             
            	proj_impact.set_as_top_level(true)
         | 
| 45 |  | 
| 46 |  | 
| 47 | 
            +
            func _on_area_shape_entered(_area_rid, _area, _area_shape_index, _local_shape_index):
         | 
| 48 | 
             
            	queue_free()
         | 
