;####### Formations reworked by Germanicu5 in cooperation with Point Blank #######
;
;
;   This file describes the unit group formation templates, any number of group formations can be specified
;   these templates are used to give a group of units a formation, the units available  in the group may not
;   totally fit the template in which case a best-fit is determined when the formation is created
;
;   Formation block positions can either be specified with a relative normalised (x,z) or they can be specified
;   relative to another formation block (when specifying in this manner rotation CANNOT be given)
;   a formation must be described entirely in one method or the other
;
;
;   formation                       the name given to this formation template
;
;   formation purposes              hints to ai for using this formation
;
;   ai_priority                     hint to the ai, denotes priority of using this template
;
;   BLOCK SPEC
;
;   min_units <VALUE>               minimum number of units block can have
;   max_units <VALUE>               maximum number of units block can have
;   not_general                     this block cannot contain the general unit
;   unit_type                       specifies units that can be allocated to the block
;                                   either : -
;                                               any
;                                               phalanx
;                                               non_phalanx_spear
;                                               chanting_screeching
;                                               ranged_missile_infantry
;                                               elephants
;                                               heavy_chariots
;                                               pilum_infantry
;                                               general_unit
;                                               <UNIT_CLASS> <UNIT_CATEGORY> <PRIORITY>
;                                   the priority dictates the order of assigning different unit types
;                                   a priority of zero means that type will only ever be assigned to this block
;                                   to fulfill block minimums
;   default_melee_state <OPTIONAL>  the melee state that will be assigned to units
;                                   in the formation
;   unit_formation                  the formation the units within this block will be in (wedge, square, ...)
;   unit_density                    either loose or close
;	min_unit_width					minimum unit width in men
;	max_unit_width					maximum unit width in men
;   block_formation                 the formation to organise the block into    (square, column, line)
;   normalised_pos                  (x,z) position relative to the center of the template (in normalised coords)
;   normalised_rot                  rotation in degress relative to the orientation of the template
;   block_relative_pos              b x z (x,z) position (in metres) relative to formation block b
;   inter_unit_spacing              distance to space units (in metres)
;   priority                        dictates the order in which units are assigned to the block


;****************************************************************
; Triple Line. Missile troops in front, foot, in second row
; mounted in third row
;****************************************************************
begin_formation ai_triple_missiles_in_front  ; ai_attack_defend_anti_cavalry
    ;;; purpose flags
	attack
    defend
    anti_cavalry
			
    ai_priority     1.0

    begin_block 0
        max_units               4
        unit_type               skirmish infantry    1.0
	;default_melee_state	fire_at_will_and_skirmish
        ;unit_density            close
		min_unit_width			30
		max_unit_width			30
        block_formation         line
        block_relative_pos      0 0.0 0.0 
        inter_unit_spacing      1.0
        priority                1.0
    end_block
    begin_block 1
        max_units               4
        unit_type               skirmish infantry    0.9
	;default_melee_state	fire_at_will_and_skirmish
        ;unit_density            close
		min_unit_width			30
		max_unit_width			30
        block_formation         line
        block_relative_pos      0 0.0 -0.5
        inter_unit_spacing      1.0
        priority                0.9
    end_block
    begin_block 2
        max_units               4
        unit_type               skirmish infantry    0.8
	;default_melee_state	fire_at_will_and_skirmish
        ;unit_density            close
		min_unit_width			30
		max_unit_width			30
        block_formation         line
        block_relative_pos      1 0.0 -0.5
        inter_unit_spacing      1.0
        priority                0.8
    end_block
    begin_dummy_block 3
        spans 0 1 2
    end_dummy_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; the infantry units
    begin_dummy_block 4
	spans 0 1 2 3
     end_dummy_block

    begin_block 5
        max_units               2
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      4 0.0 -1.0
        inter_unit_spacing      0.0
        priority                0.9
    end_block
    begin_block 6
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      5 -1.0 0.0
        inter_unit_spacing      0.0
        priority                0.8
    end_block
    begin_block 7
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      5 1.0 0.0
        inter_unit_spacing      0.0
        priority                0.8
    end_block
    begin_block 8
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      6 -1.0 0.0
        inter_unit_spacing      0.0
        priority                0.7
    end_block
    begin_block 9
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      7 1.0 0.0
        inter_unit_spacing      0.0
        priority                0.7
    end_block
    begin_block 10
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      8 -1.0 0.0
        inter_unit_spacing      0.0
        priority                0.6
    end_block
    begin_block 11
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      9 1.0 0.0
        inter_unit_spacing      0.0
        priority                0.6
    end_block
    begin_dummy_block 12
        spans 5 6 7 8 9 10 11
    end_dummy_block

    begin_block 13
        max_units               6
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		min_unit_width			20
		max_unit_width			25
        block_formation         line
        block_relative_pos      4 0.0 -15.0
        inter_unit_spacing      0.0
        priority                0.4
    end_block
    begin_block 14
        max_units               6
        unit_type               infantry	    0.2
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		min_unit_width			20
		max_unit_width			30
        block_formation         line
        block_relative_pos      13 0.0 -2.0
        inter_unit_spacing      0.0
        priority                0.3
    end_block
	begin_block 15
        max_units               6
        unit_type               infantry	    0.1
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		min_unit_width			20
		max_unit_width			30
        block_formation         line
        block_relative_pos      14 0.0 -2.0
        inter_unit_spacing      0.0
        priority                0.2
    end_block
    begin_block 16
        max_units               6
        unit_type               missile infantry	1.0
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		min_unit_width			20
		max_unit_width			30
        block_formation         line
        block_relative_pos      15 0.0 -2.0
        inter_unit_spacing      0.0
        priority                1.0
    end_block

    begin_dummy_block 17
        spans 4 12 13 14 15 16
    end_dummy_block

    begin_dummy_block 18
	spans 3 17
    end_dummy_block
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; missile cavalry

    begin_block 19
	max_units               3
        unit_type               missile cavalry 1.0
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      18 -20.0 -5.0
        inter_unit_spacing      2.0
        priority                1.0
    end_block
    begin_block 20
	max_units               3
        unit_type               missile cavalry 1.0
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      18 20.0 -5.0
        inter_unit_spacing      2.0
        priority                1.0
    end_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; cavalry

    begin_block 21
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      20 0.0 -10.0
        inter_unit_spacing      2
        priority                0.9
    end_block
    begin_block 22
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      19 0.0 -10.0
        inter_unit_spacing      2
        priority                0.9
    end_block
    begin_block 23
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      21 2.0 0
        inter_unit_spacing      2
        priority                0.7
    end_block
    begin_block 24
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      22 -2.0 0
        inter_unit_spacing      2
        priority                0.7
    end_block
    begin_block 25
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      23 2.0 0
        inter_unit_spacing      2
        priority                0.6
    end_block
    begin_block 26
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      24 -2.0 0
        inter_unit_spacing      2
        priority                0.6
    end_block
    begin_block 27
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      21 0.0 -5
        inter_unit_spacing      2
        priority                0.5
    end_block
    begin_block 28
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      22 0.0 -5
        inter_unit_spacing      2
        priority                0.5
    end_block
    begin_block 29
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      27 2.0 0
        inter_unit_spacing      2
        priority                0.4
    end_block
    begin_block 30
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      28 -2.0 0
        inter_unit_spacing      2
        priority                0.4
    end_block
    begin_block 31
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      29 2.0 0
        inter_unit_spacing      2
        priority                0.3
    end_block
    begin_block 32
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      30 -2.0 0
        inter_unit_spacing      2
        priority                0.3
    end_block

    begin_block 33
        max_units               3
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      29 0 -5.0
        inter_unit_spacing      2
        priority                0.2
    end_block
    begin_block 34
        max_units               3
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      30 0 -5.0
        inter_unit_spacing      2
        priority                0.2
    end_block
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ;; put the artillery and handlers behind everyone

    begin_block 35
        unit_type                   handler             1.0
        unit_type                   siege               1.0
        block_formation             line
        block_relative_pos          18 0.0 -5.0
        inter_unit_spacing          5.0
        priority                    1.0
    end_block
    begin_block 36
        unit_type               cavalry      0.1
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      35 0 -2.0
        inter_unit_spacing      2
        priority                0.1
    end_block

    ;;; special general block
    begin_block 37
        min_units               1
        max_units               1
        unit_type               general_unit            1.0
        unit_density            close
        block_formation         line
        block_relative_pos      36 0 -2.0
        inter_unit_spacing      20.0
        priority                1.0
    end_block

    main_line 5
end_formation


