Alchemistry

Alchemistry

16M Downloads

Suggestion: Fission reactor generating byproducts by Alpha decay, Beta decay and Nuclear reaction

poswar opened this issue ยท 4 comments

commented

I had a lot of fun playing this mod. Thank you! :D

The suggestion

Instead of splitting the nuclei by 2, the fission reactor would generate many byproducts. One of the three events bellow could occur:

  • Alpha decay
  • Beta decay
  • Nuclear reaction

The events would be simple random (as my PoC) or, would be dependent on the number of fission Core blocks, etc... For balance reasons, maybe only heavy elements could be placed on the Fission Reactor who knows.

The Nuclear reaction would follow a normal distribution that would split the atom by 2 on average, but not always.

Technical Details

I implemented the following as Proof of concept (MC 1.12.2 version - 1.0.35) :

1) Instead of dividing by 2, refreshRecipe would choose randomly between Nuclear reaction, Alpha decay and Beta decay as follow:

    fun refreshRecipe() {
        val meta = this.input[0].metadata
        if (meta > 1) {
            if (rnd.nextBoolean()) {
                // Nuclear reaction
                if (recipeOutput1 == ItemStack.EMPTY || recipeOutput2 == ItemStack.EMPTY) {
                    val newElement = getNormalSample(meta-2)+1 
                    val otherElement = meta - newElement
    
                    recipeOutput1 = ModItems.elements.toStack(meta = newElement)
                    recipeOutput2 = ModItems.elements.toStack(meta = otherElement)
                }                
            } else {
                if (meta > 2 && rnd.nextBoolean()) {
                    // Alpha decay
                    val newElement = meta-2 
                    val otherElement = meta - newElement
    
                    recipeOutput1 = ModItems.elements.toStack(meta = newElement)
                    recipeOutput2 = ModItems.elements.toStack(meta = otherElement)
                } else {
                    // Beta decay
                    val newElement = meta-1 
                    val otherElement = meta - newElement
    
                    recipeOutput1 = ModItems.elements.toStack(meta = newElement)
                    recipeOutput2 = ModItems.elements.toStack(meta = otherElement)                    
                }
            }
        } else {
            recipeOutput1 = ItemStack.EMPTY
            recipeOutput2 = ItemStack.EMPTY                
        } 
    }

2) The Nuclear reaction would follow a normal distribution, implemented as follow:

    var rnd: Random = Random();

    private fun getNormalSample(tries: Int): Int {
        var sourceQuality = 0
        var rndSource = 0 

        var sum = 0
        
        for (i in 1..tries) {
            if (sourceQuality <= 0) {
                // Get 32 bits of random "coin flips"
                rndSource = rnd.nextInt();
                sourceQuality = 32;
            }
            
            // Extract coin flips from random source
            // On average, half of the tries would be added up
            sum += rndSource and 1
            rndSource = rndSource shr 1
            sourceQuality--;            
        }
        
        return sum;
    }

That distribution on average would split the nuclei by 2, but many elements near the average would be generated too.

3) Each fission processed would reset the recipeOutput

    fun process() {
        if (progressTicks < ConfigHandler.fissionProcessingTicks!!) {
            progressTicks++
        } else {
            progressTicks = 0
            output.setOrIncrement(0, recipeOutput1.copy())
            if (!recipeOutput2.isEmpty) output.setOrIncrement(1, recipeOutput2.copy())
            
            
            input.decrementSlot(0, 1) //Will refresh the recipe, clearing the recipeOutputs if only 1 stack is left
            recipeOutput1 = ItemStack.EMPTY
            recipeOutput2 = ItemStack.EMPTY
            refreshRecipe()        
        }
        this.energyStorage.extractEnergy(ConfigHandler.fissionEnergyPerTick!!, false)
    }
commented

Thank you for opening an issue on the Alchemistry Repository!

A few months ago Alchemistry has changed ownership. The new team has rewritten the mod from the ground up for Minecraft 1.18.2. Support for all older versions is being permanently dropped so the team can focus on newer versions.

Your feature request as described won't fit the intentions we have with the mod. This doesn't mean that there isn't a chance that your idea can become an addon at a later point in time.

commented

Thank you for taking the time to sketch this out. However, my concern is from a design standpoint more than a technical standpoint, i.e. I just am not quite sure yet if this is something I want in the mod or not...

commented

Maybe another block like the Decay Hastener from nuclearcraft that does the alfa and beta decay with some RF cost? (Only for radioactive elements)

commented

The issue with this whole thing is that alchemistry doesn't support individual isotopes, which is what determines decay types. U-235 isn't going to just magically transmute into neptunium, however U-238 double beta decays on absorption of a neutron. If alchemistry ever got full support for individual isotopes this would be feasible, however replacing a valuable existing game mechanic with RNG is not the way to go about adding more content.