Well, if you changed the pirate settings and/or difficulty it may get a bit tricky. Also on smaller galaxies with more opponents you are more likely to encounter them earlier in the game. Seems logical so far.



At the beginning of the game, most likely your colonyship and your scout are of no match for AI (both pirates and AI players). Of course it also depend of the race you've chosen to start with, but if you want some pieces of advice, here are a few hints that worked for me :



I usually scout and colonize the first interesting world within 10-15 turns (much faster if I am lucky) and then try to expand within those two systems (by researching food then expansion tech before I even think to build military ships or unlock military techs) till I get enough industrial power to build military ships in just a few turns.



Now the first researches you do will have a great influence on your start. Do not try to go for too expensive researches. If you are an expansionist best is to go for the diplomacy tech tree and get the first food tech "soil xenobiology" as it will greatly help increase your rate of expansion early in the game (if you are starting on a terran planet especially, otherwise the system technology will be your friend).



Pirates and AI are of little danger at the beginning for your colonies they are just an annoyance for lone scouts and colony ships, and I personally try to expand as much as I can before they spawn (pirates) or reach me (AI) because they don't attack colonies (though they may blockade them) and I wipe them later on. If you don't want them to survive first encounter on your territory, then you need to have a more militaristic approach :



1. build combat vessels and form up 1 fleet (idealy at least 2 combat ships, since the first wave of pirate will usually be 1 or 2 ships and IA will usually be only scouts)

2. research a few combat techs (guns are usually enough to take the upper hand) and upgrade your existing designs + retrofit the current ships

3. you can also do both 1 & 2



For exploration, unfortunately there is nothing you can do if you send your scout alone and step on hostile forces, IA tends to build combat ships early on, while pirates are combat ships by definitition (with superior fire power and often number to your scout). To save your scout, merge it in one single fleet with the combat ships you've built.