Loading ...
Sorry, an error occurred while loading the content.
 

AI Pseudo-code

Expand Messages
  • aqwinsor
    below is what I have come up with. I always think it is a good idea to know what you want to do before you start coding ;) any ideas on how to improve it
    Message 1 of 4 , Apr 7, 2012
      below is what I have come up with. I always think it is a good idea to know what you want to do before you start coding ;)

      any ideas on how to improve it without generating a lot more work?

      [code]



      -load .ini data
      item weights
      trade items
      Produce Details
      racial skills
      starting cities
      guard comb/tac skills
      num factions
      for each faction
      faction number
      faction size S/L (1,1,3 or 2,2,1)
      aggression (neutral,unfriendly, aggressive)
      Allied with guards
      first turn run (can check for nexus?)
      factions at war (factions that attacked each AI)

      -do the below for each faction

      -load faction report
      get faction type allowances
      get num mages/acolytes
      get claimed hexes
      get border hexes
      get unclaimed silv
      get hex data
      locs
      tax
      work
      wage
      products
      trade bonus items needed
      buy
      sell
      races
      HasGuards
      IsClaimed
      IsGuarded
      IsBorder
      IsNexus
      IsClear
      GetStructures
      -get units
      total silver
      total support cost
      SilvInHex (total - support cost)
      total trade bonus items needed

      get units
      number
      name (so ai knows what job to give it)
      skill limit
      race
      hex
      items
      carry
      load
      IsInUnfinishedStruucture
      IsInFort

      -calculate
      max faction supported tax/11 + work/wage*(wage -10 - 4/2/0 N/U/A)/10
      DemandExists
      BoughtByCity
      NumItems < 2*(ItemsNeeded-ItemsUsed)

      -CastRandom
      Check available spells and materials
      choose a random non-gate spell
      take materials (does sharing work?)
      cast spell


      -check first turn run IfInNexus do
      Write starting cities to .ini file (do this only if not in memory)
      checkskills, IfKnowsGate, option to gate out
      move options 6 + 6*6 directions (possibly leave starting city on first

      turn
      name unit captain
      behind 1
      Faction S/L
      Declare Default
      decide what to do gate or move
      if gate, Write orders
      gate
      claim 100
      study eart
      if no gate
      50% chance to move once
      50% chance move twice

      - IF has only 1 unit and is in starting city
      turn on sharing (sharing needed for the ai to work)
      50% cast Gate (if has gate)
      else
      cast eart (if has eart)
      50%
      buy horse and move 4
      else
      study magic [eart if can] (claim)
      buy 1-3 scouts (claim)
      not more than exits
      each buy hors (claim)
      study comb
      buy 1 garrison (claim)
      study comb

      - IF has only 1 unit and is *not* in starting city
      cast eart (if has eart)
      else CastRandom non-gate
      study magic (claim)
      form 1-3 scouts (claim)
      not more than exits
      each buy hors (claim)
      each 50%
      study comb
      else
      move random non-ocean
      form garrison (claim)
      study comb

      - Size check
      check garrison/levy #/loc
      cycle through and elim 'Guard'ed then the lowest taxes OR
      add highest levy hexes
      check trade elim lowest non-buying city (IOW always trade in cities that

      buy goods)
      use following values for hex total
      food 1
      common 2
      rare 4

      - first non scout unit in hex
      form garrison


      - all other cases, DoUnitOrders (work orders not needed?)
      Scout
      if not in core/border hex move random up to limit or work
      equalize money 1/4
      if in border hex
      guard 1
      work
      if taxing < limit
      tax
      inc tax counter
      If SilvInHex(claim) > garrison buy/study/support
      Form Garrison
      else if taxing >= limit
      if in taxing hex
      tax
      10/25/50% move to available border hex
      else if have 10 silv
      10/25/50% move to available border hex
      else if comb < UnitCombLimit and has 20 silv
      50% study comb
      else
      50% move/work
      else
      50% move/work
      else if taxing < limit
      Tax
      move to border hex if available
      else if comb < UnitCombLimit
      1/3 move/study/work
      else
      50% study work

      Garrison
      name unit (as per taxing info)
      ?tax
      enter best fort
      guard 1 (every turn to catch hexes left unguarded)
      Make buy decisions loop until funds run out
      Militia\soldiers(archers/xbow/Lancers) 50/50
      check taxes if taxed @80% plus, don't buy militia
      if L2 and L3/4 in empire, 30%
      if L2 and L3/4 in next hex 70% no buy
      if L2 and fully taxed, no buy
      if lvl 2, don't buy bowmen/lancers at all
      can buy 1 of each/turn (unlimt 3/4)
      mage (up to faction limit)
      Acolyte (up to faction limit)
      each trade item producer vs amount avail (L3 vs empire wide)
      if L2 and L3 in empire, 20% no buy
      if L2 and L3 in next hex 60% no buy
      can buy 2 of each per turn (8 of lvl 3)
      each craftsman vs empire wide supply production
      if L2 and L3 in empire, 50% no buy
      if L2 and L3 in next hex 90% no buy
      (builder)
      if L2 and L3 in empire, no buy 7 total ever in hex hex*3 max
      can buy 2 of each per turn (8 of lvl 3)
      caravan until one of each type per hex.
      end loop
      0/2/5% chance to attack unit
      CanBeatGuards
      0/5/10% chance to attack guards
      5/25/50% chance to attack hostiles
      distribute hors
      distribute weap/armor

      Milita (Soldiers/Orcs)
      ?tax
      guard 1
      enter best fort
      give extra weap/armor to garrison
      Militia does not ever move.
      if not fully taxed
      work/study chance
      else
      33% work/study/move

      Knights
      ?tax
      enter best fort
      take armo/weap
      60/40 study/move
      study comb/ridi

      Captain
      ?tax
      enter best fort
      80/20 study/move
      take armo/weap
      study comb/ridi/stea/obse/tact

      Mage (disguised as Captain)
      ?tax
      enter best fort
      take armo/weap
      cast random spell
      90/10 study/move
      study comb/ridi/stea/obse/tact/random mage skill

      Acolyte (disguised as Captain)
      ?tax
      enter best fort
      equip any mage item
      take armo/weap
      80/20 study/move
      study comb/ridi/stea/obse/mani

      Bowmen
      ?tax
      study/work/move do not move if bows<3

      Archers
      ?tax
      study/work/move do not move if bows<3

      Crossbowmen
      ?tax
      study/work/move do not move if bows<3

      Marksmen
      ?tax
      study/work/move do not move if bows<3

      Lancers
      ?tax
      study/work/move do not move if lances<3

      Lumberjacks (master)
      ?tax
      give to garrison
      study/?produce/move do not move if untrained/not enough producers
      If master, produce lvl 3 first

      Farmers (master)
      ?tax
      give to garrison
      study/?produce/move do not move if untrained/not enough producers

      Ranchers (master)
      ?tax
      give to garrison
      study/?produce/move do not move if untrained/not enough producers

      Horsemen (master)
      ?tax
      give to garrison
      study/?produce/move do not move if untrained/not enough producers

      Gatherers (master)
      ?tax
      give to garrison
      study/?produce/move do not move if untrained/not enough producers

      Hunters (master)
      ?tax
      give to garrison
      study/?produce/move do not move if untrained/not enough producers

      Builders (master)
      study/work
      if stone, build castle
      if root build mystic
      else
      work
      if castle move
      (master) build roads first
      build 2 temples
      If unfinished buildings do those first

      Stone-cutters (master)
      ?tax
      give to garrison
      study/?produce/move do not move if untrained/not enough producers
      If master, produce lvl 3 first

      -All Production
      produce only 2x needed - equipped
      else work

      smiths (master)
      ?tax
      ?produce
      study/?produce/move do not move if untrained/not enough producers
      If master, produce Mswo/Mxbo if possible
      (axe/hamm) for self, then random swo

      armorers (master)
      ?tax
      ?produce
      give excess to garrison
      study/?produce/move do not move if untrained/not enough producers
      If master, produce (Marm/Mshi) then parm if possible(or needed) then

      ishi/wshi

      Herbalists, need 2x supply of these
      ?tax
      ?produce
      give excess to garrison
      study/?produce/move do not move if untrained/not enough producers
      50% prduce herb
      else
      produce bags then bags/lass

      carpenters (master)
      ?tax
      ?produce
      give excess to garrison
      study/?produce/move do not move if untrained/not enough producers
      produce mwag for convoys
      produce wag for convoys + sail
      produce spin for herb/sail/armo

      sailors
      ?tax
      ?produce
      give excess to garrison
      study/?produce/move do not move if untrained/not enough producers
      produce nets


      porters on foot
      caravan with horses
      wagon-train with wagons
      convoy with mwag
      Identical
      ?tax
      equalize with garrison 50/50 split
      give needed
      take excess to weight limit
      if not full comb 10% study
      else move

      -distribution
      melee weapons/armor to garrison,knights,captains, orc,soldiers,militia, producers/caravans,trader
      missle to approp unit,garrison,trader
      horses to carvan,knights,captain,orc,soldiers,masters
      wago to caravan,garrison,trader


      -form unit (subset)
      Scout
      name unit
      study comb
      behind 1
      avoid 1
      describe unit (move along, no trespassing, Leave or Die)
      claim if needed
      buy 1 man
      buy 1 hors (if available)

      Garrison
      name unit
      describe unit (as scout)
      behind 0
      hold 1
      avoid 0
      claim if needed
      check tax base
      <= 10 men
      study comb


      Milita
      name unit
      behind 0
      hold 0
      avoid 0
      buy 10 men
      study comb

      Soldiers
      name unit
      behind 0
      hold 0
      avoid 0
      buy 10 men
      study comb

      Warriors
      name unit
      behind 0
      hold 0
      avoid 0
      buy 10 men
      study comb

      Knight
      name unit
      behind 0
      hold 0
      avoid 0
      buy 1 lead
      study comb

      Captain
      name unit
      behind 1
      hold 0
      avoid 0
      buy 1 lead
      study comb

      Mage (disguised as Captain)
      name unit
      behind 1
      hold 0
      avoid 0
      buy 1 lead
      study patt

      Acolyte (disguised as Captain)
      name unit
      behind 1
      hold 0
      avoid 0
      buy 1 lead
      study mani

      Bowmen
      name unit
      behind 1
      hold 0
      avoid 0
      buy 5 men
      study lbow

      Archers
      name unit
      behind 1
      hold 0
      avoid 0
      buy 5 men
      study lbow

      Crossbowmen
      name unit
      behind 1
      hold 0
      avoid 0
      buy 5 men
      study xbow

      Marksmen
      name unit
      behind 1
      hold 0
      avoid 0
      buy 5 men
      study xbow

      Lancers
      name unit
      behind 0
      hold 0
      avoid 0
      buy 5 men
      study ridi

      Lumberjack (master)
      name unit
      behind 1
      hold 1
      avoid 1
      buy 1 man
      study lumb

      Farmers (master)
      name unit
      behind 1
      hold 1
      avoid 1
      buy 1 man
      study farm

      Ranchers (master)
      name unit
      behind 1
      hold 1
      avoid 1
      buy 1 man
      study ranc

      Horsemen (master)
      name unit
      behind 1
      hold 1
      avoid 1
      buy 1 man
      study hors

      Gatherers (master)
      name unit
      behind 1
      hold 1
      avoid 1
      buy 1 man
      study herb

      Hunters (master)
      name unit
      behind 1
      hold 1
      avoid 1
      buy 1 man
      study hunt

      Builders (master)
      name unit
      behind 1
      hold 1
      avoid 1
      buy 1 man
      study buil

      Stone-cutters (master)
      name unit
      behind 1
      hold 1
      avoid 1
      buy 1 man
      study quar

      smiths (master)
      name unit
      behind 1
      hold 1
      avoid 1
      buy 1 man
      study weap

      armorers (master)
      name unit
      behind 1
      hold 1
      avoid 1
      buy 1 man
      study armo

      carpenters (master)
      name unit
      behind 1
      hold 1
      avoid 1
      buy 1 man
      study carp

      Sailors
      only build if net are bought.

      Traders
      name unit
      behind 1
      hold 1
      avoid 1
      buy 10 men
      study xbow? (optimise for bowmen if lvl3 poss?)

      porters
      name unit
      behind 1
      hold 1
      avoid 1
      buy 4 men
      study comb

      caravan
      name unit
      behind 1
      hold 1
      avoid 1
      buy 4 men
      study comb

      wagon-train
      name unit
      behind 1
      hold 1
      avoid 1
      buy 4 men
      study comb

      convoy
      name unit
      behind 1
      hold 1
      avoid 1
      buy 4 men
      study comb


      -write orders
      make order file (stripping template from report?)
      -for each unit
      find unit (make new file and just do each unit?)
      insert orders (is this easier to do as orders are generated?)
      (probably not)


      [/code]
    • stabliser
      From the look of it this will run once for all AI factions each turn. Does that mean all the AI factions will share intelligence ? Also will this be able to be
      Message 2 of 4 , Apr 8, 2012
        From the look of it this will run once for all AI factions each turn. Does that mean all the AI factions will share intelligence ?

        Also will this be able to be used for AI creature factions? If so we need a tweek to allow more than one creature faction and for those factions to read an orders file at processing. I want a necromancer faction, infact I might like to have a 'wizard with golem army' faction.

        It would be good if the files you read in at init were the same files the server used. If you do these files right maybe this would be a good point to get the data out of the server code.

        Pete

        --- In atlantisdev@yahoogroups.com, "aqwinsor" <aqwinsor@...> wrote:
        >
        > below is what I have come up with. I always think it is a good idea to know what you want to do before you start coding ;)
        >
        > any ideas on how to improve it without generating a lot more work?
        >
        > [code]
        >
        >
        >
        > -load .ini data
        > item weights
        > trade items
        > Produce Details
        > racial skills
        > starting cities
        > guard comb/tac skills
        > num factions
        > for each faction
        > faction number
        > faction size S/L (1,1,3 or 2,2,1)
        > aggression (neutral,unfriendly, aggressive)
        > Allied with guards
        > first turn run (can check for nexus?)
        > factions at war (factions that attacked each AI)
        >
        > -do the below for each faction
        >
        > -load faction report
        > get faction type allowances
        > get num mages/acolytes
        > get claimed hexes
        > get border hexes
        > get unclaimed silv
        > get hex data
        > locs
        > tax
        > work
        > wage
        > products
        > trade bonus items needed
        > buy
        > sell
        > races
        > HasGuards
        > IsClaimed
        > IsGuarded
        > IsBorder
        > IsNexus
        > IsClear
        > GetStructures
        > -get units
        > total silver
        > total support cost
        > SilvInHex (total - support cost)
        > total trade bonus items needed
        >
        > get units
        > number
        > name (so ai knows what job to give it)
        > skill limit
        > race
        > hex
        > items
        > carry
        > load
        > IsInUnfinishedStruucture
        > IsInFort
        >
        > -calculate
        > max faction supported tax/11 + work/wage*(wage -10 - 4/2/0 N/U/A)/10
        > DemandExists
        > BoughtByCity
        > NumItems < 2*(ItemsNeeded-ItemsUsed)
        >
        > -CastRandom
        > Check available spells and materials
        > choose a random non-gate spell
        > take materials (does sharing work?)
        > cast spell
        >
        >
        > -check first turn run IfInNexus do
        > Write starting cities to .ini file (do this only if not in memory)
        > checkskills, IfKnowsGate, option to gate out
        > move options 6 + 6*6 directions (possibly leave starting city on first
        >
        > turn
        > name unit captain
        > behind 1
        > Faction S/L
        > Declare Default
        > decide what to do gate or move
        > if gate, Write orders
        > gate
        > claim 100
        > study eart
        > if no gate
        > 50% chance to move once
        > 50% chance move twice
        >
        > - IF has only 1 unit and is in starting city
        > turn on sharing (sharing needed for the ai to work)
        > 50% cast Gate (if has gate)
        > else
        > cast eart (if has eart)
        > 50%
        > buy horse and move 4
        > else
        > study magic [eart if can] (claim)
        > buy 1-3 scouts (claim)
        > not more than exits
        > each buy hors (claim)
        > study comb
        > buy 1 garrison (claim)
        > study comb
        >
        > - IF has only 1 unit and is *not* in starting city
        > cast eart (if has eart)
        > else CastRandom non-gate
        > study magic (claim)
        > form 1-3 scouts (claim)
        > not more than exits
        > each buy hors (claim)
        > each 50%
        > study comb
        > else
        > move random non-ocean
        > form garrison (claim)
        > study comb
        >
        > - Size check
        > check garrison/levy #/loc
        > cycle through and elim 'Guard'ed then the lowest taxes OR
        > add highest levy hexes
        > check trade elim lowest non-buying city (IOW always trade in cities that
        >
        > buy goods)
        > use following values for hex total
        > food 1
        > common 2
        > rare 4
        >
        > - first non scout unit in hex
        > form garrison
        >
        >
        > - all other cases, DoUnitOrders (work orders not needed?)
        > Scout
        > if not in core/border hex move random up to limit or work
        > equalize money 1/4
        > if in border hex
        > guard 1
        > work
        > if taxing < limit
        > tax
        > inc tax counter
        > If SilvInHex(claim) > garrison buy/study/support
        > Form Garrison
        > else if taxing >= limit
        > if in taxing hex
        > tax
        > 10/25/50% move to available border hex
        > else if have 10 silv
        > 10/25/50% move to available border hex
        > else if comb < UnitCombLimit and has 20 silv
        > 50% study comb
        > else
        > 50% move/work
        > else
        > 50% move/work
        > else if taxing < limit
        > Tax
        > move to border hex if available
        > else if comb < UnitCombLimit
        > 1/3 move/study/work
        > else
        > 50% study work
        >
        > Garrison
        > name unit (as per taxing info)
        > ?tax
        > enter best fort
        > guard 1 (every turn to catch hexes left unguarded)
        > Make buy decisions loop until funds run out
        > Militia\soldiers(archers/xbow/Lancers) 50/50
        > check taxes if taxed @80% plus, don't buy militia
        > if L2 and L3/4 in empire, 30%
        > if L2 and L3/4 in next hex 70% no buy
        > if L2 and fully taxed, no buy
        > if lvl 2, don't buy bowmen/lancers at all
        > can buy 1 of each/turn (unlimt 3/4)
        > mage (up to faction limit)
        > Acolyte (up to faction limit)
        > each trade item producer vs amount avail (L3 vs empire wide)
        > if L2 and L3 in empire, 20% no buy
        > if L2 and L3 in next hex 60% no buy
        > can buy 2 of each per turn (8 of lvl 3)
        > each craftsman vs empire wide supply production
        > if L2 and L3 in empire, 50% no buy
        > if L2 and L3 in next hex 90% no buy
        > (builder)
        > if L2 and L3 in empire, no buy 7 total ever in hex hex*3 max
        > can buy 2 of each per turn (8 of lvl 3)
        > caravan until one of each type per hex.
        > end loop
        > 0/2/5% chance to attack unit
        > CanBeatGuards
        > 0/5/10% chance to attack guards
        > 5/25/50% chance to attack hostiles
        > distribute hors
        > distribute weap/armor
        >
        > Milita (Soldiers/Orcs)
        > ?tax
        > guard 1
        > enter best fort
        > give extra weap/armor to garrison
        > Militia does not ever move.
        > if not fully taxed
        > work/study chance
        > else
        > 33% work/study/move
        >
        > Knights
        > ?tax
        > enter best fort
        > take armo/weap
        > 60/40 study/move
        > study comb/ridi
        >
        > Captain
        > ?tax
        > enter best fort
        > 80/20 study/move
        > take armo/weap
        > study comb/ridi/stea/obse/tact
        >
        > Mage (disguised as Captain)
        > ?tax
        > enter best fort
        > take armo/weap
        > cast random spell
        > 90/10 study/move
        > study comb/ridi/stea/obse/tact/random mage skill
        >
        > Acolyte (disguised as Captain)
        > ?tax
        > enter best fort
        > equip any mage item
        > take armo/weap
        > 80/20 study/move
        > study comb/ridi/stea/obse/mani
        >
        > Bowmen
        > ?tax
        > study/work/move do not move if bows<3
        >
        > Archers
        > ?tax
        > study/work/move do not move if bows<3
        >
        > Crossbowmen
        > ?tax
        > study/work/move do not move if bows<3
        >
        > Marksmen
        > ?tax
        > study/work/move do not move if bows<3
        >
        > Lancers
        > ?tax
        > study/work/move do not move if lances<3
        >
        > Lumberjacks (master)
        > ?tax
        > give to garrison
        > study/?produce/move do not move if untrained/not enough producers
        > If master, produce lvl 3 first
        >
        > Farmers (master)
        > ?tax
        > give to garrison
        > study/?produce/move do not move if untrained/not enough producers
        >
        > Ranchers (master)
        > ?tax
        > give to garrison
        > study/?produce/move do not move if untrained/not enough producers
        >
        > Horsemen (master)
        > ?tax
        > give to garrison
        > study/?produce/move do not move if untrained/not enough producers
        >
        > Gatherers (master)
        > ?tax
        > give to garrison
        > study/?produce/move do not move if untrained/not enough producers
        >
        > Hunters (master)
        > ?tax
        > give to garrison
        > study/?produce/move do not move if untrained/not enough producers
        >
        > Builders (master)
        > study/work
        > if stone, build castle
        > if root build mystic
        > else
        > work
        > if castle move
        > (master) build roads first
        > build 2 temples
        > If unfinished buildings do those first
        >
        > Stone-cutters (master)
        > ?tax
        > give to garrison
        > study/?produce/move do not move if untrained/not enough producers
        > If master, produce lvl 3 first
        >
        > -All Production
        > produce only 2x needed - equipped
        > else work
        >
        > smiths (master)
        > ?tax
        > ?produce
        > study/?produce/move do not move if untrained/not enough producers
        > If master, produce Mswo/Mxbo if possible
        > (axe/hamm) for self, then random swo
        >
        > armorers (master)
        > ?tax
        > ?produce
        > give excess to garrison
        > study/?produce/move do not move if untrained/not enough producers
        > If master, produce (Marm/Mshi) then parm if possible(or needed) then
        >
        > ishi/wshi
        >
        > Herbalists, need 2x supply of these
        > ?tax
        > ?produce
        > give excess to garrison
        > study/?produce/move do not move if untrained/not enough producers
        > 50% prduce herb
        > else
        > produce bags then bags/lass
        >
        > carpenters (master)
        > ?tax
        > ?produce
        > give excess to garrison
        > study/?produce/move do not move if untrained/not enough producers
        > produce mwag for convoys
        > produce wag for convoys + sail
        > produce spin for herb/sail/armo
        >
        > sailors
        > ?tax
        > ?produce
        > give excess to garrison
        > study/?produce/move do not move if untrained/not enough producers
        > produce nets
        >
        >
        > porters on foot
        > caravan with horses
        > wagon-train with wagons
        > convoy with mwag
        > Identical
        > ?tax
        > equalize with garrison 50/50 split
        > give needed
        > take excess to weight limit
        > if not full comb 10% study
        > else move
        >
        > -distribution
        > melee weapons/armor to garrison,knights,captains, orc,soldiers,militia, producers/caravans,trader
        > missle to approp unit,garrison,trader
        > horses to carvan,knights,captain,orc,soldiers,masters
        > wago to caravan,garrison,trader
        >
        >
        > -form unit (subset)
        > Scout
        > name unit
        > study comb
        > behind 1
        > avoid 1
        > describe unit (move along, no trespassing, Leave or Die)
        > claim if needed
        > buy 1 man
        > buy 1 hors (if available)
        >
        > Garrison
        > name unit
        > describe unit (as scout)
        > behind 0
        > hold 1
        > avoid 0
        > claim if needed
        > check tax base
        > <= 10 men
        > study comb
        >
        >
        > Milita
        > name unit
        > behind 0
        > hold 0
        > avoid 0
        > buy 10 men
        > study comb
        >
        > Soldiers
        > name unit
        > behind 0
        > hold 0
        > avoid 0
        > buy 10 men
        > study comb
        >
        > Warriors
        > name unit
        > behind 0
        > hold 0
        > avoid 0
        > buy 10 men
        > study comb
        >
        > Knight
        > name unit
        > behind 0
        > hold 0
        > avoid 0
        > buy 1 lead
        > study comb
        >
        > Captain
        > name unit
        > behind 1
        > hold 0
        > avoid 0
        > buy 1 lead
        > study comb
        >
        > Mage (disguised as Captain)
        > name unit
        > behind 1
        > hold 0
        > avoid 0
        > buy 1 lead
        > study patt
        >
        > Acolyte (disguised as Captain)
        > name unit
        > behind 1
        > hold 0
        > avoid 0
        > buy 1 lead
        > study mani
        >
        > Bowmen
        > name unit
        > behind 1
        > hold 0
        > avoid 0
        > buy 5 men
        > study lbow
        >
        > Archers
        > name unit
        > behind 1
        > hold 0
        > avoid 0
        > buy 5 men
        > study lbow
        >
        > Crossbowmen
        > name unit
        > behind 1
        > hold 0
        > avoid 0
        > buy 5 men
        > study xbow
        >
        > Marksmen
        > name unit
        > behind 1
        > hold 0
        > avoid 0
        > buy 5 men
        > study xbow
        >
        > Lancers
        > name unit
        > behind 0
        > hold 0
        > avoid 0
        > buy 5 men
        > study ridi
        >
        > Lumberjack (master)
        > name unit
        > behind 1
        > hold 1
        > avoid 1
        > buy 1 man
        > study lumb
        >
        > Farmers (master)
        > name unit
        > behind 1
        > hold 1
        > avoid 1
        > buy 1 man
        > study farm
        >
        > Ranchers (master)
        > name unit
        > behind 1
        > hold 1
        > avoid 1
        > buy 1 man
        > study ranc
        >
        > Horsemen (master)
        > name unit
        > behind 1
        > hold 1
        > avoid 1
        > buy 1 man
        > study hors
        >
        > Gatherers (master)
        > name unit
        > behind 1
        > hold 1
        > avoid 1
        > buy 1 man
        > study herb
        >
        > Hunters (master)
        > name unit
        > behind 1
        > hold 1
        > avoid 1
        > buy 1 man
        > study hunt
        >
        > Builders (master)
        > name unit
        > behind 1
        > hold 1
        > avoid 1
        > buy 1 man
        > study buil
        >
        > Stone-cutters (master)
        > name unit
        > behind 1
        > hold 1
        > avoid 1
        > buy 1 man
        > study quar
        >
        > smiths (master)
        > name unit
        > behind 1
        > hold 1
        > avoid 1
        > buy 1 man
        > study weap
        >
        > armorers (master)
        > name unit
        > behind 1
        > hold 1
        > avoid 1
        > buy 1 man
        > study armo
        >
        > carpenters (master)
        > name unit
        > behind 1
        > hold 1
        > avoid 1
        > buy 1 man
        > study carp
        >
        > Sailors
        > only build if net are bought.
        >
        > Traders
        > name unit
        > behind 1
        > hold 1
        > avoid 1
        > buy 10 men
        > study xbow? (optimise for bowmen if lvl3 poss?)
        >
        > porters
        > name unit
        > behind 1
        > hold 1
        > avoid 1
        > buy 4 men
        > study comb
        >
        > caravan
        > name unit
        > behind 1
        > hold 1
        > avoid 1
        > buy 4 men
        > study comb
        >
        > wagon-train
        > name unit
        > behind 1
        > hold 1
        > avoid 1
        > buy 4 men
        > study comb
        >
        > convoy
        > name unit
        > behind 1
        > hold 1
        > avoid 1
        > buy 4 men
        > study comb
        >
        >
        > -write orders
        > make order file (stripping template from report?)
        > -for each unit
        > find unit (make new file and just do each unit?)
        > insert orders (is this easier to do as orders are generated?)
        > (probably not)
        >
        >
        > [/code]
        >
      • aqwinsor
        ... This is intended to run using a .ini file and the faction report, it only looks at one faction at a time. Theoretically, you could have it run your faction
        Message 3 of 4 , Apr 8, 2012
          --- In atlantisdev@yahoogroups.com, "stabliser" <stabliser@...> wrote:
          >
          > From the look of it this will run once for all AI factions each turn. Does that mean all the AI factions will share intelligence ?
          >

          This is intended to run using a .ini file and the faction report, it only looks at one faction at a time. Theoretically, you could have it run your faction while you were o vacation, but you might find yourself in a war when you get back.

          > Also will this be able to be used for AI creature factions? If so we need a tweek to allow more than one creature faction and for those factions to read an orders file at processing. I want a necromancer faction, infact I might like to have a 'wizard with golem army' faction.
          >
          You'd have to change the engine itself to achieve those.

          > It would be good if the files you read in at init were the same files the server used. If you do these files right maybe this would be a good point to get the data out of the server code.
          >
          I don't think the game.in file has things like item weights, and I know it doesn't keep track of which faction attacked which.

          Oh, I see what you mean. I'm trying to do this without any changes to the code, something a gm could use without having to make any changes.

          I thought about trying to keep track of all this stuff in comments in the orders, but one slipup and the AI would get real stupid.


          > Pete
          >
          > --- In atlantisdev@yahoogroups.com, "aqwinsor" <aqwinsor@> wrote:
          > >
          > > below is what I have come up with. I always think it is a good idea to know what you want to do before you start coding ;)
          > >
          > > any ideas on how to improve it without generating a lot more work?
          > >
          > > [code]
          > >
          > >
          > >
          > > -load .ini data
          > > item weights
          > > trade items
          > > Produce Details
          > > racial skills
          > > starting cities
          > > guard comb/tac skills
          > > num factions
          > > for each faction
          > > faction number
          > > faction size S/L (1,1,3 or 2,2,1)
          > > aggression (neutral,unfriendly, aggressive)
          > > Allied with guards
          > > first turn run (can check for nexus?)
          > > factions at war (factions that attacked each AI)
          > >
          > > -do the below for each faction
          > >
          > > -load faction report
          > > get faction type allowances
          > > get num mages/acolytes
          > > get claimed hexes
          > > get border hexes
          > > get unclaimed silv
          > > get hex data
          > > locs
          > > tax
          > > work
          > > wage
          > > products
          > > trade bonus items needed
          > > buy
          > > sell
          > > races
          > > HasGuards
          > > IsClaimed
          > > IsGuarded
          > > IsBorder
          > > IsNexus
          > > IsClear
          > > GetStructures
          > > -get units
          > > total silver
          > > total support cost
          > > SilvInHex (total - support cost)
          > > total trade bonus items needed
          > >
          > > get units
          > > number
          > > name (so ai knows what job to give it)
          > > skill limit
          > > race
          > > hex
          > > items
          > > carry
          > > load
          > > IsInUnfinishedStruucture
          > > IsInFort
          > >
          > > -calculate
          > > max faction supported tax/11 + work/wage*(wage -10 - 4/2/0 N/U/A)/10
          > > DemandExists
          > > BoughtByCity
          > > NumItems < 2*(ItemsNeeded-ItemsUsed)
          > >
          > > -CastRandom
          > > Check available spells and materials
          > > choose a random non-gate spell
          > > take materials (does sharing work?)
          > > cast spell
          > >
          > >
          > > -check first turn run IfInNexus do
          > > Write starting cities to .ini file (do this only if not in memory)
          > > checkskills, IfKnowsGate, option to gate out
          > > move options 6 + 6*6 directions (possibly leave starting city on first
          > >
          > > turn
          > > name unit captain
          > > behind 1
          > > Faction S/L
          > > Declare Default
          > > decide what to do gate or move
          > > if gate, Write orders
          > > gate
          > > claim 100
          > > study eart
          > > if no gate
          > > 50% chance to move once
          > > 50% chance move twice
          > >
          > > - IF has only 1 unit and is in starting city
          > > turn on sharing (sharing needed for the ai to work)
          > > 50% cast Gate (if has gate)
          > > else
          > > cast eart (if has eart)
          > > 50%
          > > buy horse and move 4
          > > else
          > > study magic [eart if can] (claim)
          > > buy 1-3 scouts (claim)
          > > not more than exits
          > > each buy hors (claim)
          > > study comb
          > > buy 1 garrison (claim)
          > > study comb
          > >
          > > - IF has only 1 unit and is *not* in starting city
          > > cast eart (if has eart)
          > > else CastRandom non-gate
          > > study magic (claim)
          > > form 1-3 scouts (claim)
          > > not more than exits
          > > each buy hors (claim)
          > > each 50%
          > > study comb
          > > else
          > > move random non-ocean
          > > form garrison (claim)
          > > study comb
          > >
          > > - Size check
          > > check garrison/levy #/loc
          > > cycle through and elim 'Guard'ed then the lowest taxes OR
          > > add highest levy hexes
          > > check trade elim lowest non-buying city (IOW always trade in cities that
          > >
          > > buy goods)
          > > use following values for hex total
          > > food 1
          > > common 2
          > > rare 4
          > >
          > > - first non scout unit in hex
          > > form garrison
          > >
          > >
          > > - all other cases, DoUnitOrders (work orders not needed?)
          > > Scout
          > > if not in core/border hex move random up to limit or work
          > > equalize money 1/4
          > > if in border hex
          > > guard 1
          > > work
          > > if taxing < limit
          > > tax
          > > inc tax counter
          > > If SilvInHex(claim) > garrison buy/study/support
          > > Form Garrison
          > > else if taxing >= limit
          > > if in taxing hex
          > > tax
          > > 10/25/50% move to available border hex
          > > else if have 10 silv
          > > 10/25/50% move to available border hex
          > > else if comb < UnitCombLimit and has 20 silv
          > > 50% study comb
          > > else
          > > 50% move/work
          > > else
          > > 50% move/work
          > > else if taxing < limit
          > > Tax
          > > move to border hex if available
          > > else if comb < UnitCombLimit
          > > 1/3 move/study/work
          > > else
          > > 50% study work
          > >
          > > Garrison
          > > name unit (as per taxing info)
          > > ?tax
          > > enter best fort
          > > guard 1 (every turn to catch hexes left unguarded)
          > > Make buy decisions loop until funds run out
          > > Militia\soldiers(archers/xbow/Lancers) 50/50
          > > check taxes if taxed @80% plus, don't buy militia
          > > if L2 and L3/4 in empire, 30%
          > > if L2 and L3/4 in next hex 70% no buy
          > > if L2 and fully taxed, no buy
          > > if lvl 2, don't buy bowmen/lancers at all
          > > can buy 1 of each/turn (unlimt 3/4)
          > > mage (up to faction limit)
          > > Acolyte (up to faction limit)
          > > each trade item producer vs amount avail (L3 vs empire wide)
          > > if L2 and L3 in empire, 20% no buy
          > > if L2 and L3 in next hex 60% no buy
          > > can buy 2 of each per turn (8 of lvl 3)
          > > each craftsman vs empire wide supply production
          > > if L2 and L3 in empire, 50% no buy
          > > if L2 and L3 in next hex 90% no buy
          > > (builder)
          > > if L2 and L3 in empire, no buy 7 total ever in hex hex*3 max
          > > can buy 2 of each per turn (8 of lvl 3)
          > > caravan until one of each type per hex.
          > > end loop
          > > 0/2/5% chance to attack unit
          > > CanBeatGuards
          > > 0/5/10% chance to attack guards
          > > 5/25/50% chance to attack hostiles
          > > distribute hors
          > > distribute weap/armor
          > >
          > > Milita (Soldiers/Orcs)
          > > ?tax
          > > guard 1
          > > enter best fort
          > > give extra weap/armor to garrison
          > > Militia does not ever move.
          > > if not fully taxed
          > > work/study chance
          > > else
          > > 33% work/study/move
          > >
          > > Knights
          > > ?tax
          > > enter best fort
          > > take armo/weap
          > > 60/40 study/move
          > > study comb/ridi
          > >
          > > Captain
          > > ?tax
          > > enter best fort
          > > 80/20 study/move
          > > take armo/weap
          > > study comb/ridi/stea/obse/tact
          > >
          > > Mage (disguised as Captain)
          > > ?tax
          > > enter best fort
          > > take armo/weap
          > > cast random spell
          > > 90/10 study/move
          > > study comb/ridi/stea/obse/tact/random mage skill
          > >
          > > Acolyte (disguised as Captain)
          > > ?tax
          > > enter best fort
          > > equip any mage item
          > > take armo/weap
          > > 80/20 study/move
          > > study comb/ridi/stea/obse/mani
          > >
          > > Bowmen
          > > ?tax
          > > study/work/move do not move if bows<3
          > >
          > > Archers
          > > ?tax
          > > study/work/move do not move if bows<3
          > >
          > > Crossbowmen
          > > ?tax
          > > study/work/move do not move if bows<3
          > >
          > > Marksmen
          > > ?tax
          > > study/work/move do not move if bows<3
          > >
          > > Lancers
          > > ?tax
          > > study/work/move do not move if lances<3
          > >
          > > Lumberjacks (master)
          > > ?tax
          > > give to garrison
          > > study/?produce/move do not move if untrained/not enough producers
          > > If master, produce lvl 3 first
          > >
          > > Farmers (master)
          > > ?tax
          > > give to garrison
          > > study/?produce/move do not move if untrained/not enough producers
          > >
          > > Ranchers (master)
          > > ?tax
          > > give to garrison
          > > study/?produce/move do not move if untrained/not enough producers
          > >
          > > Horsemen (master)
          > > ?tax
          > > give to garrison
          > > study/?produce/move do not move if untrained/not enough producers
          > >
          > > Gatherers (master)
          > > ?tax
          > > give to garrison
          > > study/?produce/move do not move if untrained/not enough producers
          > >
          > > Hunters (master)
          > > ?tax
          > > give to garrison
          > > study/?produce/move do not move if untrained/not enough producers
          > >
          > > Builders (master)
          > > study/work
          > > if stone, build castle
          > > if root build mystic
          > > else
          > > work
          > > if castle move
          > > (master) build roads first
          > > build 2 temples
          > > If unfinished buildings do those first
          > >
          > > Stone-cutters (master)
          > > ?tax
          > > give to garrison
          > > study/?produce/move do not move if untrained/not enough producers
          > > If master, produce lvl 3 first
          > >
          > > -All Production
          > > produce only 2x needed - equipped
          > > else work
          > >
          > > smiths (master)
          > > ?tax
          > > ?produce
          > > study/?produce/move do not move if untrained/not enough producers
          > > If master, produce Mswo/Mxbo if possible
          > > (axe/hamm) for self, then random swo
          > >
          > > armorers (master)
          > > ?tax
          > > ?produce
          > > give excess to garrison
          > > study/?produce/move do not move if untrained/not enough producers
          > > If master, produce (Marm/Mshi) then parm if possible(or needed) then
          > >
          > > ishi/wshi
          > >
          > > Herbalists, need 2x supply of these
          > > ?tax
          > > ?produce
          > > give excess to garrison
          > > study/?produce/move do not move if untrained/not enough producers
          > > 50% prduce herb
          > > else
          > > produce bags then bags/lass
          > >
          > > carpenters (master)
          > > ?tax
          > > ?produce
          > > give excess to garrison
          > > study/?produce/move do not move if untrained/not enough producers
          > > produce mwag for convoys
          > > produce wag for convoys + sail
          > > produce spin for herb/sail/armo
          > >
          > > sailors
          > > ?tax
          > > ?produce
          > > give excess to garrison
          > > study/?produce/move do not move if untrained/not enough producers
          > > produce nets
          > >
          > >
          > > porters on foot
          > > caravan with horses
          > > wagon-train with wagons
          > > convoy with mwag
          > > Identical
          > > ?tax
          > > equalize with garrison 50/50 split
          > > give needed
          > > take excess to weight limit
          > > if not full comb 10% study
          > > else move
          > >
          > > -distribution
          > > melee weapons/armor to garrison,knights,captains, orc,soldiers,militia, producers/caravans,trader
          > > missle to approp unit,garrison,trader
          > > horses to carvan,knights,captain,orc,soldiers,masters
          > > wago to caravan,garrison,trader
          > >
          > >
          > > -form unit (subset)
          > > Scout
          > > name unit
          > > study comb
          > > behind 1
          > > avoid 1
          > > describe unit (move along, no trespassing, Leave or Die)
          > > claim if needed
          > > buy 1 man
          > > buy 1 hors (if available)
          > >
          > > Garrison
          > > name unit
          > > describe unit (as scout)
          > > behind 0
          > > hold 1
          > > avoid 0
          > > claim if needed
          > > check tax base
          > > <= 10 men
          > > study comb
          > >
          > >
          > > Milita
          > > name unit
          > > behind 0
          > > hold 0
          > > avoid 0
          > > buy 10 men
          > > study comb
          > >
          > > Soldiers
          > > name unit
          > > behind 0
          > > hold 0
          > > avoid 0
          > > buy 10 men
          > > study comb
          > >
          > > Warriors
          > > name unit
          > > behind 0
          > > hold 0
          > > avoid 0
          > > buy 10 men
          > > study comb
          > >
          > > Knight
          > > name unit
          > > behind 0
          > > hold 0
          > > avoid 0
          > > buy 1 lead
          > > study comb
          > >
          > > Captain
          > > name unit
          > > behind 1
          > > hold 0
          > > avoid 0
          > > buy 1 lead
          > > study comb
          > >
          > > Mage (disguised as Captain)
          > > name unit
          > > behind 1
          > > hold 0
          > > avoid 0
          > > buy 1 lead
          > > study patt
          > >
          > > Acolyte (disguised as Captain)
          > > name unit
          > > behind 1
          > > hold 0
          > > avoid 0
          > > buy 1 lead
          > > study mani
          > >
          > > Bowmen
          > > name unit
          > > behind 1
          > > hold 0
          > > avoid 0
          > > buy 5 men
          > > study lbow
          > >
          > > Archers
          > > name unit
          > > behind 1
          > > hold 0
          > > avoid 0
          > > buy 5 men
          > > study lbow
          > >
          > > Crossbowmen
          > > name unit
          > > behind 1
          > > hold 0
          > > avoid 0
          > > buy 5 men
          > > study xbow
          > >
          > > Marksmen
          > > name unit
          > > behind 1
          > > hold 0
          > > avoid 0
          > > buy 5 men
          > > study xbow
          > >
          > > Lancers
          > > name unit
          > > behind 0
          > > hold 0
          > > avoid 0
          > > buy 5 men
          > > study ridi
          > >
          > > Lumberjack (master)
          > > name unit
          > > behind 1
          > > hold 1
          > > avoid 1
          > > buy 1 man
          > > study lumb
          > >
          > > Farmers (master)
          > > name unit
          > > behind 1
          > > hold 1
          > > avoid 1
          > > buy 1 man
          > > study farm
          > >
          > > Ranchers (master)
          > > name unit
          > > behind 1
          > > hold 1
          > > avoid 1
          > > buy 1 man
          > > study ranc
          > >
          > > Horsemen (master)
          > > name unit
          > > behind 1
          > > hold 1
          > > avoid 1
          > > buy 1 man
          > > study hors
          > >
          > > Gatherers (master)
          > > name unit
          > > behind 1
          > > hold 1
          > > avoid 1
          > > buy 1 man
          > > study herb
          > >
          > > Hunters (master)
          > > name unit
          > > behind 1
          > > hold 1
          > > avoid 1
          > > buy 1 man
          > > study hunt
          > >
          > > Builders (master)
          > > name unit
          > > behind 1
          > > hold 1
          > > avoid 1
          > > buy 1 man
          > > study buil
          > >
          > > Stone-cutters (master)
          > > name unit
          > > behind 1
          > > hold 1
          > > avoid 1
          > > buy 1 man
          > > study quar
          > >
          > > smiths (master)
          > > name unit
          > > behind 1
          > > hold 1
          > > avoid 1
          > > buy 1 man
          > > study weap
          > >
          > > armorers (master)
          > > name unit
          > > behind 1
          > > hold 1
          > > avoid 1
          > > buy 1 man
          > > study armo
          > >
          > > carpenters (master)
          > > name unit
          > > behind 1
          > > hold 1
          > > avoid 1
          > > buy 1 man
          > > study carp
          > >
          > > Sailors
          > > only build if net are bought.
          > >
          > > Traders
          > > name unit
          > > behind 1
          > > hold 1
          > > avoid 1
          > > buy 10 men
          > > study xbow? (optimise for bowmen if lvl3 poss?)
          > >
          > > porters
          > > name unit
          > > behind 1
          > > hold 1
          > > avoid 1
          > > buy 4 men
          > > study comb
          > >
          > > caravan
          > > name unit
          > > behind 1
          > > hold 1
          > > avoid 1
          > > buy 4 men
          > > study comb
          > >
          > > wagon-train
          > > name unit
          > > behind 1
          > > hold 1
          > > avoid 1
          > > buy 4 men
          > > study comb
          > >
          > > convoy
          > > name unit
          > > behind 1
          > > hold 1
          > > avoid 1
          > > buy 4 men
          > > study comb
          > >
          > >
          > > -write orders
          > > make order file (stripping template from report?)
          > > -for each unit
          > > find unit (make new file and just do each unit?)
          > > insert orders (is this easier to do as orders are generated?)
          > > (probably not)
          > >
          > >
          > > [/code]
          > >
          >
        • stabliser
          ... Have you looked at AAAcontroller (Python) by fuzzyman - its in the files section. I cant remember what all its features were, but it was used by players on
          Message 4 of 4 , Apr 9, 2012
            --- In atlantisdev@yahoogroups.com, "aqwinsor" <aqwinsor@...> wrote:
            > --- In atlantisdev@yahoogroups.com, "stabliser" <stabliser@> wrote:
            > > From the look of it this will run once for all AI factions each turn. Does that mean all the AI factions will share intelligence ?
            > >
            > This is intended to run using a .ini file and the faction report, it only looks at one faction at a time. Theoretically, you could have it run your faction while you were o vacation, but you might find yourself in a war when you get back.

            Have you looked at AAAcontroller (Python) by fuzzyman - its in the files section. I cant remember what all its features were, but it was used by players on their own reports.

            >...
            > Oh, I see what you mean. I'm trying to do this without any changes to the code, something a gm could use without having to make any changes.
            >

            Another reason why atlantis would benefit from having the game data out of the code. (I'm willing to help someone who knows how to do this but I don't know where to start)

            > I thought about trying to keep track of all this stuff in comments in the orders, but one slipup and the AI would get real stupid.
            >

            If this is to be a player aid then it makes sense to use the order template as the player will be able to add/remove AI data in their client. But if its a fully autonomous bot then some other format might be useful. AAAcontroller kept a master map in atlantis report format IIRC, not sure if/where it stored intel, it was long ago.

            Pete
          Your message has been successfully submitted and would be delivered to recipients shortly.