How the AI decides what ship type to build
Posted: Tue Feb 24, 2009 9:24 am
Each empire has a list of ship types to build for each agenda. Each list can contain up to 36 entries.
Valid agendas are (per the wording in trek.exe and checked indexes):
Normal Expansion (0)
Unopposed Expansion (1)
Normal Consolidation (2)
Defensive Consolidation (3)
Offensive Consolidation (4)
Cold War (5)
Defensive War (6)
Offensive War (7)
Jihad (8 )
The lists begin at 0x18A0C0 in trek.exe. The first one is for empire 0 (Cardassians) and agenda 0, next one is empire 0 agenda 1, and so on. All together the lists take up 12960 bytes.
Each entry contains ship type id (4 bytes (as read by botf - but only 2 bytes actually matter - botf shifts the bits) and another 4 bytes which have unknown function and are usually set to 0, but sometimes 1.
Let's say the AI is playing the Cardassians. At the begining their agenda is Normal expansion. One would expect Unopposed expansion, but that is not the case.
In vanilla trek.exe the first entries are:
Scout, Colony, Transport, Destroyer, Transporter, Destroyer, Colony, Transporter, Command Cruiser...
When the AI builds a ship it also runs through the list to pick the next ship type to build, the result is saved until the AI decides to build a ship. It then builds the one previously picked and picks the one for the next time again.
Now we start with a colony and a scout. AI goes through the list like this:
if the number of scouts < 1 build scout
else continue next item
if the number of colony ships < 1 build colony
else continue next item
if the number of transporters ships < 1 build transporter
else continue next item
if the number of destroyers < 1 build destroyer
else continue next item
if the number of transporters ships < 2 build transporter
else continue next item
and so on
So the first ship our Cardassians would build is a transporter.
When the next item is -1 (FFFF) or the end of the list is reached, the AI starts again from the begining of the list with the limits increased accordingly. So if the list contained only two Colony ships, a transporter and FFFF. The logic would look like this:
if the number of colony ships < 1 build colony
else continue next item
if the number of colony ships < 2 build colony
else continue next item
if the number of transporters ships < 1 build transporter
else continue next item
read FFFF (end of list) so start from begining
if the number of colony ships < 3 build colony
else continue next item
if the number of colony ships < 4 build colony
else continue next item
if the number of transporters ships < 2 build transporter
else continue next item
etc..
The forum keeps messing up the post so read on in next post...
Valid agendas are (per the wording in trek.exe and checked indexes):
Normal Expansion (0)
Unopposed Expansion (1)
Normal Consolidation (2)
Defensive Consolidation (3)
Offensive Consolidation (4)
Cold War (5)
Defensive War (6)
Offensive War (7)
Jihad (8 )
The lists begin at 0x18A0C0 in trek.exe. The first one is for empire 0 (Cardassians) and agenda 0, next one is empire 0 agenda 1, and so on. All together the lists take up 12960 bytes.
Each entry contains ship type id (4 bytes (as read by botf - but only 2 bytes actually matter - botf shifts the bits) and another 4 bytes which have unknown function and are usually set to 0, but sometimes 1.
Let's say the AI is playing the Cardassians. At the begining their agenda is Normal expansion. One would expect Unopposed expansion, but that is not the case.
In vanilla trek.exe the first entries are:
Scout, Colony, Transport, Destroyer, Transporter, Destroyer, Colony, Transporter, Command Cruiser...
When the AI builds a ship it also runs through the list to pick the next ship type to build, the result is saved until the AI decides to build a ship. It then builds the one previously picked and picks the one for the next time again.
Now we start with a colony and a scout. AI goes through the list like this:
if the number of scouts < 1 build scout
else continue next item
if the number of colony ships < 1 build colony
else continue next item
if the number of transporters ships < 1 build transporter
else continue next item
if the number of destroyers < 1 build destroyer
else continue next item
if the number of transporters ships < 2 build transporter
else continue next item
and so on
So the first ship our Cardassians would build is a transporter.
When the next item is -1 (FFFF) or the end of the list is reached, the AI starts again from the begining of the list with the limits increased accordingly. So if the list contained only two Colony ships, a transporter and FFFF. The logic would look like this:
if the number of colony ships < 1 build colony
else continue next item
if the number of colony ships < 2 build colony
else continue next item
if the number of transporters ships < 1 build transporter
else continue next item
read FFFF (end of list) so start from begining
if the number of colony ships < 3 build colony
else continue next item
if the number of colony ships < 4 build colony
else continue next item
if the number of transporters ships < 2 build transporter
else continue next item
etc..
The forum keeps messing up the post so read on in next post...