Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2605_StackingProblems/HeuristicLab.Encodings.MoveVectorEncoding/3.3/Manipulators/SingleMoveEnableManipulator.cs @ 17317

Last change on this file since 17317 was 14278, checked in by mzehetho, 8 years ago

Initial Commit for ticket #2605

Implemented:

  • Encoding
  • Moves
  • Views
  • Blocks World Problem
  • Blocks Relocation Problem
  • Stacking Problem
File size: 1.3 KB
Line 
1using HeuristicLab.Common;
2using HeuristicLab.Core;
3using HeuristicLab.Data.MoveVectorData;
4using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
5
6namespace HeuristicLab.Encodings.MoveVectorEncoding.Manipulators
7{
8    [Item("SingleMoveEnableManipulator", " Enable or disable a move.")]
9    [StorableClass]
10    public class SingleMoveEnableManipulator : MoveVectorManipulator
11    {
12
13        [StorableConstructor]
14        protected SingleMoveEnableManipulator(bool deserializing) : base(deserializing) { }
15        protected SingleMoveEnableManipulator(SingleMoveEnableManipulator original, Cloner cloner) : base(original, cloner) { }
16       
17        public SingleMoveEnableManipulator() : base() { }
18
19        public override IDeepCloneable Clone(Cloner cloner)
20        {
21            return new SingleMoveEnableManipulator(this, cloner);
22        }
23
24        public static void Apply(IRandom random, MoveVector moves)
25        {
26            Manipulate(random, moves, random.Next(moves.Length));
27        }
28
29        public static void Manipulate(IRandom random, MoveVector moves, int index)
30        {
31            moves[index].Enabled = !moves[index].Enabled;
32        }
33
34        protected override void Manipulate(IRandom random, MoveVector moves)
35        {
36            Apply(random, moves);
37        }
38    }
39}
Note: See TracBrowser for help on using the repository browser.