Learning Game-Playing Agents with Generative Code Optimization