Integrated Dynamics

Integrated Dynamics

63M Downloads

Game crashed on a complex operator chain, head operation is the problem

icehaunter opened this issue ยท 3 comments

commented

Issue type:

  • ๐Ÿ› Bug

Short description:

Game crashed when a variable was calculated. Full process below, and I will try and replicate it

Steps to reproduce the problem:

Kinda hard to reproduce this one.

The initial task was to automate Astral Sorcery crystal growth. For this, I wanted to find a crystal in the chest, which has the largest size, which is set in NBT data

So, the first part was to create the operator, which would have a signature of Item -> Integer. It's not that complex, just NBT lookups and piping. Let's call that operator getSizeFromItem.

After that, I wanted to create a generic operator to find the crystal Item with the largest size in the List of Item.

So, here are all the functions I used, not including separate lines for constants

getSizeFromitem :: Item -> Int
map :: Operator -> List -> List

OPsizeMap :: List[Item] -> List[Int]
OPsizeMap  = apply(map, getSizeFromItem)

reduce :: Operator -> List -> Any -> Any
max :: Int -> Int -> Int

OPappliedReduce :: List -> Int -> Int
OPappliedReduce = apply(reduce, max)

OPflippedReduce :: Int -> List -> Int
OPflippedReduce = flip(OPappliedReduce)

OPgetMax :: List -> Int
OPgetMax = apply(OPflippedReduce, 0)

OPgetMaxSize :: List -> Int
OPgetMaxSize = pipe(OPsizeMap, OPgetMax)

equals :: Any -> Any -> Bool

OPcompareToMax :: List -> Int -> Bool
OPcompareToMax = pipe(OPgetMaxSize, equals)

pipe :: Operator -> Operator -> Operator

OPprependGetSize :: Operator[Int -> ...] -> Item -> ...
OPprependGetSize  = apply(pipe, getSizeFromitem)

filter :: Operator -> List -> List

OPprepareFilter :: Operator -> List -> List
OPprepareFilter = pipe(OPprependGetSize, filter)

pipe2 :: Operator -> Operator -> Operator -> Any

OPgetMaxSizeItem :: List[Item] -> List[Item]
OPgetMaxSizeItem = pipe2(OPprepareFilter , id, OPprepareFilter)

-- Here pipe2 works as follows:
-- First branch:
-- -- List goes into OPprepareFilter and it returns an operator Int -> Bool
-- Second branch just passes the list through as the second argument
-- Lastly, OPprepareFilter combines Item -> Int with Int -> Bool via OPprependGetSize 
-- and then filter the List[Item] items on the resulting Item -> Bool function

Sorry for complex code, I wanted to make it portable and not bound to the storage variables.

Up until that point everything works like a charm. Actual bug is as follows:

If you were to apply OPgetMaxSizeItem to a list and then get a head of if, it works properly in the displays

If you were to pipe OPgetMaxSizeItem into a head operator and then apply it to the list, it crashes on calculation (as soon as the variable is inserted into the monitor)

Expected behaviour:

No crashes and equivalent behaviour on both cases described above.


Versions:

Modpack: All The Mods 3 - Remix v1.0.0

  • This mod: 0.11.17
  • Minecraft: 1.12.2
  • Forge: 14.23.5.2768

Log file:

https://pastebin.com/hR9uSFdv

commented

Oh my, that's going to be an impossible one to reproduce exactly.

I assume that the problem won't be related to the size of the chain indeed.

Will look into it soon.

commented

Sorry, yeah, I know its complex, but I don't know how to reduce it. I wrote out all the functions I used with types just to make it easier to read. If you know any way I can copy-paste variables to you, That would be great

commented

Actually, forgot to add: Game doesn't crash, it freezes, stops responding and needs to be force-closed