awslabs / sagemaker-battlesnake-ai
Conditional Complexity

The distribution of complexity of units (measured with McCabe index).

Intro
  • Conditional complexity (also called cyclomatic complexity) is a term used to measure the complexity of software. The term refers to the number of possible paths through a program function. A higher value ofter means higher maintenance and testing costs (infosecinstitute.com).
  • Conditional complexity is calculated by counting all conditions in the program that can affect the execution path (e.g. if statement, loops, switches, and/or operators, try and catch blocks...).
  • Conditional complexity is measured at the unit level (methods, functions...).
  • Units are classified in four categories based on the measured McCabe index: 1-5 (simple units), 6-10 (medium complex units), 11-25 (complex units), 26+ (very complex units).
Learn more...
Conditional Complexity Overall
  • There are 470 units with 7,163 lines of code in units (79.9% of code).
    • 0 very complex units (0 lines of code)
    • 4 complex units (364 lines of code)
    • 25 medium complex units (1,236 lines of code)
    • 39 simple units (1,142 lines of code)
    • 402 very simple units (4,421 lines of code)
0% | 5% | 17% | 15% | 61%
Legend:
51+
26-50
11-25
6-10
1-5
Alternative Visuals
Conditional Complexity per Extension
51+
26-50
11-25
6-10
1-5
py0% | 5% | 17% | 15% | 61%
Conditional Complexity per Logical Component
primary logical decomposition
51+
26-50
11-25
6-10
1-5
source/BattlesnakeGym/battlesnake_gym0% | 20% | 12% | 10% | 56%
source/RLlibEnv/training0% | 3% | 17% | 17% | 61%
source/MXNetEnv/training0% | 0% | 23% | 12% | 64%
source/RLlibEnv0% | 0% | 60% | 0% | 39%
deployment/LambdaGateway/src0% | 0% | 21% | 13% | 64%
source/RLlibEnv/inference0% | 0% | 8% | 17% | 73%
source/MXNetEnv0% | 0% | 0% | 34% | 65%
source/MXNetEnv/inference0% | 0% | 0% | 25% | 75%
source0% | 0% | 0% | 0% | 100%
deployment/CloudFormation/solution-assistant0% | 0% | 0% | 0% | 100%
Most Complex Units
Top 20 most complex units
Unit# linesMcCabe index# params
def step()
in source/BattlesnakeGym/battlesnake_gym/snake_gym.py
115 37 3
def deploy_model()
in source/RLlibEnv/training/common/sagemaker_rl/orchestrator/workflow/manager/experiment_manager.py
76 32 4
def _did_snake_collide()
in source/BattlesnakeGym/battlesnake_gym/snake_gym.py
90 29 3
def evaluate_model()
in source/RLlibEnv/training/common/sagemaker_rl/orchestrator/workflow/manager/experiment_manager.py
83 27 4
def trainer()
in source/MXNetEnv/training/training_src/dqn_run.py
71 25 17
def train_next_model()
in source/RLlibEnv/training/common/sagemaker_rl/orchestrator/workflow/manager/experiment_manager.py
67 25 4
def initialize_first_model()
in source/RLlibEnv/training/common/sagemaker_rl/orchestrator/workflow/manager/experiment_manager.py
65 21 3
def sync_experiment_state_with_ddb()
in source/RLlibEnv/training/common/sagemaker_rl/orchestrator/workflow/manager/experiment_manager.py
52 20 1
def _update_experiment_db_hosting_workflow_metadata()
in source/RLlibEnv/training/common/sagemaker_rl/orchestrator/workflow/manager/experiment_manager.py
77 19 2
def _get_ascii()
in source/BattlesnakeGym/battlesnake_gym/snake_gym.py
49 16 1
def join()
in source/RLlibEnv/training/common/sagemaker_rl/orchestrator/workflow/manager/experiment_manager.py
58 16 5
def _update_experiment_db_training_workflow_metadata()
in source/RLlibEnv/training/common/sagemaker_rl/orchestrator/workflow/manager/experiment_manager.py
55 15 2
def __init__()
in source/RLlibEnv/training/common/sagemaker_rl/orchestrator/workflow/manager/join_manager.py
57 15 13
def _convert_to_state()
in deployment/LambdaGateway/src/convert_utils.py
32 15 3
def make_from_list()
in source/BattlesnakeGym/battlesnake_gym/snake.py
36 14 4
def simulate()
in source/RLlibEnv/heuristics_utils.py
69 14 5
def _update_model_table_evaluation_states()
in source/RLlibEnv/training/common/sagemaker_rl/orchestrator/workflow/manager/model_manager.py
56 14 1
def get_snake_map()
in source/BattlesnakeGym/battlesnake_gym/snake.py
35 13 2
def copy_checkpoints_to_model_output()
in source/RLlibEnv/training/common/sagemaker_rl/ray_launcher.py
27 13 1
def wait_for_s3_object()
in source/RLlibEnv/training/common/misc.py
42 12 10