Text this: Developing and Analyzing the Defect-Based Surface Codes Using Optimization Algorithms