OK, this is only going to apply to the nominative basic case. We'll be getting on to the dative (after prepositions) and genetive (kind of to do with possessives and after verbal nouns and basically it gets complicated so we're leaving that till later)
-before vowels (a,e,i,o,u) use 'an t-' (e.g. an t-each)
-Before the letters b, f, m or p use 'am' (e.g. am balach)
-Before any other letter use 'an' (an cofaidh)
-Before the letters b, c, g, m, p use: a' and then lenite the following noun. e.g. a' bhùth
-Before the letters s (except sg, sm, sp, st which I use the mnemonic 'gumpot' to remember) use an t- e.g. an t-seanmhair
-Before the letter f use an, but it lenites the following noun. e.g. an fhuil
Before any other letter it is just 'an' So yes, there are rules, but it's going to take a while to internalise.