begin_formation ai_attack_defend_anti_infantry
;general-purpose defense formation,layered skirmish-spears/swords-swords
    ;;; purpose flags
    attack
    defend
    anti_infantry	
		
    ai_priority     1.0

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; the missile units


    begin_block 0
        max_units               4
        unit_type               skirmish infantry    1.0
	;default_melee_state	fire_at_will_and_skirmish
        ;unit_density            close
		;min_unit_width			30
		;max_unit_width			30
        block_formation         line
        block_relative_pos      0 0.0 0.0 
        inter_unit_spacing      1.0
        priority                1.0
    end_block
    begin_block 1
        max_units               4
        unit_type               skirmish infantry    0.9
	;default_melee_state	fire_at_will_and_skirmish
        ;unit_density            close
		;min_unit_width			30
		;max_unit_width			30
        block_formation         line
        block_relative_pos      0 0.0 -2.0
        inter_unit_spacing      1.0
        priority                0.9
    end_block
    begin_block 2
        max_units               4
        unit_type               skirmish infantry    0.8
	;default_melee_state	fire_at_will_and_skirmish
        ;unit_density            close
		;min_unit_width			30
		;max_unit_width			30
        block_formation         line
        block_relative_pos      1 0.0 -2.0
        inter_unit_spacing      1.0
        priority                0.8
    end_block
    begin_dummy_block 3
        spans 0 1 2
    end_dummy_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; the infantry units
    begin_dummy_block 4
	spans 0 1 2 3
     end_dummy_block

    begin_block 5
        max_units               2
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		;min_unit_width			20
		;max_unit_width			25
        block_formation         line
        block_relative_pos      4 0.0 -2.0
        inter_unit_spacing      0.0
        priority                0.9
    end_block
    begin_block 6
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		;min_unit_width			20
		;max_unit_width			25
        block_formation         line
        block_relative_pos      5 -1.0 0.0
        inter_unit_spacing      0.0
        priority                0.8
    end_block
    begin_block 7
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		;min_unit_width			20
		;max_unit_width			25
        block_formation         line
        block_relative_pos      5 1.0 0.0
        inter_unit_spacing      0.0
        priority                0.8
    end_block
    begin_block 8
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		;min_unit_width			20
		;max_unit_width			25
        block_formation         line
        block_relative_pos      6 -1.0 0.0
        inter_unit_spacing      0.0
        priority                0.7
    end_block
    begin_block 9
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		;min_unit_width			20
		;max_unit_width			25
        block_formation         line
        block_relative_pos      7 1.0 0.0
        inter_unit_spacing      0.0
        priority                0.7
    end_block
    begin_dummy_block 10
        spans 5 6 7 8 9
    end_dummy_block
    begin_block 11
        max_units               6
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		;min_unit_width			20
		;max_unit_width			20
        block_formation         line
        block_relative_pos      10 0.0 -2.0
        inter_unit_spacing      0.0
        priority                0.4
    end_block
    begin_block 12
        max_units               6
        unit_type               infantry	    1.0
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		;min_unit_width			25
		;max_unit_width			40
        block_formation         line
        block_relative_pos      11 0.0 -2.0
        inter_unit_spacing      0.0
        priority                0.3
    end_block
    begin_block 13
        max_units               6
        unit_type               infantry	    1.0
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		;min_unit_width			25
		;max_unit_width			40
        block_formation         line
        block_relative_pos      12 0.0 -2.0
        inter_unit_spacing      0.0
        priority                0.2
    end_block	
    begin_block 14
        max_units               6
        unit_type               missile infantry	1.0
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		;min_unit_width			20
		;max_unit_width			30
        block_formation         line
        block_relative_pos      13 0.0 -2.0
        inter_unit_spacing      0.0
        priority                1.0
    end_block

    begin_dummy_block 15
        spans 4 10 11 12 13 14
    end_dummy_block

    begin_dummy_block 16
	spans 3 15
    end_dummy_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; missile cavalry

    begin_block 17
	max_units               3
        unit_type               missile cavalry 1.0
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      16 -20.0 -5.0
        inter_unit_spacing      2.0
        priority                1.0
    end_block
    begin_block 18
	max_units               3
        unit_type               missile cavalry 1.0
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      16 20.0 -5.0
        inter_unit_spacing      2.0
        priority                1.0
    end_block

    begin_dummy_block 19
	spans 17 18
    end_dummy_block
    begin_dummy_block 20
	spans 18 19
    end_dummy_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; cavalry

    begin_block 21
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      18 0.0 -10.0
        inter_unit_spacing      2
        priority                0.9
    end_block
    begin_block 22
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      17 0.0 -10.0
        inter_unit_spacing      2
        priority                0.9
    end_block
    begin_block 23
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      21 2.0 0
        inter_unit_spacing      2
        priority                0.7
    end_block
    begin_block 24
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      22 -2.0 0
        inter_unit_spacing      2
        priority                0.7
    end_block
    begin_block 25
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      23 2.0 0
        inter_unit_spacing      2
        priority                0.6
    end_block
    begin_block 26
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      24 -2.0 0
        inter_unit_spacing      2
        priority                0.6
    end_block
    begin_block 27
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      21 0.0 -5
        inter_unit_spacing      2
        priority                0.5
    end_block
    begin_block 28
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      22 0.0 -5
        inter_unit_spacing      2
        priority                0.5
    end_block
    begin_block 29
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      27 2.0 0
        inter_unit_spacing      2
        priority                0.4
    end_block
    begin_block 30
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      28 -2.0 0
        inter_unit_spacing      2
        priority                0.4
    end_block
    begin_block 31
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      29 2.0 0
        inter_unit_spacing      2
        priority                0.3
    end_block
    begin_block 32
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      30 -2.0 0
        inter_unit_spacing      2
        priority                0.3
    end_block

    begin_block 33
        max_units               3
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      29 0 -5.0
        inter_unit_spacing      2
        priority                0.2
    end_block
    begin_block 34
        max_units               3
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      30 0 -5.0
        inter_unit_spacing      2
        priority                0.2
    end_block
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ;; put the artillery and handlers behind everyone

    begin_block 35
        unit_type                   handler             1.0
        unit_type                   siege               1.0
        block_formation             line
        block_relative_pos          16 0.0 -5.0
        inter_unit_spacing          5.0
        priority                    1.0
    end_block
    begin_block 36
        unit_type               cavalry      0.1
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      35 0 -2.0
        inter_unit_spacing      2
        priority                0.1
    end_block

    ;;; special general block
    begin_block 37
        min_units               1
        max_units               1
        unit_type               general_unit            1.0
        unit_density            close
        block_formation         line
        block_relative_pos      36 0 -2.0
        inter_unit_spacing      20.0
        priority                1.0
    end_block

    main_line 5

end_formation



begin_formation horse_archers
;general-purpose defense formation,layered skirmish-spears/swords-swords
    ;;; purpose flags
    defend
    attack			
    ai_priority     0.0

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; the missile units


    begin_block 0
        max_units               4
        unit_type               skirmish cavalry 1.0
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			20
		;max_unit_width			30
        block_formation         line
        block_relative_pos      0 0 0
        inter_unit_spacing      2.0
        priority                1.0
    end_block
    begin_block 1
        max_units               4
        unit_type               missile cavalry 0.8
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			20
		;max_unit_width			30
        block_formation         line
        block_relative_pos      0 0 -2
        inter_unit_spacing      2.0
        priority                0.8
    end_block
    begin_dummy_block 2
	spans 0 1
    end_dummy_block
    begin_dummy_block 3
        spans 0 1
    end_dummy_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; the infantry units
    begin_block 4
        max_units               6
        unit_type               skirmish infantry      1.0
        ;unit_formation          square, phalanx, schiltrom
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			30
		;max_unit_width			30
        block_formation         line
        block_relative_pos      3 0.0 -2.0
        inter_unit_spacing      0.0
        priority                1.0
    end_block

    begin_block 5
        max_units               2
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      4 0.0 -5.0
        inter_unit_spacing      0.0
        priority                0.9
    end_block
    begin_block 6
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      5 -1.0 0.0
        inter_unit_spacing      0.0
        priority                0.8
    end_block
    begin_block 7
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      5 1.0 0.0
        inter_unit_spacing      0.0
        priority                0.8
    end_block
    begin_block 8
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      6 -1.0 0.0
        inter_unit_spacing      0.0
        priority                0.7
    end_block
    begin_block 9
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      7 1.0 0.0
        inter_unit_spacing      0.0
        priority                0.7
    end_block
    begin_dummy_block 10
        spans 5 6 7 8 9
    end_dummy_block
    begin_block 11
        max_units               6
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      10 0.0 -3.0
        inter_unit_spacing      0.0
        priority                0.4
    end_block
    begin_block 12
        max_units               6
        unit_type               infantry	    1.0
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		;min_unit_width			20
		;max_unit_width			30
        block_formation         line
        block_relative_pos      11 0.0 -2.0
        inter_unit_spacing      0.0
        priority                0.3
    end_block
    begin_block 13
        max_units               6
        unit_type               missile infantry		0.1
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		;min_unit_width			30
		;max_unit_width			40
        block_formation         line
        block_relative_pos      12 0.0 -2.0
        inter_unit_spacing      0.0
        priority                1.0
    end_block

    begin_dummy_block 14
        spans 4 10 11 12 13
    end_dummy_block

    begin_dummy_block 15
	spans 3 14
    end_dummy_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; missile cavalry

    begin_block 16
        max_units               4
        unit_type               missile cavalry 0.9
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      15 -20.0 -5.0
        inter_unit_spacing      2.0
        priority                0.9
    end_block
    begin_block 17
        max_units               4
        unit_type               missile cavalry 0.9
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      15 20.0 -5.0
        inter_unit_spacing      2.0
        priority                0.9
    end_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; cavalry

    begin_dummy_block 18
	spans 12 13
    end_dummy_block
    begin_dummy_block 19
	spans 12 13
    end_dummy_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; cavalry

    begin_block 20
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      17 0.0 -10.0
        inter_unit_spacing      2
        priority                0.9
    end_block
    begin_block 21
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      16 0.0 -10.0
        inter_unit_spacing      2
        priority                0.9
    end_block
    begin_block 22
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      20 2.0 0
        inter_unit_spacing      2
        priority                0.7
    end_block
    begin_block 23
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      21 -2.0 0
        inter_unit_spacing      2
        priority                0.7
    end_block
    begin_block 24
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      22 2.0 0
        inter_unit_spacing      2
        priority                0.6
    end_block
    begin_block 25
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      23 -2.0 0
        inter_unit_spacing      2
        priority                0.6
    end_block
    begin_block 26
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      20 0.0 -5
        inter_unit_spacing      2
        priority                0.5
    end_block
    begin_block 27
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      21 0.0 -5
        inter_unit_spacing      2
        priority                0.5
    end_block
    begin_block 28
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      26 2.0 0
        inter_unit_spacing      2
        priority                0.4
    end_block
    begin_block 29
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      27 -2.0 0
        inter_unit_spacing      2
        priority                0.4
    end_block
    begin_block 30
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      28 2.0 0
        inter_unit_spacing      2
        priority                0.3
    end_block
    begin_block 31
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      29 -2.0 0
        inter_unit_spacing      2
        priority                0.3
    end_block

    begin_block 32
        max_units               3
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      28 0 -5.0
        inter_unit_spacing      2
        priority                0.2
    end_block
    begin_block 33
        max_units               3
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      29 0 -5.0
        inter_unit_spacing      2
        priority                0.2
    end_block

    begin_block 34
        unit_type                   handler             1.0
        unit_type                   siege               1.0
        block_formation             line
        block_relative_pos          15 0.0 -5.0
        inter_unit_spacing          5.0
        priority                    1.0
    end_block
    begin_block 35
        unit_type               cavalry      0.1
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      34 0 -2.0
        inter_unit_spacing      2
        priority                0.1
    end_block

    ;;; special general block
    begin_block 36
        min_units               1
        max_units               1
        unit_type               general_unit            1.0
        unit_density            close
        block_formation         line
        block_relative_pos      35 0 -2.0
        inter_unit_spacing      20.0
        priority                1.0
    end_block
    main_line 5

end_formation


