Integrated Dynamics

Integrated Dynamics

63M Downloads

ValueOperator to ValueBoolean ClassCastException

narwhalfire opened this issue ยท 0 comments

commented

Issue type:

  • ๐Ÿ› Bug

Short description:

I was attempting to implement list sorting by generating a list of lists and map reducing the nested list. My generator for the list builder takes a list and returns that same list less the minimum value according to a comparison operator (like min). I then apply a map reduce to the nested list using the aforementioned comparison operator to get a sorted list. At some point in this process ( I suspect the map reduce) it crashes.

Steps to reproduce the problem:

There is a decent amount of logic behind the list generation, and I'm currently trying to fix the data of my world so I can actually go back in there and look at it. But I will try to describe what I did.

As example, the comparison operator used will be the minimum operator as it it what I was using when it crashed.

The list generator works by taking the minimum of the given list and using that minimum value to return a list that has been filtered to not have that value. (So my sort algorithm removes dups). I'll edit this with more accurate info when I fix my world, but this is how I think I did this.
Then I apply this list generator and a list to the lazy list builder and I pipe that to my map reduce to get a sorted list. I'll edit this with the exact variable cards when I fix my world. (edit at bottom)

My map reduce is simple and works as follows:

  • get a reduce1 and apply min
  • get a map and apply previously made operator

Expected behaviour:

listGen :: List -> List
listGen [ 3, 2, 1, 4 ] = [ 3, 2, 4 ] ;; this works
listGen [ 3 ] = [ ] ;; didn't try this alone but it should work
listGen [ ] = ? ;; didn't try this alone either, maybe it's what crashes it

listBuilder :: List -> (List -> List) -> List[List]
listbuilder [ 3, 2, 1, 4 ] listGen = [ [ 3, 2, 1, 4 ], [ 3, 2, 4 ], [ 3, 4 ], [ 4 ], [?], ?, ... ]

I don't actually know what to expect from this. I figured it might error and stop since it can't filter an empty list. Maybe I'd get infinite empty lists at the tail? Maybe I do get empty lists at tail and it crashes when I try to map reduce them. Perhaps when it gets to [ 4 ] it applies the min op to just the 4 resulting in a new operator instead of an expected boolean. This would explain the cast exception.


Versions:

  • This mod:
    1.12.2-1.0.11 (Dynamics),
    1.12.2-1.6.8 (Tunnels)
  • Minecraft: 1.12.2
  • Forge: 14.23.5.2838

It shouldn't matter but the environment is FTB:Interactions 1.9.1 launched my MultiMC 0.6.5-1302

Log file:

Trimmed to when I loaded the world, if you want the full thing for some reason I can post it.
https://pastebin.com/VBudkwVf

Edit:
Here are the variable cards I used to produce this:
My syntax is <card name>:<variable id> := <assigned value> :: <type signature>

- proxy->64         := Arithmetic Minimum       :: Number -> Number -> Number
- operator_64:116   := proxy->64                :: Number -> Number -> Number
- Identity:62       := General Identity         :: Any -> Any
- reduce1:119       := Operator Reduce1         :: Operator -> List -> Any
- rel_equals:118    := Relational Equals        :: Any -> Any -> Boolean
- filter:38         := Operator Filter          :: Operator -> List -> List
- filter_f:122      := Flip(flip) filter:38     :: List -> Operator -> List
- reduce1_op64:120          := Apply(apply) reduce1:119 operator_64:116                 :: List -> Any
- predReduc_op64Match:121   := Pipe(.) reduce1_op64:120 rel_equals:118                  :: List -> Any -> Boolean
- predReduc_op64NoMatch:142 := Negation(!.) predReduc_op64Match:121                     :: List -> Any -> Boolean
- dup_list_filter:143       := Pipe(.) predReduc_op64NoMatch:142 filter:38              :: List -> List -> List 
- op64_most_filter:144      := Pipe2(.2) Identity:62 Identity:62 dup_list_filter:144    :: List -> List
- lazybuilder:114           := List Lazy List Builder                                   :: Any -> Operator -> List
- lazybuilder_f:136         := Flip(flip) lazybuilder:114                               :: Operator -> Any -> List
- lazybuilt_less_op64reduce:145 := Apply(apply) lazybuilder_f:136 op64_most_filter:144  :: List -> List[List]
- map:128                       := Operator Map                                         :: Operator -> List -> List
- mapreduce_op64:129            := Apply(apply) map:128 reduce1_op64:120                :: List[List] -> List
- sort_op64:146                 := Pipe(.) lazybuilt_less_op64reduce:145 mapreduce_op64:129 :: List -> List

I attempted to just generate the nested list without reducing it and it still crashed so the problem must be somewhere under lazybuilt_less_op64reduce:145. Not entirely sure how the lazy builder is designed to work or how to get a finite list from it (or if I even can). Interestingly, when I first made this I didn't negate my predicate so from a list with a minimum element of 1, I got [ [3, 1, 6], [1], [1], [1], ... ]. No crash.
Let me know if there is any more information I can provide.