コード例 #1
0
        private void RemoveGene(int i)
        {
            Array.Copy(Genes, i + 1, Genes, i, GenesLength - (i + 1));
            var move = new TMove();

            move.Decode((int)Genes[GenesLength - 1]);
            move.Axis = (move.Axis + 1) % 3;
            Genes[GenesLength - 1] = move.Encode();
        }
コード例 #2
0
        public void Correct()
        {
            for (int i = 0; i < GenesLength; i++)
            {
                var move = new TMove();
                move.Decode((int)Genes[i]);

                for (int j = i - 1; j >= 0; j--)
                {
                    var pMove = new TMove();
                    pMove.Decode((int)Genes[j]);

                    if (move.Axis != pMove.Axis)
                    {
                        break;
                    }

                    if (move.SegNo == pMove.SegNo)
                    {
                        RemoveGene(i);
                        i--;
                        var angle = (pMove.Angle + move.Angle + 2) % 4;

                        if (angle == 0)
                        {
                            RemoveGene(j);
                            i--;
                        }
                        else
                        {
                            pMove.Angle = angle - 1;
                            Genes[j]    = pMove.Encode();
                        }

                        break;
                    }
                }
            }
        }