begin_formation heavy_cavalry
    ;;; purpose flags
    attack			
    ai_priority     0.0

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; the missile units


    begin_block 0
        max_units               4
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               light cavalry      0.8
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			30
		;max_unit_width			30
        block_formation         line
        block_relative_pos      0 0 0
        inter_unit_spacing      2.0
        priority                1.0
    end_block
    begin_block 1
        max_units               4
        unit_type               heavy cavalry      0.9
        unit_type               spearmen cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			30
		;max_unit_width			30
        block_formation         line
        block_relative_pos      0 0 -2
        inter_unit_spacing      2.0
        priority                0.8
    end_block
    begin_dummy_block 2
	spans 0 1
    end_dummy_block
    begin_dummy_block 3
        spans 0 1
    end_dummy_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; the infantry units
    begin_block 4
        max_units               6
        unit_type               skirmish infantry      1.0
        ;unit_formation          square, phalanx, schiltrom
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			30
		;max_unit_width			30
        block_formation         line
        block_relative_pos      3 0.0 -2.0
        inter_unit_spacing      0.0
        priority                1.0
    end_block

    begin_block 5
        max_units               2
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      4 0.0 -5.0
        inter_unit_spacing      0.0
        priority                0.9
    end_block
    begin_block 6
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      5 -1.0 0.0
        inter_unit_spacing      0.0
        priority                0.8
    end_block
    begin_block 7
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      5 1.0 0.0
        inter_unit_spacing      0.0
        priority                0.8
    end_block
    begin_block 8
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      6 -1.0 0.0
        inter_unit_spacing      0.0
        priority                0.7
    end_block
    begin_block 9
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      7 1.0 0.0
        inter_unit_spacing      0.0
        priority                0.7
    end_block
    begin_dummy_block 10
        spans 5 6 7 8 9
    end_dummy_block
    begin_block 11
        max_units               6
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      10 0.0 -3.0
        inter_unit_spacing      0.0
        priority                0.4
    end_block
    begin_block 12
        max_units               6
        unit_type               infantry	    1.0
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		;min_unit_width			20
		;max_unit_width			30
        block_formation         line
        block_relative_pos      11 0.0 -2.0
        inter_unit_spacing      0.0
        priority                0.3
    end_block
    begin_block 13
        max_units               6
        unit_type               missile infantry		0.1
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		;min_unit_width			30
		;max_unit_width			40
        block_formation         line
        block_relative_pos      12 0.0 -2.0
        inter_unit_spacing      0.0
        priority                1.0
    end_block

    begin_dummy_block 14
        spans 4 10 11 12 13
    end_dummy_block

    begin_dummy_block 15
	spans 3 14
    end_dummy_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; missile cavalry

    begin_block 16
        max_units               4
        unit_type               missile cavalry 0.9
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      15 -20.0 -10.0
        inter_unit_spacing      2.0
        priority                0.9
    end_block
    begin_block 17
        max_units               4
        unit_type               missile cavalry 0.9
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      15 20.0 -10.0
        inter_unit_spacing      2.0
        priority                0.9
    end_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; cavalry

    begin_dummy_block 18
	spans 12 13
    end_dummy_block
    begin_dummy_block 19
	spans 12 13
    end_dummy_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; cavalry

    begin_block 20
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      17 0.0 -10.0
        inter_unit_spacing      2
        priority                0.9
    end_block
    begin_block 21
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      16 0.0 -10.0
        inter_unit_spacing      2
        priority                0.9
    end_block
    begin_block 22
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      20 2.0 0
        inter_unit_spacing      2
        priority                0.7
    end_block
    begin_block 23
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      21 -2.0 0
        inter_unit_spacing      2
        priority                0.7
    end_block
    begin_block 24
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      22 2.0 0
        inter_unit_spacing      2
        priority                0.6
    end_block
    begin_block 25
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      23 -2.0 0
        inter_unit_spacing      2
        priority                0.6
    end_block
    begin_block 26
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      20 0.0 -5
        inter_unit_spacing      2
        priority                0.5
    end_block
    begin_block 27
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      21 0.0 -5
        inter_unit_spacing      2
        priority                0.5
    end_block
    begin_block 28
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      26 2.0 0
        inter_unit_spacing      2
        priority                0.4
    end_block
    begin_block 29
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      27 -2.0 0
        inter_unit_spacing      2
        priority                0.4
    end_block
    begin_block 30
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      28 2.0 0
        inter_unit_spacing      2
        priority                0.3
    end_block
    begin_block 31
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      29 -2.0 0
        inter_unit_spacing      2
        priority                0.3
    end_block

    begin_block 32
        max_units               3
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      28 0 -5.0
        inter_unit_spacing      2
        priority                0.2
    end_block
    begin_block 33
        max_units               3
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      29 0 -5.0
        inter_unit_spacing      2
        priority                0.2
    end_block

    begin_block 34
        unit_type                   handler             1.0
        unit_type                   siege               1.0
        block_formation             line
        block_relative_pos          15 0.0 -5.0
        inter_unit_spacing          5.0
        priority                    1.0
    end_block
    begin_block 35
        unit_type               cavalry      0.1
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      34 0 -2.0
        inter_unit_spacing      2
        priority                0.1
    end_block

    ;;; special general block
    begin_block 36
        min_units               1
        max_units               1
        unit_type               general_unit            1.0
        unit_density            close
        block_formation         line
        block_relative_pos      35 0 -2.0
        inter_unit_spacing      20.0
        priority                1.0
    end_block
    main_line 5

end_formation


;****************************************************************
; Bridge assault column
;****************************************************************
begin_formation ai_crossing_assault_force

    ;;; purpose flags
    crossing_assault_force
    ai_priority                 1

    ;;; front block
    begin_block 0
        min_units               1
        max_units				3
        not_general
        unit_type               heavy infantry      1.0
        unit_density            close
        max_unit_width          40
        block_formation         column
        block_relative_pos      0 0.0 0.0
        inter_unit_spacing      2.0
        priority                0.9
    end_block

    ;;; behind
    begin_block 1
        max_units               2
        not_general
        unit_type               heavy infantry      1.0
        unit_type               light infantry      0.9
        unit_type               heavy cavalry       0.7
        unit_type               light cavalry       0.7
        unit_type               skirmish cavalry    0.7
        unit_type               heavy infantry      0.6
        unit_type               light infantry      0.6
        unit_type               skirmish infantry   0.6
        unit_type               any                 0.1
        unit_density            close
        max_unit_width          20
        block_formation         column
        block_relative_pos      0 0.0 -2.0
        inter_unit_spacing      2.0
        priority                0.8

    end_block

    ;;; further behind
    begin_block 2
        max_units               3
        not_general
        unit_type               light infantry      0.9
        unit_type               heavy cavalry       0.7
        unit_type               light cavalry       0.7
        unit_type               skirmish cavalry    0.7
        unit_type               missile cavalry     0.7
        unit_type               heavy infantry      0.6
        unit_type               light infantry      0.6
        unit_type               skirmish infantry   0.6
        unit_type               any                 0.1
        unit_density            close
        max_unit_width          20
        block_formation         column
        block_relative_pos      1 0.0 -2.0
        inter_unit_spacing      2.0
        priority                0.6
    end_block

    ;;; main body of units (everything else)
    begin_block 3
        unit_type               any                 1.0
        unit_density            close
        block_formation         column
        block_relative_pos      2 0.0 -8.0
        inter_unit_spacing      2.0
        priority                0.4
    end_block

    ;;; if we have any swimming units put them on the flanks so they can swim over
    ;;; and increase our attacking bandwidth
    begin_dummy_block 4
        spans 0 1 2 3
    end_dummy_block

    begin_block 5
        ;;; at the moment all swimming units have to swim   max_units               2
        not_general
        unit_type               swimming            1.0
        unit_density            close
        block_formation         line
        block_relative_pos      4 -10.0 0
        inter_unit_spacing      2.0
        priority                1.0
    end_block

    begin_block 6
   		not_general
        unit_type               swimming            1.0
        unit_density            close
        block_formation         line
        block_relative_pos      4 10.0 0
        inter_unit_spacing      2.0
        priority                1.0
    end_block

end_formation


;****************************************************************
; Bridge assault crossing buffer
;****************************************************************

begin_formation ai_crossing_assault_buffer
	
	;;; purpose flags
	crossing_assault_buffer
	ai_priority 1
	
	begin_block 0
        unit_type               heavy infantry      1.0
        unit_type               light infantry      0.9
        unit_type               missile infantry	0.4
        unit_type               missile cavalry		0.3
        unit_density			close
		max_unit_width			20
        block_formation			line
        normalised_pos			0.5		1.0
        normalised_rot			0
        inter_unit_spacing		2.0
        priority				1.0
	end_block
	
	begin_block 1
        unit_type               heavy infantry      1.0
        unit_type               light infantry      0.8
        unit_type               missile infantry	0.4
        unit_type               missile cavalry		0.3
        unit_density			close
		max_unit_width			20
        block_formation			line
        normalised_pos			0.8125	0.75
        normalised_rot			45
        inter_unit_spacing		2.0
        priority				0.5
	end_block
	
	begin_block 2
        unit_type               heavy infantry      1.0
        unit_type               light infantry      0.8
        unit_type               missile infantry	0.4
        unit_type               missile cavalry		0.3
        unit_density			close
		max_unit_width			20
        block_formation			line
        normalised_pos			0.1875	0.75
        normalised_rot			315
        inter_unit_spacing		2.0
        priority				0.5
	end_block
	
	begin_block 3
        unit_type               heavy infantry      1.0
        unit_type               light infantry      0.8
        unit_density			close
		max_unit_width			20
        block_formation			line
        normalised_pos			1.0		0.25
        normalised_rot			75
        inter_unit_spacing		2.0
        priority				0.2
	end_block
	
	begin_block 4
        unit_type               heavy infantry      1.0
        unit_type               light infantry      0.8
        unit_density			close
		max_unit_width			20
        block_formation			line
        normalised_pos			0.0		0.25
        normalised_rot			285
        inter_unit_spacing		2.0
        priority				0.2
	end_block
	
	begin_block 5
        unit_type               any					0.1
        unit_density			close
		max_unit_width			20
        block_formation			column
        normalised_pos			0.5		0.0
        normalised_rot			0
        inter_unit_spacing		2.0
        priority				0.1
	end_block
	
end_formation

;****************************************************************
; Bridge assault cover force
;****************************************************************
begin_formation ai_crossing_assault_cover

    crossing_assault_cover
    ai_priority                 1

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; the missile units
    begin_dummy_block 0                                         ;; centre slot left empty for assault column to pass through
        spacer 0.0 0.0 30 20
    end_dummy_block
    
    begin_block 1
        max_units               1
        not_general
        unit_type               missile infantry    1.0
        unit_type               missile cavalry     0.8
        unit_density            close
		min_unit_width			30
		max_unit_width			30
        block_formation         line
        block_relative_pos      0 1.0 0.0
        inter_unit_spacing      1.0
        priority                1.0
    end_block
    begin_block 2
        max_units               1
        not_general
        unit_type               missile infantry    1.0
        unit_type               missile cavalry    	0.8
        unit_density            close
		min_unit_width			30
		max_unit_width			30
        block_formation         line
        block_relative_pos      0 -1.0 0.0 
        inter_unit_spacing      1.0
        priority                1.0
    end_block
    begin_block 3
        max_units               1
        not_general
        unit_type               missile infantry    1.0
        unit_type               missile cavalry    	0.8
        unit_density            close
		min_unit_width			30
		max_unit_width			30
        block_formation         line
        block_relative_pos      1 1.0 0.0
        inter_unit_spacing      1.0
        priority                0.8
    end_block
    begin_block 4
        max_units               1
        not_general
        unit_type               missile infantry    1.0
        unit_type               missile cavalry    	0.8
        unit_density            close
		min_unit_width			30
		max_unit_width			30
        block_formation         line
        block_relative_pos      2 -1.0 0.0
        inter_unit_spacing      1.0
        priority                0.8
    end_block
    
    begin_block 5
        max_units               3
        not_general
        unit_type               missile infantry    1.0
        unit_type               siege               0.9
        unit_type               missile cavalry    	0.8
        unit_density            close
		min_unit_width			30
		max_unit_width			30
        block_formation         line
        block_relative_pos      1 0.0 -3.0
        inter_unit_spacing      1.0
        priority                1.0
    end_block
    begin_block 6
        max_units               3
        not_general
        unit_type               missile infantry    1.0
        unit_type               siege               0.9
        unit_type               missile cavalry    	0.8
        unit_density            close
		min_unit_width			30
		max_unit_width			30
        block_formation         line
        block_relative_pos      2 0.0 -3.0 
        inter_unit_spacing      1.0
        priority                1.0
    end_block
    begin_dummy_block 7
        spans 0 1 2 3 4 5 6
    end_dummy_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ;;; special general block
    begin_block 8
        max_units               1
        unit_type               general_unit            1.0
        unit_type				any						0.1	
        unit_density            close
        block_formation         line
        block_relative_pos      7 0 -5.0
        inter_unit_spacing      1.0
        priority                1.0
    end_block

end_formation


