sirgwain / craig-stars

Web based Stars! clone
https://craig-stars.net
MIT License
7 stars 3 forks source link

Update AI Ship Design To Commit to Beams or Torpedoes on a single design #155

Open KentheDM opened 2 weeks ago

KentheDM commented 2 weeks ago

Mixing torpedo and beam weapons is not a viable ship design in Stars! Recommend updating the AI ship design to commit to either beam or torp weapons for a single design. I don't know how to code, so you'll have to figure out items in brackets. Hope this helps.

craig-stars/cs/shipdesign.go

case HullSlotTypeWeapon:
            [make decision matrix beams vs. missiles, or keep it random for now, if designed in an odd year, make torpedos, if even make beams?]
            //hull should commit to a single weapon type
            if [beam ship/even year/whatever] {
                slot.HullComponent = beamWeapon.Name
                numBeamWeapons++
            } else {
                slot.HullComponent = torpedo.Name
                numTorpedos++
            }

General slots for fighter-type hulls should be set to weapons, to maximize combat ability. Added case ShipDesignPurposeFighter to do this. This would impact the design of destroyers, cruisers, and dreadnaughts only.

case HullSlotTypeGeneral:
            switch purpose {
            case ShipDesignPurposeFuelFreighter:
                slot.HullComponent = fuelTank.Name
                numFuelTanks++
            case ShipDesignPurposeColonizer:
                // balance fuel and cargo, fuel firsts
                if numFuelTanks > numCargoPods && cargoPod != nil {
                    slot.HullComponent = cargoPod.Name
                    numCargoPods++
                } else {
                    slot.HullComponent = fuelTank.Name
                    numFuelTanks++
                }
            case ShipDesignPurposeFighter:
                //adds the same weapons in GP slots for fighters
                if numTorpedos > numBeamWeapons {
                    slot.HullComponent = torpedo.Name
                    numTorpedos++
                } else {
                    slot.HullComponent = beamWeapon.Name
                    numBeamWeapons++
                }
            case ShipDesignPurposeFighterScout:
                if numScanners == 0 {
                    slot.HullComponent = scanner.Name
                    numScanners++
                } else {
                    slot.HullComponent = beamWeapon.Name
                }
            default:
                if numScanners == 0 {
                    slot.HullComponent = scanner.Name
                    numScanners++
                } else {
                    slot.HullComponent = fuelTank.Name
                    numFuelTanks++
                }
            }
        }

Only destroyers have straight mechanical slots. If it is a beamer ship, it should have a jet or thruster, if not you can put on a fuel tank. Added case ShipDesignPurposeFighter to do this, but I didn't know how to write the code to add thrusters.

case HullSlotTypeMechanical:
            switch purpose {
            case ShipDesignPurposeFuelFreighter:
                slot.HullComponent = fuelTank.Name
                numFuelTanks++
            case ShipDesignPurposeFreighter:
                fallthrough
            case ShipDesignPurposeColonistFreighter:
                // add cargo pods to freighters if we have a ramscoop
                if engine.FreeSpeed > 1 && cargoPod != nil {
                    slot.HullComponent = cargoPod.Name
                    numCargoPods++
                }
            case ShipDesignPurposeColonizer:
                if colonizationModule != nil && numColonizationModules == 0 {
                    numColonizationModules++
                    slot.HullComponent = colonizationModule.Name
                    slot.Quantity = 1 // we only need 1 colonization module
                } else {
                    // balance fuel and cargo, fuel firsts
                    if numFuelTanks > numCargoPods {
                        slot.HullComponent = cargoPod.Name
                        numCargoPods++
                    } else {
                        slot.HullComponent = fuelTank.Name
                        numFuelTanks++
                    }
                }
            case ShipDesignPurposeFighter
                //Destroyers are the only Fighter Hull that has a straight mechanical slot
                if [beam ship/even year/whatever] {
                    [add maneuvering jet or overthurster]
                } else {
                    slot.HullComponent = fuelTank.Name
                    numFuelTanks++
                }
            default:
                slot.HullComponent = fuelTank.Name
                numFuelTanks++
            }
sirgwain commented 2 weeks ago

Are there use cases where you'd want beams over torpedos or vice versa? Are beams better for attack ships or defense ships? I tend to pick beams if I have a high enough movement, but eventually go all torpedo once delta+ are there.

KentheDM commented 2 weeks ago

TLDR: Up to weapons tech level 12/16 go beams, then go capital ship missiles with computers. If under tech level 12, throw in some randomness to get the occasional torpedo design.

Most fights take place at either beam range or torpedo range, so mixing the two doesn't work. Even if it's a random choice, at any tech level, either going full torpedoes or full beams is superior to a mix.

Before capital ship missiles, (tech 12) and their double damage against unshielded targets, I generally follow what you do and go beams. The last time the beams are effective (without chaff) one-v-one is probably tech 16? But I am not an expert player.

However, beam fleets are cheaper, and have less mass (and thus gatable by non-IT folk), so they can serve as a "barbarian horde" strategy (i.e., smaller fleets of ships hitting you everywhere). AIs that want to make a lot of smaller invasion fleets might lean into beams, while AIs making super big fleets should probably go with capital ship missiles.

Oh. If you are using general slots for weapons, the AI should include a scout ship in their fleets. Since bombers are expensive, I would double or triple the number fighter ships for bomber fleets.