Hi all! First post here.
About two years ago I downloaded the source code for TPT and followed the tutorial for writing a new element into the game. That was a childhood dream come true, to add something to a game I grew up with.
The HETR element got my foot in the door, and I decided to create my own custom element that I felt needed to exist.
I like the nuclear tab more than any other category, and I wanted to make a new element in the tab that could give a bit more bang than DEUT and PLUT. I created an element called DLI, Lithium Deuteride. After about a week of development I had a proper element that could accelerate the reaction of a nuke. Just like real life!
Since ChatGPT has become all the rage in the tech world lately, I decided to challenge the AI and ask it to write me an element. I assumed that the AI would fail and tell me "I don't know how to write code for Powder Toy".
Within seconds it gave me an element class that looks promising.
I will give the prompt and its response below:
Me: "Write an element in C++ for the game Powder Toy. Name the element "DLI" with a description of "Lithium Deuteride". Give it a blue color of your choice. Have this element generate 255 pressure when the pressure near the particle is greater than 100"
ChatGPT: Here is an example element in C++ for the game Powder Toy as per the requirements:
// DLI - Lithium Deuteride // Generates pressure when pressure near the particle is greater than 100 #define col_dli 0x0000FF // Blue color for DLI int update_dli(UPDATE_FUNC_ARGS) { int r, rx, ry; for (r = 0; r < part[i].propr2; r++) { rx = rand()%5-2; ry = rand()%5-2; sim->part_change_type(i, x+rx, y+ry, PT_NEUT, NULL); sim->part_change_type(i, x+rx, y+ry, PT_HYGN, NULL); } if (part[i].temp > 273) { sim->part_change_type(i, x, y, PT_LAVA, NULL); } if (part[i].temp < 273) { sim->part_change_type(i, x, y, PT_PLSM, NULL); } if (part[i].temp > 600) { sim->part_change_type(i, x, y, PT_BOMB, NULL); } if (sim->pressure(x, y) > 100) { sim->part_change_property(i, PROP_PRESSURE, 255); } return 0; } sim->part_defaults(DLI_PT, "DLI", col_dli, update_dli, 2, PT_PROP_NEUTPASS, PT_PROP_HOT, PT_PROP_RADIOACTIVE, PT_PROP_LIFE_DEC, PT_PROP_ENERGY, PT_PROP_DEADLY, PT_PROP_EXPLOSIVE, PT_PROP_VISIBLE, PT_PROP_CONDUCTS, -1);
(I can't be certain that the code chunk above won't hit a character limit)
Feel free to pop the code chunk into a C++ formatter.
The code that ChatGPT generated isn't quite what I designed my DLI element to do, but the fact that it generated anything at all, let alone promising code, is scary and cool!
Just thought I'd share my recent experience using the AI to play around with this game.
// DLI - Lithium Deuteride
// Generates pressure when pressure near the particle is greater than 100
#define col_dli 0x0000FF
// Blue color for DLI
int update_dli(UPDATE_FUNC_ARGS) {
int r, rx, ry;
for (r = 0; r < part[i].propr2; r++)
{
rx = rand()%5-2;
ry = rand()%5-2;
sim->part_change_type(i, x+rx, y+ry, PT_NEUT, NULL);
sim->part_change_type(i, x+rx, y+ry, PT_HYGN, NULL);
}
if (part[i].temp > 273)
{
sim->part_change_type(i, x, y, PT_LAVA, NULL);
}
if (part[i].temp < 273)
{
sim->part_change_type(i, x, y, PT_PLSM, NULL);
}
if (part[i].temp > 600)
{
sim->part_change_type(i, x, y, PT_BOMB, NULL);
}
if (sim->pressure(x, y) > 100)
{
sim->part_change_property(i, PROP_PRESSURE, 255);
}
return 0;
}
sim->part_defaults(DLI_PT, "DLI", col_dli, update_dli, 2, PT_PROP_NEUTPASS, PT_PROP_HOT, PT_PROP_RADIOACTIVE, PT_PROP_LIFE_DEC, PT_PROP_ENERGY, PT_PROP_DEADLY, PT_PROP_EXPLOSIVE, PT_PROP_VISIBLE, PT_PROP_CONDUCTS, -1);