;****************************************************************
; Crossing Block
; For blocking a crossing against a cavalry heavy opponent
; Semicircular formation around end of crossing
;****************************************************************
begin_formation ai_crossing_block_cavalry

    crossing_block
    anti_cavalry
    ai_priority                 1

    ;; forward missile units
    begin_block 0
        max_units               2
        unit_type               missile infantry    1.0
        unit_density            close
		min_unit_width			30
		max_unit_width			60
        block_formation         line
        block_relative_pos      0 0.0 0.0
        inter_unit_spacing      3.0
        priority                1.0
    end_block
    begin_block 1
        max_units               6
        unit_type               missile infantry    1.0
        unit_density            close
		min_unit_width			30
		max_unit_width			60
        block_formation         line
        block_relative_pos      0 1.0 0.0
        inter_unit_spacing      3.0
        priority                0.8
    end_block
    begin_block 2
        max_units               6
        unit_type               missile infantry    1.0
        unit_density            close
		min_unit_width			30
		max_unit_width			60
        block_formation         line
        block_relative_pos      0 -1.0 0.0 
        inter_unit_spacing      3.0
        priority                0.8
    end_block
    begin_dummy_block 3
        spans 0 1 2
    end_dummy_block

    ;; forward melee units
    begin_block 4
        max_units               4
        unit_type               		spearmen infantry		1.0
        unit_type				heavy infantry			0.8
        unit_type				light infantry			0.4
        unit_density            close
		min_unit_width			20
		max_unit_width			20
        block_formation         line
        block_relative_pos      3 0.0 -3.0
        inter_unit_spacing      1.0
        priority                0.6
    end_block
    begin_block 5
        max_units               6
        unit_type				heavy infantry			1.0
        unit_type               		spearmen infantry		0.8
        unit_type				light infantry			0.4
        unit_density            close
		min_unit_width			20
		max_unit_width			20
        block_formation         line
        block_relative_pos      4 0.0 -2.0
        inter_unit_spacing      1.0
        priority                0.4
    end_block
    begin_block 6
        max_units               6
        unit_type				heavy cavalry			1.0
        unit_type               		light cavalry			0.8
        unit_density            close
		min_unit_width			20
		max_unit_width			20
        block_formation         line
        block_relative_pos      5 0.0 -3.0 
        inter_unit_spacing      1.0
        priority                0.4
    end_block
    begin_dummy_block 7
        spans 4 5 6
    end_dummy_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ;;; special general block
    begin_block 8
        min_units               1
        max_units               1
        unit_type               general_unit            1.0
        unit_density            close
        block_formation         line
        block_relative_pos      7 0 -3.0
        inter_unit_spacing      1.0
        priority                1.0
    end_block

    ;; put the artillery and handlers behind everyone

    begin_block 9
        unit_type                   any             	0.6
        unit_type                   siege               1.0
        block_formation             line
        block_relative_pos          8 0.0 -5.0
        inter_unit_spacing          3.0
        priority                    0.1
    end_block

end_formation


;****************************************************************
; Crossing Block
; For blocking a crossing against a infantry heavy opponent
;****************************************************************
begin_formation ai_crossing_block_infantry

    crossing_block
    anti_infantry
    ai_priority                 1

    ;; forward missile units
    begin_block 0
        max_units               2
        unit_type               missile infantry    1.0
        unit_density            close
		min_unit_width			30
		max_unit_width			60
        block_formation         line
        block_relative_pos      0 0.0 0.0
        inter_unit_spacing      3.0
        priority                1.0
    end_block
    begin_block 1
        max_units               6
        unit_type               missile infantry    1.0
        unit_density            close
		min_unit_width			30
		max_unit_width			60
        block_formation         line
        block_relative_pos      0 1.0 0.0
        inter_unit_spacing      3.0
        priority                0.8
    end_block
    begin_block 2
        max_units               6
        unit_type               missile infantry    1.0
        unit_density            close
		min_unit_width			30
		max_unit_width			60
        block_formation         line
        block_relative_pos      0 -1.0 0.0 
        inter_unit_spacing      3.0
        priority                0.8
    end_block
    begin_dummy_block 3
        spans 0 1 2
    end_dummy_block

    ;; forward melee units
    begin_block 4
        max_units               4
        unit_type				heavy infantry			1.0
        unit_type               		spearmen infantry		0.8
        unit_type				light infantry			0.4
        unit_density            close
		min_unit_width			20
		max_unit_width			20
        block_formation         line
        block_relative_pos      3 0.0 -3.0
        inter_unit_spacing      1.0
        priority                0.6
    end_block
    begin_block 5
        max_units               6
        unit_type				heavy infantry			1.0
        unit_type               		spearmen infantry		0.8
        unit_type				light infantry			0.4
        unit_density            close
		min_unit_width			20
		max_unit_width			20
        block_formation         line
        block_relative_pos      4 0.0 -2.0
        inter_unit_spacing      1.0
        priority                0.4
    end_block
    begin_block 6
        max_units               6
        unit_type				heavy cavalry			1.0
        unit_type               		light cavalry			0.8
        unit_density            close
		min_unit_width			20
		max_unit_width			20
        block_formation         line
        block_relative_pos      5 0.0 -3.0 
        inter_unit_spacing      1.0
        priority                0.4
    end_block
    begin_dummy_block 7
        spans 4 5 6
    end_dummy_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ;;; special general block
    begin_block 8
        min_units               1
        max_units               1
        unit_type               general_unit            1.0
        unit_density            close
        block_formation         line
        block_relative_pos      7 0 -3.0
        inter_unit_spacing      1.0
        priority                1.0
    end_block

    ;; put the artillery and handlers behind everyone

    begin_block 9
        unit_type                   any             	0.6
        unit_type                   siege               1.0
        block_formation             line
        block_relative_pos          8 0.0 -5.0
        inter_unit_spacing          3.0
        priority                    0.1
    end_block

end_formation




;****************************************************************
; Crossing Defend
; For defending a crossing when the odds are against us
; This variant is targetted towards a cavalry heavy opponent
;****************************************************************
begin_formation ai_crossing_defend_cavalry

    crossing_defend
    anti_cavalry
    ai_priority                 1
    
    ;; forward missile units
    begin_block 0
        max_units               2
        unit_type               missile infantry    1.0
        unit_type               missile cavalry    	0.8
        unit_density            close
		min_unit_width			30
		max_unit_width			30
        block_formation         line
        block_relative_pos      0 0.0 0.0
        inter_unit_spacing      3.0
        priority                1.0
    end_block
    begin_block 1
        max_units               6
        unit_type               missile infantry    1.0
        unit_type               missile cavalry    	0.8
        unit_density            close
		min_unit_width			30
		max_unit_width			30
        block_formation         line
        block_relative_pos      0 1.0 0.0
        inter_unit_spacing      3.0
        priority                0.8
    end_block
    begin_block 2
        max_units               6
        unit_type               missile infantry    1.0
        unit_type               missile cavalry    	0.8
        unit_density            close
		min_unit_width			30
		max_unit_width			30
        block_formation         line
        block_relative_pos      0 -1.0 0.0 
        inter_unit_spacing      3.0
        priority                0.8
    end_block
    begin_dummy_block 3
        spans 0 1 2
    end_dummy_block

    ;; forward melee units
    begin_block 4
        max_units               2
        unit_type               spearmen infantry		1.0
        unit_type				heavy infantry			0.8
        unit_type				light infantry			0.4
        unit_density            close
		min_unit_width			30
		max_unit_width			30
        block_formation         line
        block_relative_pos      3 0.0 -3.0
        inter_unit_spacing      1.0
        priority                0.6
    end_block
    begin_block 5
        max_units               6
        unit_type               spearmen infantry		1.0
        unit_type				heavy infantry			0.8
        unit_type				light infantry			0.4
        unit_density            close
		min_unit_width			30
		max_unit_width			30
        block_formation         line
        block_relative_pos      4 1.0 0.0
        inter_unit_spacing      1.0
        priority                0.4
    end_block
    begin_block 6
        max_units               6
        unit_type               spearmen infantry		1.0
        unit_type				heavy infantry			0.8
        unit_type				light infantry			0.4
        unit_density            close
		min_unit_width			30
		max_unit_width			30
        block_formation         line
        block_relative_pos      4 -1.0 0.0 
        inter_unit_spacing      1.0
        priority                0.4
    end_block
    begin_dummy_block 7
        spans 4 5 6
    end_dummy_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ;; put the artillery and handlers behind everyone

    begin_block 8
        unit_type                   any             	1.0
        unit_type                   siege               1.0
        block_formation             line
        block_relative_pos          7 0.0 -5.0
        inter_unit_spacing          1.0
        priority                    0.1
    end_block

    ;;; special general block
    begin_block 9
        min_units               1
        max_units               1
        unit_type               general_unit            1.0
        unit_density            close
        block_formation         line
        block_relative_pos      8 0 -5.0
        inter_unit_spacing      1.0
        priority                1.0
    end_block

end_formation




;****************************************************************
; Crossing Defend
; For defending a crossing when the odds are against us
; This variant is targetted towards an infantry heavy opponent
;****************************************************************
begin_formation ai_crossing_defend_infantry

    crossing_defend
    anti_infantry
    ai_priority                 1

    ;;; missile units in the centre
    begin_block 0
        max_units               3
        unit_type               missile infantry                1.0
        unit_type               missile cavalry                 0.8
        unit_density            close
        block_formation         line
        block_relative_pos      0 0.0 0.0
        inter_unit_spacing      2.0
        priority                1
    end_block

    ;;; protective shield of heavy infantry for the missile troops
    begin_block 1
        max_units               3
	unit_type		spearmen infantry		1.0
        unit_type               heavy infantry                  0.9
        unit_type               heavy cavalry                   0.8
        unit_type               light infantry                  0.7
        unit_type               light cavalry                   0.6
        unit_density            close
        block_formation         line
        block_relative_pos      0 0.0 15.0
        inter_unit_spacing      2.0
        priority                1.0
    end_block

    ;;; close support melee for shooters left flank
    begin_block 2
        max_units               2
        unit_type               heavy infantry                  0.9
        unit_type               light infantry                  0.7
        unit_type               skirmish infantry               0.7
        unit_type               heavy cavalry                   0.7
        unit_type               light cavalry                   0.7
        unit_type               skirmish cavalry                0.7
        block_formation         line
        block_relative_pos      1 -0.5 -7.0
        inter_unit_spacing      2.0
        priority                0.9
    end_block

    ;;; close support melee for shooters right flank
    begin_block 3
        max_units               2
        unit_type               heavy infantry                  0.9
        unit_type               light infantry                  0.7
        unit_type               skirmish infantry               0.7
        unit_type               heavy cavalry                   0.7
        unit_type               light cavalry                   0.7
        unit_type               skirmish cavalry                0.7
        block_formation         line
        block_relative_pos      1 0.5 -7.0
        inter_unit_spacing      2.0
        priority                0.9
    end_block

    ;;; fast moving left side outflankers
    begin_block 4
        max_units               2
        unit_type               heavy cavalry                   0.7
        unit_type               light cavalry                   0.7
        unit_type               skirmish cavalry                0.7
        block_formation         line
        block_relative_pos      0 -10.0 1.0
        inter_unit_spacing      2.0
        priority                0.6
    end_block

    ;;; melee troops to left of flank shooters
    begin_block 5
        max_units               2
        unit_type               heavy cavalry                   1.0
        unit_type               light cavalry                   0.7
        unit_type               skirmish cavalry                0.7
        block_formation         line
        block_relative_pos      0 10.0 1.0
        inter_unit_spacing      2.0
        priority                0.6
    end_block

    ;;; everyone else in the second line
    begin_block 6
        unit_type               any                             1.0
        block_formation         line
        block_relative_pos      0 0.0 -10.0
        inter_unit_spacing      2.0
        priority                0.1
    end_block

