Text this: Optimising energy distribution and detecting vulnerabilities in networks using artificial intelligence