2 ms·
I think LLMs are adapting higher level concepts. For example, the following JavaScript code generated by GLM (https://github.com/simonw/tools/blob/9e04fd9895fae
by threeducks 1y ago
I think LLMs are adapting higher level concepts. For example, the following JavaScript code generated by GLM (https://github.com/simonw/tools/blob/9e04fd9895fae1aa9ac78b8e62d2833831fe0544/space-invaders-GLM-4.5-Air-3bit.html#L387-L405 https://github.com/simonw/tools/blob/9e04fd9895fae1aa9ac78b8...) is clearly inspired by this C++ code (https://github.com/portapack-mayhem/mayhem-firmware/blob/28e2f770e5f9cb60021a1ddfe12cdc1a1f82d38f/firmware/application/external/spaceinv/ui_spaceinv.cpp#L468-L486 https://github.com/portapack-mayhem/mayhem-firmware/blob/28e...), but it is not an exact copy.
- simonw 1y agoThis is a really good spot. That code certainly looks similar, but I have trouble imagining how else you would implement very basic collision detection between a projectile and a player object in a game of this nature.
- threeducks 1y agoA human would likely have refactored the two collision checks between bullet/enemy and enemyBullet/player in the JavaScript code into its own function, perhaps something like "areRectanglesOverlapping". The C++ code only does one collision check like that, so it has not been refactored there, but as a human, I certainly would not want to write that twice. More importantly, it is not just the collision check that is similar. Almost the entire sequence of operations is identical on a higher level: 1. enemyBullet/player collision check 2. same comment "// Player hit!" (this is how I found the code) 3. remove enemy bullet from array 4. decrement lives 5. update lives UI 6. (createParticle only exists in JS code) 7. if lives are <= 0, gameOver