end_formation




;****************************************************************
; Wall Assault
; Siege engine in the centre, covering troops on the flanks
; other units in a column behind, waiting to go up the siege tower
;****************************************************************
begin_formation ai_wall_assault

    wall_assault_force
    ai_priority                                                 1


    ;;; artillery in front
    begin_dummy_block 0                                      
        spacer 0.0 0.0 20 5
    end_dummy_block

    ;; infantry covering artillery
    begin_block 1
	max_units               1
	not_general
        unit_type               spearmen infantry               1.4
	unit_type               phalanx		    		1.3
        unit_type               heavy infantry                  1.2
        unit_type               light infantry                  1.1
        unit_density            close
	min_unit_width			35
	max_unit_width			65
        block_formation         line
        block_relative_pos      0 0.0 -0.1
        inter_unit_spacing      0.0
        priority                1.0
    end_block

    ;;;;; next 3 blocks aren't used
    ;;; rams at the centre
    begin_block 2
	max_units 2
        unit_type               carrying_siege_engine ram       1.7
        unit_density            close
        block_formation         line
        block_relative_pos      1 0.0 -5.0
        inter_unit_spacing      10.0
        priority                1.0
    end_block

    ;; other engines left side
    begin_block 3
	max_units 1
        unit_type               carrying_siege_engine ladder    1.6
        unit_type               carrying_siege_engine tower     1.5
        unit_density            close
        block_formation         line
        block_relative_pos      2 -15.0 0.0
        inter_unit_spacing      5.0
        priority                1.0
    end_block

    ;; other engines right side
    begin_block 4
	max_units 1
        unit_type               carrying_siege_engine ladder    1.5
        unit_type               carrying_siege_engine tower     1.6
        unit_density            close
        block_formation         line
        block_relative_pos      2 15.0 0.0
        inter_unit_spacing      5.0
        priority                1.0
    end_block
    
    begin_dummy_block 5
        spans 0 1
    end_dummy_block

    ;; infantry behind 1
    begin_block 6
	max_units               4
	not_general
        unit_type               heavy infantry                  1.0
        unit_type               spearmen infantry               0.9
        unit_type               light infantry                  0.8
        unit_density            close
	min_unit_width			15
	max_unit_width			25
        block_formation         line
        block_relative_pos      5 0.0 -50.0
        inter_unit_spacing      7.5
        priority                0.9
    end_block

    ;; infantry behind 2
    begin_block 7
	max_units               4
        unit_type               heavy infantry                  1.0
        unit_type               spearmen infantry               0.9
        unit_type               light infantry                  0.8
	unit_type               missile infantry   		0.7
        unit_type               skirmish infantry   		0.6
        unit_density            close
	min_unit_width			15
	max_unit_width			25
        block_formation         line
        block_relative_pos      6 0.0 -10.0
        inter_unit_spacing      7.5
        priority                0.8
    end_block

    ;; infantry behind 3
    begin_block 8
	max_units               4
        unit_type               heavy infantry                  1.0
        unit_type               spearmen infantry               0.9
        unit_type               light infantry                  0.8
	unit_type               missile infantry   		0.7
        unit_type               skirmish infantry   		0.6
        unit_density            close
	min_unit_width			15
	max_unit_width			25
        block_formation         line
        block_relative_pos      7 0.0 -10.0
        inter_unit_spacing      7.5
        priority                0.7
    end_block

    begin_dummy_block 9
        spans 6 7 8
    end_dummy_block

    ;;; other rams on both sides
    begin_block 10
	;max_units 0
        unit_type               carrying_siege_engine ram       1.5
        unit_density            close
	block_formation         column
        block_relative_pos      6 -7.5 0.0
        inter_unit_spacing      1.0
        priority                1.0
    end_block

    begin_block 11
	;max_units 0
        unit_type               carrying_siege_engine ram       1.5
        unit_density            close
        block_formation         column
        block_relative_pos      6 7.5 0.0
        inter_unit_spacing      1.0
        priority                1.0
    end_block

    begin_dummy_block 12
        spans 9 10 11
    end_dummy_block

    ;; missile left 1
    begin_block 13
	max_units               3
	unit_type               missile infantry   		1.0
        unit_type               skirmish infantry   		0.9
        unit_density            close
	min_unit_width			30
	max_unit_width			40
        block_formation         column
        block_relative_pos      10 -7.5 -15.0
        inter_unit_spacing      5.0
        priority                1.0
    end_block

    ;; missile right 1
    begin_block 14
	max_units               3
	unit_type               missile infantry   		1.0
        unit_type               skirmish infantry   		0.9
        unit_density            close
	min_unit_width			30
	max_unit_width			40
        block_formation         column
        block_relative_pos      11 7.5 -15.0
        inter_unit_spacing      5.0
        priority                1.0
    end_block

    ;; missile left 2
    begin_block 15
	max_units               3
	unit_type               missile infantry   		1.0
        unit_type               skirmish infantry   		0.9
        unit_density            close
	min_unit_width			30
	max_unit_width			40
        block_formation         column
        block_relative_pos      13 -7.5 0.0
        inter_unit_spacing      5.0
        priority                0.9
    end_block

    ;; missile right 2
    begin_block 16
	max_units               3
	unit_type               missile infantry   		1.0
        unit_type               skirmish infantry   		0.9
        unit_density            close
	min_unit_width			30
	max_unit_width			40
        block_formation         column
        block_relative_pos      14 7.5 0.0
        inter_unit_spacing      5.0
        priority                0.9
    end_block

    begin_dummy_block 17
        spans 12 13 14 15 16
    end_dummy_block

    ;;; other infantry behind
    begin_block 18
	max_units               10
        unit_type               heavy infantry                  1.0
        unit_type               light infantry                  0.9
        unit_type               spearmen infantry               0.8
        unit_type               missile infantry	        0.7
        unit_type               skirmish infantry               0.6
 
        unit_density            close
		min_unit_width			25
		max_unit_width			25
        block_formation         line
        block_relative_pos      17 0.0 -1.0
        inter_unit_spacing      7.5
        priority                0.3
    end_block

    begin_dummy_block 19 
        spans 9 18
    end_dummy_block

    begin_block 20
        min_units               1
        max_units         	1
        unit_type               general_unit           1.0
        unit_density            close
        block_formation         line
        block_relative_pos      19 0 -70.0
        inter_unit_spacing      20.0
        priority                1.0
    end_block

    ;;; cavalry on both sides
    begin_block 21
        unit_type               heavy cavalry                   1.0
        unit_type               light cavalry                   0.9
        unit_type               missile cavalry                 0.8
        unit_type               skirmish cavalry                0.7
        unit_type               any                             0.1
		min_unit_width			12
		max_unit_width			16
        ;unit_density            close
        block_formation         line
        block_relative_pos      20 -10.0 10.0
        inter_unit_spacing      5.0
        priority                0.2
    end_block

    begin_block 22
        unit_type               heavy cavalry                   1.0
        unit_type               light cavalry                   0.9
        unit_type               missile cavalry                 0.8
        unit_type               skirmish cavalry                0.7
        unit_type               any                             0.1
        ;unit_density            close
	min_unit_width			12
	max_unit_width			16
        block_formation         line
        block_relative_pos      20 10.0 10.0
        inter_unit_spacing      5.0
        priority                0.2
    end_block

    ;; other engines left side
    begin_block 23
        unit_type               carrying_siege_engine ladder    1.6
        unit_type               carrying_siege_engine tower     1.5
        unit_density            close
        block_formation         line
        block_relative_pos      3 -80.0 0.0
        inter_unit_spacing      20.0
        priority                1.0
    end_block

    ;; other engines right side
    begin_block 24
        unit_type               carrying_siege_engine ladder    1.5
        unit_type               carrying_siege_engine tower     1.6
        unit_density            close
        block_formation         line
        block_relative_pos      4 80.0 0.0
        inter_unit_spacing      20.0
        priority                1.0
    end_block

end_formation


