#!/bin/bash

# Default values
N_SAMPLES=1000
MAX_ATTEMPTS=1000
N=5
MIN_REGIONS=3
MAX_REGIONS=5
SHADOW_RATIO=0.1

# Parse command line arguments
while [[ $# -gt 0 ]]; do
  case $1 in
    --n_samples)
      N_SAMPLES="$2"
      shift 2
      ;;
    --max_attempts)
      MAX_ATTEMPTS="$2"
      shift 2
      ;;
    --n)
      N="$2"
      shift 2
      ;;
    --min_regions)
      MIN_REGIONS="$2"
      shift 2
      ;;
    --max_regions)
      MAX_REGIONS="$2"
      shift 2
      ;;
    --shadow_ratio)
      SHADOW_RATIO="$2"
      shift 2
      ;;
    *)
      echo "Unknown option: $1"
      exit 1
      ;;
  esac
done

# Print the parameters
echo "Generating Norinori puzzles with the following parameters:"
echo "  Grid size (n): $N"
echo "  Region range: $MIN_REGIONS-$MAX_REGIONS"
echo "  Shadow ratio: $SHADOW_RATIO"
echo "  Number of samples: $N_SAMPLES"
echo "  Max attempts per puzzle: $MAX_ATTEMPTS"

# Run the Python script
python3 games/tasks/norinori/scripts/norinori.py \
  --n_samples "$N_SAMPLES" \
  --max_attempts "$MAX_ATTEMPTS" \
  --n "$N" \
  --min_regions "$MIN_REGIONS" \
  --max_regions "$MAX_REGIONS" \
  --shadow_ratio "$SHADOW_RATIO"

# Check if the script executed successfully
if [ $? -eq 0 ]; then
  echo "Norinori puzzles generated successfully!"
else
  echo "Error generating Norinori puzzles."
  exit 1
fi