4 ms·
I used it last night to write serialization code for EnTT (an entity component system) and cereal (a serialization library). The code needed to save/load all re
by suby 4y ago
I used it last night to write serialization code for EnTT (an entity component system) and cereal (a serialization library). The code needed to save/load all relevant state for entities, component data, and context (sort of like a singleton entity).
The amount of magic C++ required here is beyond me, but I was able to hobble through it thanks to ChatGPT. I also received help on a Discord which was essential because at one point ChatGPT got stuck (it kept using a certain function which did not exist, and refused to not use said function to solve the issue at hand, despite me clearly and repeatedly telling it that this thing was invalid and did not exist).
Here's the small test example - https://pastebin.com/XX9rPDgt https://pastebin.com/XX9rPDgt
I have also found it useful for writing small scripts which normally would take me 5 - 15 minutes to write. For example, I had downloaded an archive of images which were in an annoying format, where there were 1000's of images in total but they were each burried in a varying depth of folder directories, and there were hundreds of root level folders. ChatGPT wrote a script to extract these images into the root level. The task took about 60 seconds in total, including the time it took to craft the prompt.
It's nice to not have to write scripts like that myself anymore.
- nolok 4y agoInstead of the final code which may or may not have time saved from chatgpt, it would be more interesting to see your chat history for that specific conversation with it and see how easily or poorly it understood what was needed, and how close to the actual end result it got.
- suby 4y agoI don't think I would have completed the task at all had it not been for chatgpt (and the help on discord). I'd probably have had to rely on some kind soul doing the whole thing for me, as I could not find a working example with the latest version of both libraries online anywhere. There probably is a working example somewhere, but I couldn't find it. The service is down now so I can't post it, but there's definitely an art to phrasing it to do what you want. I had some cases where I told it what I wanted to do at a certain section in high level terms, but when given together it would produce garbage (using non-existent functions). For example, if told to loop through the components from the argument list and add a component to the archive if it exists, it'd fail due to trying to accomplish the task in a more straight forward way (with functions that don't exist). However, I could break it down over the course of more prompts, so one prompt would be asking it to do a loop through components, auto process_component_type = [&](auto component_type) { }; (process_component_type(std::type_identity<Components>{}), ...); Another prompt to extract the component type (this would go inside the loop) using ComponentType = decltype(component_type)::type; std::cout << "Processing component: " << typeid(ComponentType).name() << std::endl; And then I myself could write (after the above) if (registry.ctx().contains<ComponentType>()) { std::cout << "Context contains"; archive(registry.ctx().get<ComponentType>()); }