;****************************************************************
; Siege deployment
; The engines have already been assigned at this point
; Put rams in the centre front, other engines at the front either side
;****************************************************************
begin_formation deployment_siege

    standard_siege_attacker_deployment
    ai_priority                                                 1


    ;;; artillery in front
    begin_block 0
        unit_type               siege                           1.0
        unit_density            close
        block_formation         line
        block_relative_pos      0 0.0 0.0
        inter_unit_spacing      5.0
        priority                1.0
    end_block

    ;; infantry covering artillery
    begin_block 1
	max_units               1
	not_general
        unit_type               spearmen infantry               1.4
	unit_type               phalanx		    		1.3
        unit_type               heavy infantry                  1.2
        unit_type               light infantry                  1.1
        unit_density            close
	min_unit_width			35
	max_unit_width			65
        block_formation         line
        block_relative_pos      0 0.0 -0.1
        inter_unit_spacing      0.0
        priority                1.0
    end_block

    ;;; rams at the centre
    begin_block 2
	max_units 1
        unit_type               carrying_siege_engine ram       1.7
        unit_density            close
        block_formation         line
        block_relative_pos      1 0.0 -5.0
        inter_unit_spacing      5.0
        priority                1.0
    end_block

    ;; other engines left side
    begin_block 3
	max_units 1
        unit_type               carrying_siege_engine ladder    1.6
        unit_type               carrying_siege_engine tower     1.5
        unit_density            close
        block_formation         line
        block_relative_pos      2 -12.5 0.0
        inter_unit_spacing      5.0
        priority                1.0
    end_block

    ;; other engines right side
    begin_block 4
	max_units 1
        unit_type               carrying_siege_engine ladder    1.5
        unit_type               carrying_siege_engine tower     1.6
        unit_density            close
        block_formation         line
        block_relative_pos      2 12.5 0.0
        inter_unit_spacing      5.0
        priority                1.0
    end_block
    
    begin_dummy_block 5
        spans 0 1 2 3 4
    end_dummy_block

    ;; infantry behind 1
    begin_block 6
	max_units               4
	not_general
        unit_type               heavy infantry                  1.0
        unit_type               spearmen infantry               0.9
        unit_type               light infantry                  0.8
        unit_density            close
	min_unit_width			15
	max_unit_width			25
        block_formation         line
        block_relative_pos      5 0.0 -7.0
        inter_unit_spacing      7.5
        priority                0.9
    end_block

    ;; infantry behind 2
    begin_block 7
	max_units               4
        unit_type               heavy infantry                  1.0
        unit_type               spearmen infantry               0.9
        unit_type               light infantry                  0.8
	unit_type               missile infantry   		0.7
        unit_type               skirmish infantry   		0.6
        unit_density            close
	min_unit_width			15
	max_unit_width			25
        block_formation         line
        block_relative_pos      6 0.0 -5.0
        inter_unit_spacing      7.5
        priority                0.8
    end_block

    ;; infantry behind 3
    begin_block 8
	max_units               4
        unit_type               heavy infantry                  1.0
        unit_type               spearmen infantry               0.9
        unit_type               light infantry                  0.8
	unit_type               missile infantry   		0.7
        unit_type               skirmish infantry   		0.6
        unit_density            close
	min_unit_width			15
	max_unit_width			25
        block_formation         line
        block_relative_pos      7 0.0 -5.0
        inter_unit_spacing      7.5
        priority                0.7
    end_block

    begin_dummy_block 9
        spans 6 7 8
    end_dummy_block

    ;;; other rams on both sides
    begin_block 10
	;max_units 0
        unit_type               carrying_siege_engine ram       1.5
        unit_density            close
	block_formation         column
        block_relative_pos      6 -7.5 0.0
        inter_unit_spacing      1.0
        priority                1.0
    end_block

    begin_block 11
	;max_units 0
        unit_type               carrying_siege_engine ram       1.5
        unit_density            close
        block_formation         column
        block_relative_pos      6 7.5 0.0
        inter_unit_spacing      1.0
        priority                1.0
    end_block

    begin_dummy_block 12
        spans 9 10 11
    end_dummy_block

    ;; missile left 1
    begin_block 13
	max_units               3
	unit_type               missile infantry   		1.0
        unit_type               skirmish infantry   		0.9
        unit_density            close
	min_unit_width			30
	max_unit_width			40
        block_formation         column
        block_relative_pos      10 -7.5 -15.0
        inter_unit_spacing      5.0
        priority                1.0
    end_block

    ;; missile right 1
    begin_block 14
	max_units               3
	unit_type               missile infantry   		1.0
        unit_type               skirmish infantry   		0.9
        unit_density            close
	min_unit_width			30
	max_unit_width			40
        block_formation         column
        block_relative_pos      11 7.5 -15.0
        inter_unit_spacing      5.0
        priority                1.0
    end_block

    ;; missile left 2
    begin_block 15
	max_units               3
	unit_type               missile infantry   		1.0
        unit_type               skirmish infantry   		0.9
        unit_density            close
	min_unit_width			30
	max_unit_width			40
        block_formation         column
        block_relative_pos      13 -7.5 0.0
        inter_unit_spacing      5.0
        priority                0.9
    end_block

    ;; missile right 2
    begin_block 16
	max_units               3
	unit_type               missile infantry   		1.0
        unit_type               skirmish infantry   		0.9
        unit_density            close
	min_unit_width			30
	max_unit_width			40
        block_formation         column
        block_relative_pos      14 7.5 0.0
        inter_unit_spacing      5.0
        priority                0.9
    end_block

    begin_dummy_block 17
        spans 12 13 14 15 16
    end_dummy_block

    ;;; other infantry behind
    begin_block 18
	max_units               10
        unit_type               heavy infantry                  1.0
        unit_type               light infantry                  0.9
        unit_type               spearmen infantry               0.8
        unit_type               missile infantry	        0.7
        unit_type               skirmish infantry               0.6
 
        unit_density            close
		min_unit_width			25
		max_unit_width			25
        block_formation         line
        block_relative_pos      17 0.0 -1.0
        inter_unit_spacing      7.5
        priority                0.3
    end_block

    begin_dummy_block 19 
        spans 9 18
    end_dummy_block

    begin_block 20
        min_units               1
        max_units               1
        unit_type               general_unit            1.0
        unit_density            close
        block_formation         line
        block_relative_pos      19 0 -30.0
        inter_unit_spacing      20.0
        priority                1.0
    end_block

    ;;; cavalry on both sides
    begin_block 21
        unit_type               heavy cavalry                   1.0
        unit_type               light cavalry                   0.9
        unit_type               missile cavalry                 0.8
        unit_type               skirmish cavalry                0.7
        unit_type               any                             0.1
		min_unit_width			12
		max_unit_width			16
        ;unit_density            close
        block_formation         line
        block_relative_pos      20 -10.0 10.0
        inter_unit_spacing      5.0
        priority                0.2
    end_block
    begin_block 22
        unit_type               heavy cavalry                   1.0
        unit_type               light cavalry                   0.9
        unit_type               missile cavalry                 0.8
        unit_type               skirmish cavalry                0.7
        unit_type               any                             0.1
        ;unit_density            close
	min_unit_width			12
	max_unit_width			16
        block_formation         line
        block_relative_pos      20 10.0 10.0
        inter_unit_spacing      5.0
        priority                0.2
    end_block

    ;; other engines left side
    begin_block 23
        unit_type               carrying_siege_engine ladder    1.6
        unit_type               carrying_siege_engine tower     1.5
        unit_density            close
        block_formation         line
        block_relative_pos      3 -80.0 0.0
        inter_unit_spacing      20.0
        priority                1.0
    end_block

    ;; other engines right side
    begin_block 24
        unit_type               carrying_siege_engine ladder    1.5
        unit_type               carrying_siege_engine tower     1.6
        unit_density            close
        block_formation         line
        block_relative_pos      4 80.0 0.0
        inter_unit_spacing      20.0
        priority                1.0
    end_block

end_formation

;****************************************************************
; Ambush deployment
; Column marching formation for the army being ambushed
;****************************************************************
begin_formation ambush_defender_deployment

    standard_ambush_defender_deployment
    ai_priority 1

    ;;; general at the front
    begin_block 0
        min_units               1
        max_units               1
        unit_type               general_unit            1.0
        unit_density            close
        max_unit_width          4
        block_formation         line
        block_relative_pos      0 0.0 0.0
        inter_unit_spacing      2.0
        priority                1.0
    end_block

    ;;; all other units behind
    begin_block 1
        unit_type               any                 1.0
        unit_density            close
        max_unit_width          4
        block_formation         column
        block_relative_pos      0 0.0 -2.0
        inter_unit_spacing      2.0
        priority                1.0
    end_block


end_formation

;****************************************************************

begin_formation ai_standard_hiding

    ;;; purpose flags
    hiding

    ai_priority         1

        begin_block 0
            min_units           1
            unit_type           any 1.0
            unit_density        close
            block_formation     square
            block_relative_pos  0 0.0 0.0
            inter_unit_spacing  1.0
            priority            1.0
        end_block

end_formation

;****************************************************************

begin_formation ai_breach_defense_infantry

    ;;; purpose flags
    breach_defense_force

    ai_priority     1.0

    begin_dummy_block 0                                         ;; centre slot left empty for assault column to pass through
        spacer 0.0 0.0 0.5 0.5
    end_dummy_block

    ;;; left and forward
    begin_block 1
        max_units               1
    	not_general
        unit_type               spearmen infantry               1.0
        unit_type               heavy infantry                  0.9
        unit_type               light infantry                  0.8
        unit_type               phalanx                  	0.7
        unit_type               skirmish infantry               0.6
        unit_type               any				0.1
        unit_density            close
	max_unit_width			30
        block_formation         line
        block_relative_pos  	0 -0.5 -0.5
        inter_unit_spacing      0.0
        priority                1.0
    end_block

    ;;; right and forward
    begin_block 2
        max_units               1
    	not_general
        unit_type               spearmen infantry               1.0
        unit_type               heavy infantry                  0.9
        unit_type               light infantry                  0.8
        unit_type               phalanx                  	0.7
        unit_type               skirmish infantry               0.6
        unit_type               any				0.1
        unit_density            close
	max_unit_width			30
        block_formation         line
        block_relative_pos  	0 0.5 -0.5
        inter_unit_spacing      0.0
        priority                1.0
    end_block

    ;;; left and forward
    begin_block 3
        max_units               1
    	not_general
        unit_type               heavy infantry                  1.0
        unit_type               spearmen infantry               0.9
        unit_type               light infantry                  0.8
        unit_type               phalanx                  	0.7
        unit_type               skirmish infantry               0.6
        unit_type               any				0.1
        unit_density            close
	max_unit_width			30
        block_formation         line
        block_relative_pos  	1 -0.5 0.0
        inter_unit_spacing      0.0
        priority                0.6
    end_block

    ;;; right and forward
    begin_block 4
        max_units               1
    	not_general
        unit_type               heavy infantry                  1.0
        unit_type               spearmen infantry               0.9
        unit_type               light infantry                  0.8
        unit_type               phalanx                  	0.7
        unit_type               skirmish infantry               0.6
        unit_type               any				0.1
        unit_density            close
	max_unit_width			30
        block_formation         line
        block_relative_pos  	2 0.5 0.0
        inter_unit_spacing      0.0
        priority                0.6
    end_block

    ;;; backup
    begin_block 5
        unit_type               heavy infantry                  1.0
        unit_type               spearmen infantry               0.9
        unit_type               light infantry                  0.8
        unit_type               phalanx                  	0.7
        unit_type               skirmish infantry               0.6
        unit_type               any				0.1
        unit_density            close
;	max_unit_width			30
        block_formation         line
        block_relative_pos  	0 0.0 -5.0
        inter_unit_spacing      2.0
        priority                0.1
    end_block

end_formation

;****************************************************************

begin_formation ai_settlement_defense_street_artillery

    ;;; purpose flags
    settlement
    artillery
    defend

    ai_priority     1.0

    ;;; centre of group blocking the breach
    begin_block 0
    	not_general
        unit_type           	siege               1.0
        unit_density            close
        block_formation         column
        block_relative_pos  	0 0.0 0.0
        inter_unit_spacing      2.0
        priority                1.0
    end_block

    ;;; backup
    begin_block 1
        unit_type               heavy infantry                  1.0
        unit_type               spearmen infantry               0.9
        unit_type               light infantry                  0.8
        unit_type               phalanx                  	0.7
        unit_type               skirmish infantry               0.6
        unit_type               any				0.1				0.1
        unit_density            close
;	max_unit_width			20
        block_formation         line
        block_relative_pos  	0 0.0 -5.0
        inter_unit_spacing      2.0
        priority                0.1
    end_block

end_formation

;****************************************************************

begin_formation ai_settlement_defense_plaza

	;;; purpose flags
	plaza
	
	ai_priority		1.0
	
	;;; centre forward block
	begin_block 0
		max_units				2
    	not_general
        unit_type               phalanx                  	1.0
        unit_type               heavy infantry                  0.9
        unit_type               spearmen infantry               0.8
        unit_type               light infantry                  0.7
        unit_density			close
		max_unit_width			20
        block_formation			line
        normalised_pos			0.5		1.0
        normalised_rot			0
        inter_unit_spacing		0.5
        priority				1.0
	end_block
	
	;;; forward and right block
	begin_block 1
		max_units				2
    	not_general
        unit_type               phalanx                  	1.0
        unit_type               heavy infantry                  0.9
        unit_type               spearmen infantry               0.8
        unit_type               light infantry                  0.7
        unit_density			close
		max_unit_width			20
        block_formation			line
        normalised_pos			0.8125	0.75
        normalised_rot			45
        inter_unit_spacing		0.5
        priority				0.5
	end_block
	
	;;; forward and left block
	begin_block 2
		max_units				2
    	not_general
        unit_type               phalanx                  	1.0
        unit_type               heavy infantry                  0.9
        unit_type               spearmen infantry               0.8
        unit_type               light infantry                  0.7
        unit_density			close
		max_unit_width			20
        block_formation			line
        normalised_pos			0.1875	0.75
        normalised_rot			315
        inter_unit_spacing		0.5
        priority				0.5
	end_block
	
	;;; right block
	begin_block 3
		max_units				2
    	not_general
        unit_type               phalanx                  	1.0
        unit_type               heavy infantry                  0.9
        unit_type               spearmen infantry               0.8
        unit_type               light infantry                  0.7
        unit_density			close
		max_unit_width			20
        block_formation			line
        normalised_pos			1.0		0.25
        normalised_rot			75
        inter_unit_spacing		0.5
        priority				0.2
	end_block
	
	;;; left block
	begin_block 4
		max_units				2
    	not_general
        unit_type               phalanx                  	1.0
        unit_type               heavy infantry                  0.9
        unit_type               spearmen infantry               0.8
        unit_type               light infantry                  0.7
        unit_density			close
		max_unit_width			20
        block_formation			line
        normalised_pos			0.0		0.25
        normalised_rot			285
        inter_unit_spacing		0.5
        priority				0.2
	end_block

	;;; centre back catch all block	
	begin_block 5
        unit_type               any					0.1
        unit_density			close
		max_unit_width			20
        block_formation			column
        normalised_pos			0.5		0.0
        normalised_rot			0
        inter_unit_spacing		2.0
        priority				0.1
	end_block

