@@ -16,14 +16,14 @@ class CrisscrossNewPossiblesCreator
1616 internal Action NoNewData ;
1717
1818 internal readonly AutoResetEvent BuildingNewCrisscrossARE ;
19- protected readonly SortedSet < Crisscross > PossibleNewCrisscrossCre ;
19+ protected readonly ICollection < Crisscross > PossibleNewCrisscrossCre ;
2020 protected readonly object PossibleNewSrisscrossCreLocker ;
2121
2222 protected readonly AutoResetEvent ReducingCrisscrossARE ;
23- protected readonly List < Crisscross > PossibleToCrisscrossReduce ;
23+ protected readonly ICollection < Crisscross > PossibleToCrisscrossReduce ;
2424 protected readonly object CrisscrossReduceLocker ;
2525
26- internal CrisscrossNewPossiblesCreator ( List < ActionPDDL > actions , AutoResetEvent BuildingNewCrisscrossARE , SortedSet < Crisscross > PossibleNewCrisscrossCre , object PossibleNewSrisscrossCreLocker , AutoResetEvent ReducingCrisscrossARE , List < Crisscross > PossibleToCrisscrossReduce , object CrisscrossReduceLocker )
26+ internal CrisscrossNewPossiblesCreator ( List < ActionPDDL > actions , AutoResetEvent BuildingNewCrisscrossARE , ICollection < Crisscross > PossibleNewCrisscrossCre , object PossibleNewSrisscrossCreLocker , AutoResetEvent ReducingCrisscrossARE , ICollection < Crisscross > PossibleToCrisscrossReduce , object CrisscrossReduceLocker )
2727 {
2828 this . Actions = actions ;
2929
@@ -56,7 +56,6 @@ bool CheckPossibleOfRealization()
5656 }
5757
5858 Crisscross stateToCheck ;
59- List < Crisscross > ToAddList = new List < Crisscross > ( ) ;
6059
6160 while ( ! token . IsCancellationRequested )
6261 {
@@ -101,31 +100,61 @@ void TryActionPossibility(ThumbnailObject[] SetToCheck, int actionPos)
101100 uint ActionCost = ( uint ) Actions [ actionPos ] . actionCost . CostExpressionFunc . DynamicInvoke ( SetToCheck ) ;
102101 stateToCheck . Add ( newPossibleState , actionPos , ActionArg , ActionCost , out Crisscross AddedItem ) ;
103102
104- ToAddList . Add ( AddedItem ) ;
103+ lock ( CrisscrossReduceLocker )
104+ {
105+ PossibleToCrisscrossReduce . Add ( AddedItem ) ;
106+ }
107+ ReducingCrisscrossARE . Set ( ) ;
105108 }
106109
107- void CheckAllPos ( int actionPos , ThumbnailObject [ ] SetToCheck , int currentIndex , List < ThumbnailObject > [ ] possibleOld , List < ThumbnailObject > [ ] possibleNew , bool UntilNowOnlyOld )
110+ void CheckAllPos ( int actionPos , ThumbnailObject [ ] SetToCheck , int currentIndex , IList < ThumbnailObject > [ ] possibleOld , IList < ThumbnailObject > [ ] possibleNew , bool UntilNowOnlyOld )
108111 {
109- IEnumerable < ThumbnailObject > newone = new List < ThumbnailObject > ( possibleOld [ currentIndex ] ) ;
110-
112+ ThumbnailObject [ ] ToRemove = new ThumbnailObject [ 0 ] ;
113+
111114 if ( currentIndex != 0 )
112115 {
113- ThumbnailObject [ ] ToRemove = new ThumbnailObject [ currentIndex ] ;
116+ ToRemove = new ThumbnailObject [ currentIndex ] ;
114117 Array . Copy ( SetToCheck , ToRemove , currentIndex ) ;
115- newone = newone . Except ( ToRemove ) ;
116118 }
117119
120+ IEnumerable < ThumbnailObject > newone = possibleNew [ currentIndex ] . Except ( ToRemove ) ;
121+
122+ foreach ( ThumbnailObject thisOne in newone )
123+ {
124+ SetToCheck [ currentIndex ] = thisOne ;
125+
126+ if ( currentIndex == SetToCheck . Length - 1 )
127+ TryActionPossibility ( SetToCheck , actionPos ) ;
128+ else
129+ CheckAllPos ( actionPos , SetToCheck , currentIndex + 1 , possibleOld , possibleNew , false ) ;
130+ }
131+
132+ if ( UntilNowOnlyOld )
133+ if ( SetToCheck . Length == currentIndex + 1 )
134+ {
135+ //return;
136+ }
137+
138+ newone = possibleOld [ currentIndex ] . Except ( ToRemove ) ;
139+
118140 foreach ( ThumbnailObject thisOne in newone )
119141 {
120142 SetToCheck [ currentIndex ] = thisOne ;
121143
122144 if ( currentIndex == SetToCheck . Length - 1 )
123- TryActionPossibility ( SetToCheck , actionPos ) ;
145+ TryActionPossibility ( SetToCheck , actionPos ) ;
124146 else
125147 CheckAllPos ( actionPos , SetToCheck , currentIndex + 1 , possibleOld , possibleNew , UntilNowOnlyOld ) ;
126148 }
127149 }
128150
151+ void CheckTheOldPoss ( int actionPos , IEnumerable < ThumbnailObject > [ ] possibleCha )
152+ {
153+ if ( stateToCheck . Root is null )
154+ return ;
155+ //stateToCheck.Root.Children
156+ }
157+
129158 for ( int actionPos = 0 ; actionPos != Actions . Count ( ) ; actionPos ++ )
130159 {
131160 IEnumerable < ThumbnailObject > [ ] possibleAll = new IEnumerable < ThumbnailObject > [ Actions [ actionPos ] . InstantActionParamCount ] ;
@@ -139,42 +168,25 @@ void CheckAllPos(int actionPos, ThumbnailObject[] SetToCheck, int currentIndex,
139168 if ( possibleAll . Any ( p => ! p . Any ( ) ) )
140169 continue ;
141170
171+ CheckTheOldPoss ( actionPos , possibleCha ) ;
172+
142173 if ( possibleCha . All ( p => ! p . Any ( ) ) )
143174 {
144175 //tylko sprawdzenie poprzednich i wyjście
145176 }
146177
147178 ThumbnailObject [ ] SetToCheck = new ThumbnailObject [ Actions [ actionPos ] . InstantActionParamCount ] ;
148- List < ThumbnailObject > [ ] possibleNew = new List < ThumbnailObject > [ SetToCheck . Length ] ;
149- List < ThumbnailObject > [ ] possibleOld = new List < ThumbnailObject > [ SetToCheck . Length ] ;
179+ IList < ThumbnailObject > [ ] possibleNew = new IList < ThumbnailObject > [ SetToCheck . Length ] ;
180+ IList < ThumbnailObject > [ ] possibleOld = new IList < ThumbnailObject > [ SetToCheck . Length ] ;
150181
151182 for ( int i = 0 ; i != SetToCheck . Length ; i ++ )
152183 {
153- possibleNew [ i ] = new List < ThumbnailObject > ( possibleCha [ i ] ) ;
154- possibleOld [ i ] = new List < ThumbnailObject > ( possibleAll [ i ] ) ; // .Except(possibleNew[i]));
184+ possibleNew [ i ] = possibleCha [ i ] . ToList ( ) . AsReadOnly ( ) ;
185+ possibleOld [ i ] = possibleAll [ i ] . Except ( possibleNew [ i ] ) . ToList ( ) . AsReadOnly ( ) ;
155186 }
156187
157188 CheckAllPos ( actionPos , SetToCheck , 0 , possibleOld , possibleNew , true ) ;
158189 }
159-
160- if ( ToAddList . Any ( ) )
161- {
162- ToAddList = ToAddList . OrderBy ( c => c . CumulativedTransitionCharge ) . ToList ( ) ;
163- bool any ;
164-
165- lock ( CrisscrossReduceLocker )
166- {
167- any = PossibleToCrisscrossReduce . Any ( ) ;
168- PossibleToCrisscrossReduce . AddRange ( ToAddList ) ;
169-
170- if ( any )
171- PossibleToCrisscrossReduce . Sort ( Crisscross . SortCumulativedTransitionCharge ( ) ) ;
172-
173- ReducingCrisscrossARE . Set ( ) ;
174- }
175-
176- ToAddList . Clear ( ) ;
177- }
178190 }
179191 NoNewData . BeginInvoke ( null , null ) ;
180192 IsWaiting = true ;
0 commit comments