end_formation

;****************************************************************

begin_formation ai_settlement_attack_reform

    ai_priority                                                 0

    ;;; rams at the centre
    begin_block 0
        unit_type               carrying_siege_engine ram       1.0
        unit_density            close
        block_formation         line
        block_relative_pos      0 0.0 0.0
        inter_unit_spacing      0.5
        priority                1.0
    end_block

    ;; other engines left side
    begin_block 1
        unit_type               carrying_siege_engine ladder    1.0
        unit_type               carrying_siege_engine tower     1.0
        unit_type               siege                           1.0
        unit_density            close
        block_formation         line
        block_relative_pos      0 -1.0 0.0
        inter_unit_spacing      0.5
        priority                1.0
    end_block

    ;; other infantry left side
    begin_block 2
        unit_type               heavy infantry                  0.7
        unit_type               light infantry                  0.7
        unit_type               skirmish infantry               0.7
        unit_type               missile infantry	            0.4
        unit_density            close
        block_formation         line
        block_relative_pos      1 -1.0 0.0
        inter_unit_spacing      0.5
        priority                0.5
    end_block

    ;; other engines right side
    begin_block 3
        unit_type               carrying_siege_engine ladder    1.0
        unit_type               carrying_siege_engine tower     1.0
        unit_type               siege                           1.0
        unit_density            close
        block_formation         line
        block_relative_pos      0 1.0 0.0
        inter_unit_spacing      0.5
        priority                1.0
    end_block

    ;; other infantry right side
    begin_block 4
        unit_type               heavy infantry                  0.7
        unit_type               light infantry                  0.7
        unit_type               skirmish infantry               0.7
        unit_type               missile infantry	            0.4
        unit_density            close
        block_formation         line
        block_relative_pos      3 1.0 0.0
        inter_unit_spacing      0.5
        priority                0.5
    end_block

    begin_dummy_block 5
        spans 0 1 2 3 4
    end_dummy_block

    ;;; cavalry on both sides
    begin_block 6
        unit_type               heavy cavalry                   1.0
        unit_type               light cavalry                   1.0
        unit_type               skirmish cavalry                1.0
        unit_type               any                             0.1
        unit_density            close
        block_formation         line
        block_relative_pos      5 1.0 0.0
        inter_unit_spacing      0.5
        priority                0.1
    end_block
    begin_block 7
        unit_type               heavy cavalry                   1.0
        unit_type               light cavalry                   1.0
        unit_type               skirmish cavalry                1.0
        unit_type               any                             0.1
        unit_density            close
        block_formation         line
        block_relative_pos      5 -1.0 0.0
        inter_unit_spacing      0.5
        priority                0.1
    end_block

end_formation

;****************************************************************

begin_formation ai_settlement_assault_gate

    ai_priority                                                 0

    begin_block 0
        unit_type               any 1.0
        unit_density            close
        block_formation         line
        block_relative_pos      0 0.0 0.0
        inter_unit_spacing      2.0
        priority                1.0
    end_block
	
	;;; special general block
    begin_block 1
        min_units               1
        max_units               1
        unit_type               general_unit            1.0
        unit_density            close
        block_formation         line
        block_relative_pos      0 0.0 -50.0
        inter_unit_spacing      1.0
        priority                1.0
    end_block

end_formation

;****************************************************************

begin_formation ai_street_defense_infantry
    ;;; purpose flags
    street
    defend

    ai_priority     1.0

    ;;; 
    begin_block 0
    	max_units				2
    	not_general
        unit_type               phalanx                  	1.0
        unit_type               heavy infantry                  0.9
        unit_type               spearmen infantry               0.8
        unit_type               light infantry                  0.7
        unit_type               skirmish infantry               0.6
        unit_type               any				0.1

        unit_density            close
;	max_unit_width			20
        block_formation         line
        block_relative_pos  	0 0.0 0.0
        inter_unit_spacing      0.0
        priority                1.0
    end_block

    ;;;
    begin_block 1
    	max_units				1
        unit_type               heavy infantry                  1.0
        unit_type               spearmen infantry               0.9
        unit_type               phalanx                  	0.8
        unit_type               light infantry                  0.7
        unit_type               skirmish infantry               0.6
        unit_type               any				0.1
        unit_density            close
;	max_unit_width			20
        block_formation         line
        block_relative_pos  	0 0.0 -1.0
        inter_unit_spacing      0.0
        priority                0.5
    end_block

    ;;;
    begin_block 2
    	max_units				1
        unit_type               skirmish infantry               1.0
        unit_type               missile infantry	        0.9
        unit_type               heavy infantry                  0.8
        unit_type               spearmen infantry               0.7
        unit_type               light infantry                  0.6
        unit_type               phalanx                  	0.5
        unit_type               any				0.1
        unit_density            close
;	max_unit_width			20
        block_formation         line
        block_relative_pos  	1 0.0 -10.0
        inter_unit_spacing      0.0
        priority                0.5
    end_block
end_formation

;****************************************************************
; Germanicu5 Tripple_missiles_up_front - more condensed formation
;****************************************************************

begin_formation ai_triple_missiles_up_front 

    ;;; purpose flags
;    attack
    defend
    anti_cavalry
			
    ai_priority     1.0

    begin_block 0
        max_units               5
        unit_type               skirmish infantry    1.0
	;default_melee_state	fire_at_will_and_skirmish
        ;unit_density            close
		min_unit_width			15
		max_unit_width			25
        block_formation         line
        block_relative_pos      0 0.0 0.0 
        inter_unit_spacing      1.0
        priority                1.0
    end_block
    begin_block 1
        max_units               5
        unit_type               skirmish infantry    0.9
	;default_melee_state	fire_at_will_and_skirmish
        ;unit_density            close
		min_unit_width			15
		max_unit_width			25
        block_formation         line
        block_relative_pos      0 0.0 -1.0
        inter_unit_spacing      1.0
        priority                0.9
    end_block
    begin_block 2
        max_units               5
        unit_type               skirmish infantry    0.8
	;default_melee_state	fire_at_will_and_skirmish
        ;unit_density            close
		min_unit_width			15
		max_unit_width			25
        block_formation         line
        block_relative_pos      1 0.0 -1.0
        inter_unit_spacing      1.0
        priority                0.8
    end_block
    begin_dummy_block 3
        spans 0 1 2
    end_dummy_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; the infantry units
    begin_dummy_block 4
	spans 0 1 2 3
     end_dummy_block

    begin_block 5
        max_units               2
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      4 0.0 -2.0
        inter_unit_spacing      0.0
        priority                0.9
    end_block
    begin_block 6
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      5 -1.0 0.0
        inter_unit_spacing      0.0
        priority                0.8
    end_block
    begin_block 7
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      5 1.0 0.0
        inter_unit_spacing      0.0
        priority                0.8
    end_block
    begin_block 8
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      6 -1.0 0.0
        inter_unit_spacing      0.0
        priority                0.7
    end_block
    begin_block 9
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      7 1.0 0.0
        inter_unit_spacing      0.0
        priority                0.7
    end_block
    begin_block 10
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      8 -1.0 0.0
        inter_unit_spacing      0.0
        priority                0.6
    end_block
    begin_block 11
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      9 1.0 0.0
        inter_unit_spacing      0.0
        priority                0.6
    end_block
    begin_dummy_block 12
        spans 5 6 7 8 9 10 11
    end_dummy_block

    begin_block 13
        max_units               6
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		min_unit_width			20
		max_unit_width			20
        block_formation         line
        block_relative_pos      4 0.0 -15.0
        inter_unit_spacing      0.0
        priority                0.4
    end_block
    begin_block 14
        max_units               6
        unit_type               infantry	    0.2
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		min_unit_width			20
		max_unit_width			25
        block_formation         line
        block_relative_pos      13 0.0 -2.0
        inter_unit_spacing      0.0
        priority                0.3
    end_block
    begin_block 15
        max_units               6
     unit_type               infantry	    0.1
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		min_unit_width			20
		max_unit_width			25
        block_formation         line
        block_relative_pos      14 0.0 -2.0
        inter_unit_spacing      0.0
  priority                0.2
    end_block
    begin_block 16
        max_units               6
        unit_type               missile infantry	0.7
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		min_unit_width			20
		max_unit_width			25
        block_formation         line
        block_relative_pos      15 0.0 -2.0
        inter_unit_spacing      0.0
        priority                0.7
    end_block

begin_dummy_block 17
        spans 4 12 13 14 15 16
    end_dummy_block

    begin_dummy_block 18
	spans 3 17
    end_dummy_block
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; missile cavalry

    begin_block 19
	max_units               3
        unit_type               missile cavalry 1.0
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      18 -15.0 -5.0
        inter_unit_spacing      1.0
        priority                1.0
    end_block
    begin_block 20
	max_units               3
        unit_type               missile cavalry 1.0
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		min_unit_width			15
		max_unit_width			15
        block_formation         line
        block_relative_pos      18 15.0 -5.0
        inter_unit_spacing      1.0
        priority                1.0
    end_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; cavalry


    begin_block 21
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		min_unit_width			15
		max_unit_width			15
        block_formation         line
        block_relative_pos      20 0.0 -10.0
        inter_unit_spacing      1.0
        priority                0.9
    end_block
    begin_block 22
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		min_unit_width			15
		max_unit_width			15
        block_formation         line
      block_relative_pos      19 0.0 -10.0
        inter_unit_spacing      1
  priority                0.9
    end_block
    begin_block 23
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		min_unit_width			15
		max_unit_width			15
        block_formation         line
        block_relative_pos      21 2.0 0
        inter_unit_spacing      1
        priority                0.7
    end_block
    begin_block 24
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		min_unit_width			15
		max_unit_width			15
        block_formation         line
        block_relative_pos      22 -2.0 0
        inter_unit_spacing      1
        priority                0.7
    end_block
    begin_block 25
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		min_unit_width			15
		max_unit_width			15
        block_formation         line
        block_relative_pos      23 2.0 0
        inter_unit_spacing      1
        priority                0.6
    end_block
    begin_block 26
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		min_unit_width			15
		max_unit_width			15
        block_formation         line
     block_relative_pos      24 -2.0 0
        inter_unit_spacing      1
        priority                0.6
    end_block
    begin_block 27
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		min_unit_width			15
		max_unit_width			15
        block_formation         line
        block_relative_pos      21 0.0 -5
        inter_unit_spacing      1
        priority                0.5
    end_block
    begin_block 28
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		min_unit_width			15
		max_unit_width			15
        block_formation         line
        block_relative_pos      22 0.0 -5
        inter_unit_spacing      1
        priority                0.5
    end_block
    begin_block 29
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		min_unit_width			15
		max_unit_width			15
        block_formation         line
        block_relative_pos      27 2.0 0
        inter_unit_spacing      1
        priority                0.4
    end_block
    begin_block 30
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		min_unit_width			15
		max_unit_width			15
        block_formation         line
        block_relative_pos      28 -2.0 0
        inter_unit_spacing      1
        priority                0.4
    end_block
    begin_block 31
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		min_unit_width			15
		max_unit_width			15
        block_formation         line
        block_relative_pos      29 2.0 0
        inter_unit_spacing      1
        priority                0.3
    end_block

    begin_block 32
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      30 -2.0 0
        inter_unit_spacing      1
        priority                0.3
    end_block
    begin_block 33
        max_units               3
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      29 0 -5.0
        inter_unit_spacing      1
        priority                0.2
    end_block
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ;; put the artillery and handlers behind everyone

begin_block 34
        max_units               3
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      30 0 -5.0
        inter_unit_spacing      2
        priority                0.2
    end_block
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ;; put the artillery and handlers behind everyone

    begin_block 35
        unit_type                   handler             1.0
        unit_type                   siege               1.0
        block_formation             line
        block_relative_pos          18 0.0 -5.0
        inter_unit_spacing          5.0
        priority                    1.0
    end_block
    begin_block 36
        unit_type               cavalry      0.1
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      35 0 -2.0
        inter_unit_spacing      2
        priority                0.1
    end_block

    ;;; special general block
    begin_block 37
        min_units               1
        max_units               1
        unit_type               general_unit            1.0
        unit_density            close
		min_unit_width			15
		max_unit_width			25
        block_formation         line
        block_relative_pos      36 0 -2.0
        inter_unit_spacing      20.0
        priority                1.0
    end_block

    main_line 5
end_formation

;****************************************************************
; G5 Triple missiles in front plus infantry on flanks
;****************************************************************

begin_formation ai_infantry_on_flanks  ; ai_defend_anti_cavalry
    ;;; purpose flags
    attack
    defend
    anti_cavalry
    anti_infantry		
    ai_priority     1.0

    begin_block 0
        max_units               4
        unit_type               skirmish infantry    1.0
	;default_melee_state	fire_at_will_and_skirmish
        ;unit_density            close
		min_unit_width			30
		max_unit_width			30
        block_formation         line
        block_relative_pos      0 0.0 0.0 
        inter_unit_spacing      1.0
        priority                1.0
    end_block
    begin_block 1
        max_units               4
        unit_type               skirmish infantry    0.9
	;default_melee_state	fire_at_will_and_skirmish
        ;unit_density            close
		min_unit_width			30
		max_unit_width			30
        block_formation         line
        block_relative_pos      0 0.0 -0.5
        inter_unit_spacing      1.0
        priority                0.9
    end_block
    begin_block 2
        max_units               4
        unit_type               skirmish infantry    0.8
	;default_melee_state	fire_at_will_and_skirmish
        ;unit_density            close
		min_unit_width			30
		max_unit_width			30
        block_formation         line
        block_relative_pos      1 0.0 -0.5
        inter_unit_spacing      1.0
        priority                0.8
    end_block
    begin_dummy_block 3
        spans 0 1 2
    end_dummy_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; the infantry units
    begin_dummy_block 4
	spans 0 1 2 3
     end_dummy_block

    begin_block 5
        max_units               2
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      4 0.0 -2.0
        inter_unit_spacing      0.0
        priority                0.9
    end_block
    begin_block 6
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      5 -1.0 0.0
        inter_unit_spacing      0.0
        priority                0.8
    end_block
    begin_block 7
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      5 1.0 0.0
        inter_unit_spacing      0.0
        priority                0.8
    end_block
    begin_block 8
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      6 -1.0 0.0
        inter_unit_spacing      0.0
        priority                0.7
    end_block
    begin_block 9
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      7 1.0 0.0
        inter_unit_spacing      0.0
        priority                0.7
    end_block
	begin_block 10
        max_units               1
	unit_type		heavy infantry	    1.0
	unit_type		light infantry	    0.9
        unit_type               spearmen	    0.8
	unit_type               phalanx		    0.7
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		min_unit_width			15
		max_unit_width			25
        block_formation         line
        block_relative_pos      9 0.0 -8.0
        inter_unit_spacing      1.0
        priority                0.6
    end_block
	begin_block 11
        max_units               1
	unit_type		heavy infantry	    1.0
	unit_type		light infantry	    0.9
        unit_type               spearmen	    0.8
	unit_type               phalanx		    0.7
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		min_unit_width			15
		max_unit_width			25
        block_formation         line
        block_relative_pos      8 0.0 -8.0
        inter_unit_spacing      1.0
        priority                0.6
    end_block
 	begin_block 12
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      8 -1.0 0.0
        inter_unit_spacing      0.0
        priority                0.5
    end_block
    begin_block 13
        max_units               1
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        ;unit_formation          square, phalanx, schiltrom
	;;default_melee_state	defend
        unit_density            close
		min_unit_width			15
		max_unit_width			20
        block_formation         line
        block_relative_pos      9 1.0 0.0
        inter_unit_spacing      0.0
        priority                0.5
    end_block
    begin_dummy_block 14
        spans 5 6 7 8 9 12 13
    end_dummy_block
    begin_block 15
        max_units               2
        unit_type               phalanx		    1.0
        unit_type               spearmen	    0.9
	unit_type		heavy infantry	    0.8
	unit_type		light infantry	    0.7
        unit_type               missile infantry    0.6
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		min_unit_width			20
		max_unit_width			25
        block_formation         line
        block_relative_pos      4 0.0 -20.0
        inter_unit_spacing      0.0
        priority                0.4
    end_block
   	begin_block 16
        max_units               1
        unit_type               spearmen	    1.0
	unit_type		light infantry	    0.9
	unit_type		heavy infantry	    0.8
	unit_type               phalanx		    0.7
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		min_unit_width			15
		max_unit_width			25
        block_formation         line
        block_relative_pos      11 0.0 -13.0
        inter_unit_spacing      1.0
        priority                0.3
    end_block
	begin_block 17
        max_units               1
        unit_type               spearmen	    1.0
	unit_type		light infantry	    0.9
	unit_type		heavy infantry	    0.8
	unit_type               phalanx		    0.7
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		min_unit_width			15
		max_unit_width			25
        block_formation         line
        block_relative_pos      10 0.0 -13.0
        inter_unit_spacing      1.0
        priority                0.3
    end_block
	begin_block 18
        max_units               4
        unit_type               infantry	    0.1
        unit_type               missile infantry    0.5
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		min_unit_width			25
		max_unit_width			30
        block_formation         line
        block_relative_pos      15 0.0 -5.0
        inter_unit_spacing      0.0
        priority                0.2
    end_block
    begin_block 19
        max_units               4
        unit_type               missile infantry	0.4
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		min_unit_width			25
		max_unit_width			30
        block_formation         line
        block_relative_pos      18 0.0 -2.0
        inter_unit_spacing      0.0
        priority                0.1
    end_block
    begin_block 20
        max_units               4
        unit_type               missile infantry	0.3
        ;unit_formation          square, phalanx, schiltrom
        unit_density            close
		min_unit_width			15
		max_unit_width			25
        block_formation         line
        block_relative_pos      19 0.0 -2.0
        inter_unit_spacing      0.0
        priority                0.1
    end_block

    begin_dummy_block 21
        spans 4 10 11 15
    end_dummy_block

    begin_dummy_block 22
	spans 3 21
    end_dummy_block
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; missile cavalry

    begin_block 23
	max_units               3
        unit_type               missile cavalry 1.0
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      22 -20.0 -15.0
        inter_unit_spacing      2.0
        priority                1.0
    end_block
    begin_block 24
	max_units               3
        unit_type               missile cavalry 1.0
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      22 20.0 -5.0
        inter_unit_spacing      2.0
        priority                1.0
    end_block

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; cavalry

    begin_block 25
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      24 0.0 -10.0
        inter_unit_spacing      2
        priority                0.9
    end_block
    begin_block 26
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      23 0.0 -10.0
        inter_unit_spacing      2
        priority                0.9
    end_block
    begin_block 27
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      25 2.0 0
        inter_unit_spacing      2
        priority                0.7
    end_block
    begin_block 28
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      26 -2.0 0
        inter_unit_spacing      2
        priority                0.7
    end_block
    begin_block 29
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      27 2.0 0
        inter_unit_spacing      2
        priority                0.6
    end_block
    begin_block 30
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      28 -2.0 0
        inter_unit_spacing      2
        priority                0.6
    end_block
    begin_block 31
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      25 0.0 -5
        inter_unit_spacing      2
        priority                0.5
    end_block
    begin_block 32
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      26 0.0 -5
        inter_unit_spacing      2
        priority                0.5
    end_block
    begin_block 33
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      31 2.0 0
        inter_unit_spacing      2
        priority                0.4
    end_block
    begin_block 34
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      32 -2.0 0
        inter_unit_spacing      2
        priority                0.4
    end_block
    begin_block 35
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      31 2.0 0
        inter_unit_spacing      2
        priority                0.3
    end_block
    begin_block 36
        max_units               1
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			15
        block_formation         line
        block_relative_pos      34 -2.0 0
        inter_unit_spacing      2
        priority                0.3
    end_block

    begin_block 37
        max_units               3
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      33 0 -5.0
        inter_unit_spacing      2
        priority                0.2
    end_block
    begin_block 38
        max_units               3
        unit_type               heavy cavalry      1.0
        unit_type               spearmen cavalry   0.9
        unit_type               skirmish cavalry   0.8
        unit_type               light cavalry      0.7
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      34 0 -5.0
        inter_unit_spacing      2
        priority                0.2
    end_block
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ;; put the artillery and handlers behind everyone

    begin_block 39
        unit_type                   handler             1.0
        unit_type                   siege               1.0
        block_formation             line
        block_relative_pos          20 0.0 -2.0
        inter_unit_spacing          5.0
        priority                    1.0
    end_block
    begin_block 40
        unit_type               cavalry      0.1
	;default_melee_state	fire_at_will_and_skirmish
        unit_density            close
		;min_unit_width			15
		;max_unit_width			20
        block_formation         line
        block_relative_pos      39 0 -2.0
        inter_unit_spacing      2
        priority                0.1
    end_block

    ;;; special general block
    begin_block 41
        min_units               1
        max_units               1
        unit_type               general_unit            1.0
        unit_density            close
		min_unit_width			15
		max_unit_width			25
        block_formation         line
        block_relative_pos      40 0 -2.0
        inter_unit_spacing      20.0
        priority                1.0
    end_block

    main_line 5
end_formation