示例#1
0
        public override void InputValues(LayerTypes layer, FieldTypes field, int[] diceNumbers)
        {
            if (_isAnnounced)
            {
                if (field == _announcedField)
                {
                    Layers[layer].InputValues(field, diceNumbers);

                    if (field == FieldTypes.ONE)
                    {
                        Layers[LayerTypes.MIDDLE].InputValues(field, diceNumbers);
                    }
                    _isAnnounced = false;
                }
                else
                {
                    throw new InaccessibleFieldException("Posted unavailable field.");
                }
            }
            else if (Layers[layer].IsFieldFilled(field))
            {
                throw new FieldIsFilledException("The field is already filled.");
            }
            else
            {
                _isAnnounced = true;
                _announcedField = field;
            }
        }
示例#2
0
        public Layer(Tile[] tiles, int zOrder)
        {
            _tiles = tiles;
            _layerType = LayerTypes.TileLayer;

            this.ZOrder = zOrder;
        }
示例#3
0
        public override void InputValues(LayerTypes layer, FieldTypes field, int[] diceNumbers)
        {
            if (field == _fieldPointer && !IsColumnFull())
            {
                Layers[layer].InputValues(field, diceNumbers);

                if (field == FieldTypes.ONE)
                {/*ako je unos jedinica, upisuju se još i u pomoćni spremnik
                  * središnjeg sloja stupca, jer je potrebno kod računanja bodova*/

                    Layers[LayerTypes.MIDDLE].InputValues(field, diceNumbers);
                }

                if (_fieldPointer != FieldTypes.YAMB)
                {/*ako nije došlo do kraja stupca pomjeri pokazivač na sljedeće polje*/

                    int newFieldPointer = (int)_fieldPointer + 1;
                    _fieldPointer = (FieldTypes)newFieldPointer;
                }
            }
            else
            {
                throw new InaccessibleFieldException("Illegal field is selected or the column is already filled.");
            }
        }
示例#4
0
文件: Form1.cs 项目: qdm097/MNIST-CNN
        private void AddBtn_Click(object sender, EventArgs e)
        {
            int    result = int.Parse(LayerCountTxt.Text);
            string type   = null;

            if (LayerTypeCB.Text == "Fully Connected")
            {
                type = "f";
            }
            if (LayerTypeCB.Text == "Convolution")
            {
                type = "c";
                if (result > 10)
                {
                    MessageBox.Show("Convolution's layer count is squared, must still be between 0 and 100");
                    return;
                }
            }
            if (LayerTypeCB.Text == "Pooling")
            {
                type = "p";
            }
            LayerTypes.Add(type);
            LayerCounts.Add(result);
            LayerLB.Items.Add("[" + (LayerCounts.Count - 1).ToString() + "] " + LayerTypeCB.Text + ", " + result.ToString());
        }
示例#5
0
        public Layer(OrderedDictionary<string, IGameObject> gameObjects, int zOrder)
        {
            _gameObjects = gameObjects;

            _layerType = LayerTypes.ObjectLayer;

            this.ZOrder = zOrder;
        }
示例#6
0
        public override void InputValues(LayerTypes layer, FieldTypes field, int[] diceNumbers)
        {
            Layers[layer].InputValues(field, diceNumbers);

            if (field == FieldTypes.ONE)
            {
                Layers[LayerTypes.MIDDLE].InputValues(field, diceNumbers);
            }
        }
示例#7
0
        public AddLayerViewModel()
        {
            foreach (var layer in Enum.GetValues(typeof(Layer.LayerType)).Cast <Layer.LayerType>())
            {
                LayerTypes.Add(layer);
            }

            Image = BitmapHelper.ConvertBitmapToImageSource(DataAccess.Properties.Resources.LayerPreviewImage);
        }
示例#8
0
 private LayerChunk(LayerFlags flags, LayerTypes type, ushort childLevel, BlendModes blendMode, byte opacity, string name)
 {
     Flags      = flags;
     Type       = type;
     ChildLevel = childLevel;
     BlendMode  = blendMode;
     Opacity    = opacity;
     Name       = name;
 }
 public Layer()
 {
     this.LayerName     = "";
     this.Type          = LayerTypes.Layer;
     this.Inboundlayer  = new List <string>();
     this.OutboundLayer = "";
     GraphicsNode       = new GraphicsObject.GraphicsNode_UsrCtrl();
     this.ChildLayer    = new List <Layer>();
     this.ParentLayer   = new List <Layer>();
     this.isRendered    = false;
 }
示例#10
0
文件: Form1.cs 项目: qdm097/MNIST-CNN
 private void DelBtn_Click(object sender, EventArgs e)
 {
     if (LayerLB.Items.Count == 0)
     {
         return;
     }
     if (LayerLB.SelectedIndex == LayerTypes.Count - 1)
     {
         MessageBox.Show("Can't remove the output layer"); return;
     }
     LayerTypes.RemoveAt(LayerLB.SelectedIndex);
     LayerCounts.RemoveAt(LayerLB.SelectedIndex);
     LayerLB.Items.RemoveAt(LayerLB.SelectedIndex);
 }
示例#11
0
 public static Layer GetLayer(LayerTypes layerType)
 {
     switch (layerType)
     {
         case LayerTypes.FIRST:
             return new FirstLayer();
         case LayerTypes.MIDDLE:
             return new MiddleLayer();
         case LayerTypes.LAST:
             return new LastLayer();
         default:
             throw new YambException("");
     }
 }
示例#12
0
 protected virtual void Dispose(bool disposing)
 {
     if (!disposed)
     {
         if (disposing)
         {
             this.LayerName     = string.Empty;
             this.Type          = LayerTypes.Layer;
             this.Inboundlayer  = null;
             this.OutboundLayer = string.Empty;
         }
     }
     disposed = true;
 }
示例#13
0
        private void processLayer(LayerTypes lt)
        {
            UID pID         = new UIDClass();
            int layerTypeID = (int)lt;

            pID.Value = LayerTypeUIDs[(int)lt];
            List <ILayer> FoundLayerList = getLayerList(pID);

            foreach (ILayer lyr in FoundLayerList)
            {
                if (!processedLayers.Contains(lyr))
                {
                    LayerInfo lyrInfo = new LayerInfo(mapDoc);
                    switch (lt)
                    {
                    case LayerTypes.GroupLayer:
                        lyrInfo.processGroupLayer(lyr);
                        break;

                    case LayerTypes.AnnotationLayer:
                        lyrInfo.processAnnotationLayer(lyr);
                        break;

                    case LayerTypes.AnnotationSubLayer:
                        lyrInfo.processAnnotationSubLayer(lyr);
                        break;

                    case LayerTypes.RasterLayer:
                        lyrInfo.processRasterLayer(lyr);
                        break;

                    case LayerTypes.RasterCatalogLayer:
                        lyrInfo.processRasterCatalogLayer(lyr);
                        break;

                    case LayerTypes.FeatureLayer:
                        lyrInfo.processFeatureLayer(lyr);
                        break;

                    case LayerTypes.OtherLayer:
                        lyrInfo.processOtherLayer(lyr);
                        break;
                    }
                    lyrInfos.Add(lyrInfo);
                    processedLayers.Add(lyr);
                }
            }
        }
 public void Init()
 {
     nSize        = (ushort)Marshal.SizeOf(typeof(PixelFormatDescriptor));
     nVersion     = 1;
     dwFlags      = Flags.PFD_DRAW_TO_WINDOW | Flags.PFD_SUPPORT_OPENGL | Flags.PFD_DOUBLEBUFFER;
     iPixelType   = PixelType.PFD_TYPE_RGBA;
     cColorBits   = 32;
     cRedBits     = cRedShift = cGreenBits = cGreenShift = cBlueBits = cBlueShift = 0;
     cAlphaBits   = cAlphaShift = 0;
     cAccumBits   = cAccumRedBits = cAccumGreenBits = cAccumBlueBits = cAccumAlphaBits = 0;
     cDepthBits   = 32;
     cStencilBits = cAuxBuffers = 0;
     iLayerType   = LayerTypes.PFD_MAIN_PLANE;
     bReserved    = 0;
     dwLayerMask  = dwVisibleMask = dwDamageMask = 0;
 }
示例#15
0
文件: Game.cs 项目: Joop7/yamb-game
        public bool EnterDiceValue(IViewTableForm frmTableDisplay, IConfirmForm frmConfirm, ColumnTypes column, LayerTypes layer, FieldTypes field)
        {
            if (_currentDiceThrow == DiceThrow.FIRST && !_turnEnded)
            {
                frmTableDisplay.DisplayMsg(Color.Red, _msg[4]);
                return false;
            }
            else
            {
                if (ValidEntering(frmConfirm, column))
                {
                    try
                    {
                        YambTable.GetInstance().InputValue(column, layer, field, _diceRoller.Dices, _currentDiceThrow);

                        if (column == ColumnTypes.ANNOUNCEMENT)
                        {
                            AnnouncementActions(frmTableDisplay, field);
                        }
                        else
                        {
                            NextTurn();
                            frmTableDisplay.EndOfTurnActions();
                        }

                        if (YambTable.GetInstance().IsTableFull())
                        {
                            frmTableDisplay.GameFinished();
                        }
                    }
                    catch (YambException)
                    {
                        frmTableDisplay.DisplayMsg(Color.Red, _msg[5]);
                        return false;
                    }
                }
                else
                {
                    return false;
                }
            }
            return true;
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="aLayer"></param>
 /// <param name="aLayersTV"></param>
 public VectorLayerSet(VectorLayer aLayer, LayersLegend aLayersTV)
 {
     m_LayerName                  = aLayer.LayerName;
     m_FileName                   = aLayer.FileName;
     m_Handle                     = aLayer.Handle;
     m_Extent                     = aLayer.Extent;
     m_Visible                    = aLayer.Visible;
     m_LayerDrawType              = aLayer.LayerDrawType;
     m_LayerType                  = aLayer.LayerType;
     m_ShapeType                  = aLayer.ShapeType;
     m_AviodCollision             = aLayer.AvoidCollision;
     m_TransparencyPerc           = aLayer.TransparencyPerc;
     m_ShapeNum                   = aLayer.ShapeNum;
     m_LayersTV                   = aLayersTV;
     m_LegendSchemeE              = new LegendSchemeE();
     m_LegendSchemeE.LayerHandle  = aLayer.Handle;
     m_LegendSchemeE.LegendScheme = (LegendScheme)aLayer.LegendScheme.Clone();
     m_LegendSchemeE.LayersTV     = aLayersTV;
     m_IsMaskout                  = aLayer.IsMaskout;
 }
示例#17
0
 public int GetFieldValue(ColumnTypes column, LayerTypes layer, FieldTypes field)
 {
     switch (column)
     {
         case ColumnTypes.DOWN:
             return DownColumn.GetFieldValue(layer, field);
         case ColumnTypes.UP:
             return UpColumn.GetFieldValue(layer, field);
         case ColumnTypes.FREE:
             return FreeColumn.GetFieldValue(layer, field);
         case ColumnTypes.ANNOUNCEMENT:
             return AnnouncementColumn.GetFieldValue(layer, field);
         default:
             throw new YambException("");
     }
 }
示例#18
0
 public int GetFieldValue(LayerTypes layer, FieldTypes field)
 {
     switch (layer)
     {
         case LayerTypes.FIRST:
             return FLayer.GetValue(((int) field) - 1);
         case LayerTypes.MIDDLE:
             return MLayer.GetValue(((int) field) - 6);
         case LayerTypes.LAST:
             return LLayer.GetValue(((int) field) - 9);
         default:
             throw new YambException("");
     }
 }
示例#19
0
 public int GetLayerPoints(LayerTypes layer)
 {
     switch (layer)
     {
          case LayerTypes.FIRST:
             return FLayer.LayerPoints;
          case LayerTypes.MIDDLE:
             return MLayer.LayerPoints;
          case LayerTypes.LAST:
             return LLayer.LayerPoints;
         default:
             throw new YambException("");
     }
 }
示例#20
0
        public Layers(NeuralNetworks network, int layerIndex, LayerTypes layerType, KernelTypes kernelType, int neuronCount, bool useMapInfo, int mapCount, int mapWidth, int mapHeight, bool isFullyMapped, int receptiveFieldWidth, int receptiveFieldHeight, Layers previousLayer, Mappings mappings, bool lockedWeights = false)
        {
            Network = network;
            LayerIndex = layerIndex;
            LayerType = layerType;
            KernelType = kernelType;
            NeuronCount = neuronCount;
            UseMapInfo = useMapInfo;
            MapCount = mapCount;
            MapWidth = mapWidth;
            MapHeight = mapHeight;
            IsFullyMapped = isFullyMapped;
            ReceptiveFieldWidth = receptiveFieldWidth;
            ReceptiveFieldHeight = receptiveFieldHeight;
            PreviousLayer = previousLayer;
            LockedWeights = lockedWeights;

            Neurons = new Neuron[NeuronCount];
            for (int i = 0; i < NeuronCount; i++)
            {
                Neurons[i] = new Neuron();
            }

            int[] kernelTemplate;
            int iNumWeight = 0;
            int position = 0;

            switch (LayerType)
            {
                case LayerTypes.Input:
                    WeightCount = 0;
                    Weights = new Weight[WeightCount];
                    break;

                case LayerTypes.Convolutional:
                    int totalMappings;
                    if (UseMapInfo)
                    {
                        if (IsFullyMapped)
                        {
                            totalMappings = PreviousLayer.MapCount * MapCount;
                        }
                        else
                        {
                            Mappings = mappings;
                            if (Mappings != null)
                            {
                                if (Mappings.IsMapped.Count() == PreviousLayer.MapCount * MapCount)
                                    totalMappings = Mappings.IsMapped.Count(p => p == true);
                                else
                                    throw new ArgumentException("Invalid mappings definition");
                            }
                            else
                                throw new ArgumentException("Empty mappings definition");
                        }

                        WeightCount = (totalMappings * ReceptiveFieldWidth * ReceptiveFieldHeight) + MapCount;
                        Weights = new Weight[WeightCount];

                        kernelTemplate = new int[ReceptiveFieldWidth * ReceptiveFieldHeight];
                        for (int row = 0; row < ReceptiveFieldHeight; row++)
                        {
                            for (int column = 0; column < ReceptiveFieldWidth; column++)
                            {
                                kernelTemplate[column + (row * ReceptiveFieldWidth)] = column + (row * PreviousLayer.MapWidth);
                            }
                        }

                        int positionPrevMap = 0;
                        iNumWeight = 0;
                        int mapping = 0;
                        int prevCurMap = -1;
                        if (!IsFullyMapped) // not fully mapped
                        {
                            for (int curMap = 0; curMap < MapCount; ++curMap)
                            {
                                for (int prevMap = 0; prevMap < PreviousLayer.MapCount; ++prevMap)
                                {
                                    positionPrevMap = prevMap * PreviousLayer.MapWidth * PreviousLayer.MapHeight;

                                    if (mappings.IsMapped[(curMap * PreviousLayer.MapCount) + prevMap] == true)
                                    {
                                        for (int y = 0; y < MapHeight; ++y)
                                        {
                                            for (int x = 0; x < MapWidth; ++x)
                                            {
                                                position = x + (y * MapWidth) + (curMap * MapWidth * MapHeight);
                                                iNumWeight = (mapping * (ReceptiveFieldWidth * ReceptiveFieldHeight)) + curMap;
                                                if (prevCurMap != curMap)
                                                    Neurons[position].AddBias(iNumWeight++);

                                                for (int k = 0; k < (ReceptiveFieldWidth * ReceptiveFieldHeight); ++k)
                                                {
                                                    Neurons[position].AddConnection(x + (y * PreviousLayer.MapWidth) + kernelTemplate[k] + positionPrevMap, iNumWeight++);
                                                }
                                            }
                                        }
                                        mapping++;
                                        prevCurMap = curMap;
                                    }
                                }
                            }
                        }
                        else // Fully mapped
                        {
                            if (totalMappings > MapCount)
                            {
                                for (int curMap = 0; curMap < MapCount; curMap++)
                                {
                                    for (int prevMap = 0; prevMap < PreviousLayer.MapCount; prevMap++)
                                    {
                                        positionPrevMap = prevMap * PreviousLayer.MapWidth * PreviousLayer.MapHeight;

                                        for (int y = 0; y < MapHeight; y++)
                                        {
                                            for (int x = 0; x < MapWidth; x++)
                                            {
                                                position = x + (y * MapWidth) + (curMap * MapWidth * MapHeight);
                                                iNumWeight = (mapping * ReceptiveFieldWidth * ReceptiveFieldHeight) + curMap;

                                                if (prevCurMap != curMap)
                                                    Neurons[position].AddBias(iNumWeight++);

                                                for (int k = 0; k < (ReceptiveFieldWidth * ReceptiveFieldHeight); ++k)
                                                {
                                                    Neurons[position].AddConnection(x + (y * PreviousLayer.MapWidth) + kernelTemplate[k] + positionPrevMap, iNumWeight++);
                                                }
                                            }
                                        }
                                        mapping++;
                                        prevCurMap = curMap;
                                    }
                                }
                            }
                            else // PreviousLayer has only one map
                            {
                                for (int curMap = 0; curMap < MapCount; ++curMap)
                                {
                                    for (int y = 0; y < MapHeight; ++y)
                                    {
                                        for (int x = 0; x < MapWidth; ++x)
                                        {
                                            position = x + (y * MapWidth) + (curMap * MapWidth * MapHeight);
                                            iNumWeight = curMap * ((ReceptiveFieldWidth * ReceptiveFieldHeight) + 1);

                                            Neurons[position].AddBias(iNumWeight++);

                                            for (int k = 0; k < (ReceptiveFieldWidth * ReceptiveFieldHeight); ++k)
                                            {
                                                Neurons[position].AddConnection(x + (y * PreviousLayer.MapWidth) + kernelTemplate[k], iNumWeight++);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new ArgumentException("Inadequate mapping information provided");
                    }
                    break;

                case LayerTypes.ConvolutionalSubsampling:  // Simard's implementation
                    if (UseMapInfo)
                    {
                        if (IsFullyMapped)
                        {
                            totalMappings = PreviousLayer.MapCount * MapCount;
                        }
                        else
                        {
                            Mappings = mappings;
                            if (Mappings != null)
                            {
                                if (Mappings.IsMapped.Count() == PreviousLayer.MapCount * MapCount)
                                    totalMappings = Mappings.IsMapped.Count(p => p == true);
                                else
                                    throw new ArgumentException("Invalid mappings definition");
                            }
                            else
                                throw new ArgumentException("Empty mappings definition");
                        }

                        WeightCount = (totalMappings * ReceptiveFieldWidth * ReceptiveFieldHeight) + MapCount;
                        Weights = new Weight[WeightCount];

                        kernelTemplate = new int[ReceptiveFieldWidth * ReceptiveFieldHeight];
                        for (int row = 0; row < ReceptiveFieldHeight; ++row)
                        {
                            for (int column = 0; column < ReceptiveFieldWidth; ++column)
                            {
                                kernelTemplate[column + (row * ReceptiveFieldWidth)] = column + (row * PreviousLayer.MapWidth);
                            }
                        }

                        int positionPrevMap = 0;
                        iNumWeight = 0;
                        int mapping = 0;
                        int prevCurMap = -1;
                        if (!IsFullyMapped) // not fully mapped
                        {
                            for (int curMap = 0; curMap < MapCount; ++curMap)
                            {
                                for (int prevMap = 0; prevMap < PreviousLayer.MapCount; ++prevMap)
                                {
                                    positionPrevMap = prevMap * PreviousLayer.MapWidth * PreviousLayer.MapHeight;

                                    if (mappings.IsMapped[(curMap * PreviousLayer.MapCount) + prevMap] == true)
                                    {
                                        for (int y = 0; y < MapHeight; ++y)
                                        {
                                            for (int x = 0; x < MapWidth; ++x)
                                            {
                                                position = x + (y * MapWidth) + (curMap * MapWidth * MapHeight);
                                                iNumWeight = (mapping * (ReceptiveFieldWidth * ReceptiveFieldHeight)) + curMap;
                                                if (prevCurMap != curMap)
                                                    Neurons[position].AddBias(iNumWeight++);

                                                for (int k = 0; k < (ReceptiveFieldWidth * ReceptiveFieldHeight); ++k)
                                                {
                                                    Neurons[position].AddConnection((x * 2)+ (y * 2 * PreviousLayer.MapWidth) + kernelTemplate[k] + positionPrevMap, iNumWeight++);
                                                }
                                            }
                                        }
                                        mapping++;
                                        prevCurMap = curMap;
                                    }
                                }
                            }
                        }
                        else // Fully mapped
                        {
                            if (totalMappings > MapCount)
                            {
                                for (int curMap = 0; curMap < MapCount; ++curMap)
                                {
                                    for (int prevMap = 0; prevMap < PreviousLayer.MapCount; ++prevMap)
                                    {
                                        positionPrevMap = prevMap * PreviousLayer.MapWidth * PreviousLayer.MapHeight;

                                        for (int y = 0; y < MapHeight; ++y)
                                        {
                                            for (int x = 0; x < MapWidth; ++x)
                                            {
                                                position = x + (y * MapWidth) + (curMap * MapWidth * MapHeight);
                                                iNumWeight = (mapping * ReceptiveFieldWidth * ReceptiveFieldHeight) + curMap;

                                                if (prevCurMap != curMap)
                                                    Neurons[position].AddBias(iNumWeight++);

                                                for (int k = 0; k < (ReceptiveFieldWidth * ReceptiveFieldHeight); ++k)
                                                {
                                                    Neurons[position].AddConnection((x * 2) + (y * 2 * PreviousLayer.MapWidth) + kernelTemplate[k] + positionPrevMap, iNumWeight++);
                                                }
                                            }
                                        }
                                        mapping++;
                                        prevCurMap = curMap;
                                    }
                                }
                            }
                            else // PreviousLayer has only one map
                            {
                                for (int curMap = 0; curMap < MapCount; ++curMap)
                                {
                                    for (int y = 0; y < MapHeight; ++y)
                                    {
                                        for (int x = 0; x < MapWidth; ++x)
                                        {
                                            position = x + (y * MapWidth) + (curMap * MapWidth * MapHeight);
                                            iNumWeight = curMap * ((ReceptiveFieldWidth * ReceptiveFieldHeight) + 1);

                                            Neurons[position].AddBias(iNumWeight++);

                                            for (int k = 0; k < (ReceptiveFieldWidth * ReceptiveFieldHeight); ++k)
                                            {
                                                Neurons[position].AddConnection((x * 2) + (y * 2 * PreviousLayer.MapWidth) + kernelTemplate[k], iNumWeight++);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new ArgumentException("Inadequate mapping information provided");
                    }
                    break;

                case LayerTypes.Subsampling:
                    if (UseMapInfo)
                    {
                        if (IsFullyMapped)
                        {
                            // Symmetrical mapping
                            List<bool> mapCombinations = new List<bool>(PreviousLayer.MapCount * MapCount);
                            for (int x = 0; x < MapCount; x++)
                            {
                                for (int y = 0; y < PreviousLayer.MapCount; y++)
                                {
                                    mapCombinations.Add(x == y);
                                }
                            }
                            mappings = new Mappings(network, PreviousLayer.LayerIndex, mapCombinations);
                        }

                        Mappings = mappings;
                        if (Mappings != null)
                        {
                            if (Mappings.IsMapped.Count() == PreviousLayer.MapCount * MapCount)
                                totalMappings = Mappings.IsMapped.Count(p => p == true);
                            else
                                throw new ArgumentException("Invalid mappings definition");
                        }
                        else
                            throw new ArgumentException("Empty mappings definition");

                        WeightCount = MapCount * 2;
                        Weights = new Weight[WeightCount];

                        SubsamplingScalingFactor = 1D / (receptiveFieldWidth * ReceptiveFieldHeight);

                        kernelTemplate = new int[ReceptiveFieldWidth * ReceptiveFieldHeight];
                        for (int row = 0; row < ReceptiveFieldHeight; ++row)
                        {
                            for (int column = 0; column < ReceptiveFieldWidth; ++column)
                            {
                                kernelTemplate[column + (row * ReceptiveFieldWidth)] = column + (row * PreviousLayer.MapWidth);
                            }
                        }

                        int positionPrevMap = 0;
                        iNumWeight = 0;
                        if (PreviousLayer.MapCount > 1) //fully symmetrical mapped
                        {
                            for (int curMap = 0; curMap < MapCount; ++curMap)
                            {
                                for (int prevMap = 0; prevMap < PreviousLayer.MapCount; ++prevMap)
                                {
                                    positionPrevMap = prevMap * PreviousLayer.MapWidth * PreviousLayer.MapHeight;

                                    if (mappings.IsMapped[(curMap * PreviousLayer.MapCount) + prevMap] == true)
                                    {
                                        for (int y = 0; y < MapHeight; ++y)
                                        {
                                            for (int x = 0; x < MapWidth; ++x)
                                            {
                                                position = x + (y * MapWidth) + (curMap * MapWidth * MapHeight);
                                                iNumWeight = curMap * 2;
                                                Neurons[position].AddBias(iNumWeight++);

                                                for (int k = 0; k < (ReceptiveFieldWidth * ReceptiveFieldHeight); ++k)
                                                {
                                                    Neurons[position].AddConnection((x * ReceptiveFieldWidth) + (y * ReceptiveFieldHeight * PreviousLayer.MapWidth) + kernelTemplate[k] + positionPrevMap, iNumWeight);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else // only one previous layer
                        {
                            for (int curMap = 0; curMap < MapCount; ++curMap)
                            {
                                for (int y = 0; y < MapHeight; ++y)
                                {
                                    for (int x = 0; x < MapWidth; ++x)
                                    {
                                        position = x + (y * MapWidth) + (curMap * MapWidth * MapHeight);
                                        iNumWeight = curMap * 2;

                                        Neurons[position].AddBias(iNumWeight++);

                                        for (int k = 0; k < (ReceptiveFieldWidth * ReceptiveFieldHeight); ++k)
                                        {
                                            Neurons[position].AddConnection((x * ReceptiveFieldWidth) + (y * ReceptiveFieldHeight * PreviousLayer.MapWidth) + kernelTemplate[k], iNumWeight);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    break;

                case LayerTypes.FullyConnected:
                    WeightCount = (PreviousLayer.NeuronCount + 1) * NeuronCount;
                    Weights = new Weight[WeightCount];

                    iNumWeight = 0;
                    if (UseMapInfo)
                    {
                        for (int curMap = 0; curMap < MapCount; ++curMap)
                        {
                            for (int yc = 0;  yc < MapHeight; ++yc)
                            {
                                for (int xc = 0; xc < MapWidth; ++xc)
                                {
                                    position = xc + (yc * MapWidth) + (curMap * MapWidth * MapHeight);
                                    Neurons[position].AddBias(iNumWeight++);

                                    for (int prevMaps = 0; prevMaps < PreviousLayer.MapCount; ++prevMaps)
                                    {
                                        for (int y = 0; y < PreviousLayer.MapHeight; ++y)
                                        {
                                            for (int x = 0; x < PreviousLayer.MapWidth; ++x)
                                            {
                                                Neurons[position].AddConnection((x + (y * PreviousLayer.MapWidth) + (prevMaps * PreviousLayer.MapWidth * PreviousLayer.MapHeight)), iNumWeight++);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int y = 0; y < NeuronCount; ++y)
                        {
                            Neurons[y].AddBias(iNumWeight++);
                            for (int x = 0; x < PreviousLayer.NeuronCount; ++x)
                            {
                                Neurons[y].AddConnection(x, iNumWeight++);
                            }
                        }
                    }
                    break;

                case LayerTypes.RBF:
                    WeightCount = PreviousLayer.NeuronCount * NeuronCount; // no biasses
                    Weights = new Weight[WeightCount];

                    iNumWeight = 0;
                    if (UseMapInfo)
                    {
                        for (int n = 0; n < NeuronCount; ++n)
                        {
                            for (int prevMaps = 0; prevMaps < PreviousLayer.MapCount; ++prevMaps)
                            {
                                for (int y = 0; y < PreviousLayer.MapHeight; ++y)
                                {
                                    for (int x = 0; x < PreviousLayer.MapWidth; ++x)
                                    {
                                        Neurons[n].AddConnection((x + (y * PreviousLayer.MapWidth) + (prevMaps * PreviousLayer.MapWidth * PreviousLayer.MapHeight)), iNumWeight++);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int y = 0; y < NeuronCount; ++y)
                        {
                            for (int x = 0; x < PreviousLayer.NeuronCount; ++x)
                            {
                                Neurons[y].AddConnection(x, iNumWeight++);
                            }
                        }
                    }
                    break;
            };

            int conn = 0;
            foreach (Neuron neuron in Neurons)
            {
                conn += neuron.Connections.Count();
            }

            Name += "Layer: " + LayerIndex.ToString(CultureInfo.CurrentCulture) + "\r\n";
            Name += "Layer type: " + LayerType.ToString() + "\r\n" +
                   ((KernelType != KernelTypes.None) ? ("Kernel type: " + KernelType.ToString() + "\r\n") : ("")) +
                   ((LayerType == LayerTypes.Convolutional) ? ("Receptive field: " + ReceptiveFieldWidth.ToString(CultureInfo.CurrentCulture) + "x" + ReceptiveFieldHeight.ToString(CultureInfo.CurrentCulture) + "\r\n") : "") +
                   ((UseMapInfo) ? ("Maps: " + MapCount.ToString(CultureInfo.CurrentCulture) + "x(" + MapWidth.ToString(CultureInfo.CurrentCulture) + "x" + MapHeight.ToString(CultureInfo.CurrentCulture) + ")" + "\r\n") : ("")) +
                   "Neurons: " + NeuronCount.ToString(CultureInfo.CurrentCulture) + "\r\n" +
                   ((LayerType != LayerTypes.Input) ? ("Weights: " + Weights.Count().ToString(CultureInfo.CurrentCulture) + "\r\n") : ("")) +
                   "Connections: " + conn.ToString(CultureInfo.CurrentCulture) + "\r\n";

            if (PreviousLayer != null)
            {
                PreviousLayer.NextLayer = this;
            }
        }
示例#21
0
 public void PreSelect()
 {
     SelectedLayerType = LayerTypes.FirstOrDefault(t => t.Name == ProposedLayer.LayerType.Name);
     ToggleIsEvent();
 }
示例#22
0
 /// <summary>
 /// Gets the layer childrens.
 /// </summary>
 /// <returns>The ccnode childrens.</returns>
 /// <param name="layer">The layer.</param>
 public CCNode GetChildrens(LayerTypes layer)
 {
     return m_childs[layer];
 }
示例#23
0
 public int GetLayerPointsByColumn(ColumnTypes column, LayerTypes layer)
 {
     return Columns[column].GetLayerPoints(layer);
 }
示例#24
0
 public ManagedLayer(int scale)
 {
     Type  = LayerTypes.Subsampling;
     Scale = scale;
 }
示例#25
0
文件: Column.cs 项目: Joop7/yamb-game
 public int GetLayerPoints(LayerTypes layer)
 {
     return Layers[layer].GetLayerPoints();
 }
            public void read(Reader reader)
            {
                width = reader.ReadByte();
                reader.ReadByte(); // Unused

                height = reader.ReadByte();
                reader.ReadByte(); // Unused

                type = (LayerTypes)reader.ReadByte();

                // 2 bytes, little-endian, signed
                parallaxFactor  = reader.ReadByte();
                parallaxFactor |= (short)(reader.ReadByte() << 8);
                scrollSpeed     = reader.ReadByte();

                lineScroll = new byte[height * 128];

                // Read Line Scroll
                byte[] buf = new byte[3];
                int    pos = 0;

                // For some reason some BG files in v4 have some trailing bytes and end up having more than [height * 128] bytes for line scroll
                // they aren't used in-engine as you'd expect so we dont really need to account for them here, the files are functionally identical without em anyways
                while (true)
                {
                    buf[0] = reader.ReadByte();
                    if (buf[0] == 0xFF)
                    {
                        buf[1] = reader.ReadByte();
                        if (buf[1] != 0xFF)
                        {
                            buf[2] = reader.ReadByte();
                            byte val = buf[1];
                            int  cnt = buf[2] - 1;
                            for (int c = 0; c < cnt; ++c)
                            {
                                if (pos < lineScroll.Length)
                                {
                                    lineScroll[pos++] = val;
                                }
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        if (pos < lineScroll.Length)
                        {
                            lineScroll[pos++] = buf[0];
                        }
                    }
                }

                layout = new ushort[height][];
                for (int m = 0; m < height; m++)
                {
                    layout[m] = new ushort[width];
                }

                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        // 128x128 Block number is 16-bit
                        // Little-Endian in RSDKv4
                        layout[y][x]  = reader.ReadByte();
                        layout[y][x] |= (ushort)(reader.ReadByte() << 8);
                    }
                }
            }
示例#27
0
        public void InputValue(ColumnTypes column, LayerTypes layer, FieldTypes field, int[] diceNumbers, DiceThrow diceThrow)
        {
            if (column == ColumnTypes.ANNOUNCEMENT && !_announced)
            {
                if (diceThrow == DiceThrow.SECOND)
                {
                    Columns[column].InputValues(layer, field, diceNumbers);
                    _announced = true;
                }
                else
                {
                    throw new InaccessibleFieldException("The field is unavailable.");
                }
            }
            else if (_announced && column != ColumnTypes.ANNOUNCEMENT)
            {
                throw new InaccessibleFieldException("The field is unavailable.");
            }
            else
            {
                Columns[column].InputValues(layer, field, diceNumbers);
                _announced = false;
            }

            NotifyObservers();
        }
示例#28
0
文件: Column.cs 项目: Joop7/yamb-game
 public abstract void InputValues(LayerTypes layer, FieldTypes field, int[] diceNumbers);
示例#29
0
 public Layers(NeuralNetworks network, LayerTypes layerType, KernelTypes kernelType, int neuronCount, Mappings mappings, bool lockedWeights = false)
     : this(network, ((network.Layers.Count == 0) ? (0) : (network.Layers.Count)), layerType, kernelType, neuronCount, false, 1, 1, 1, false, 0, 0, ((network.Layers.Count == 0) ? (null) : (network.Layers[network.Layers.Count - 1])), mappings, lockedWeights)
 {
 }
示例#30
0
 public Layers(NeuralNetworks network, LayerTypes layerType, KernelTypes kernelType, int mapCount, int mapWidth, int mapHeight, bool lockedWeights = false)
     : this(network, ((network.Layers.Count == 0) ? (0) : (network.Layers.Count)), layerType, kernelType, mapCount * mapWidth * mapHeight, true, mapCount, mapWidth, mapHeight, true, 0, 0, ((network.Layers.Count == 0) ? (null) : (network.Layers[network.Layers.Count - 1])), null, lockedWeights)
 {
 }
示例#31
0
 public int GetLayerPointsByColumn(ColumnTypes column, LayerTypes layer)
 {
     switch (column)
     {
         case ColumnTypes.DOWN:
             return DownColumn.GetLayerPoints(layer);
         case ColumnTypes.UP:
             return UpColumn.GetLayerPoints(layer);
         case ColumnTypes.FREE:
             return FreeColumn.GetLayerPoints(layer);
         case ColumnTypes.ANNOUNCEMENT:
             return AnnouncementColumn.GetLayerPoints(layer);
         default:
             throw new YambException("");
     }
 }
示例#32
0
文件: Column.cs 项目: Joop7/yamb-game
 public int GetFieldValue(LayerTypes layer, FieldTypes field)
 {
     return Layers[layer].GetFieldValue(field);
 }
示例#33
0
 public int GetTotalLayerPoints(LayerTypes layerType)
 {
     switch (layerType)
     {
         case LayerTypes.FIRST:
             return DownColumn.FLayer.LayerPoints + UpColumn.FLayer.LayerPoints + FreeColumn.FLayer.LayerPoints +
                    AnnouncementColumn.FLayer.LayerPoints;
         case LayerTypes.MIDDLE:
             return DownColumn.MLayer.LayerPoints + UpColumn.MLayer.LayerPoints + FreeColumn.MLayer.LayerPoints +
                    AnnouncementColumn.MLayer.LayerPoints;
         case LayerTypes.LAST:
             return DownColumn.LLayer.LayerPoints + UpColumn.LLayer.LayerPoints + FreeColumn.LLayer.LayerPoints +
                    AnnouncementColumn.LLayer.LayerPoints;
         default:
             throw new YambException("");
     }
 }
示例#34
0
 private void processLayer(LayerTypes lt)
 {
     UID pID = new UIDClass();
     int layerTypeID = (int)lt;
     pID.Value = LayerTypeUIDs[(int)lt];
     List<ILayer> FoundLayerList = getLayerList(pID);
     foreach (ILayer lyr in FoundLayerList)
     {
         if (!processedLayers.Contains(lyr))
         {
             LayerInfo lyrInfo = new LayerInfo(mapDoc);
             switch (lt)
             {
                 case LayerTypes.GroupLayer:
                     lyrInfo.processGroupLayer(lyr);
                     break;
                 case LayerTypes.AnnotationLayer:
                     lyrInfo.processAnnotationLayer(lyr);
                     break;
                 case LayerTypes.AnnotationSubLayer:
                     lyrInfo.processAnnotationSubLayer(lyr);
                     break;
                 case LayerTypes.RasterLayer:
                     lyrInfo.processRasterLayer(lyr);
                     break;
                 case LayerTypes.RasterCatalogLayer:
                     lyrInfo.processRasterCatalogLayer(lyr);
                     break;
                 case LayerTypes.FeatureLayer:
                     lyrInfo.processFeatureLayer(lyr);
                     break;
                 case LayerTypes.OtherLayer:
                     lyrInfo.processOtherLayer(lyr);
                     break;
             }
             lyrInfos.Add(lyrInfo);
             processedLayers.Add(lyr);
         }
     }
 }
示例#35
0
 public ManagedLayer(int outputMaps, int kernelSize)
 {
     Type       = LayerTypes.Convolution;
     KernelSize = kernelSize;
     OutputMaps = outputMaps;
 }
示例#36
0
            public void read(Reader reader)
            {
                width  = reader.ReadByte();
                height = reader.ReadByte();
                type   = (LayerTypes)reader.ReadByte();

                parallaxFactor = reader.ReadByte();
                scrollSpeed    = reader.ReadByte();

                lineScroll = new byte[height * 128];

                // Read Line Scroll
                byte[] buf = new byte[3];
                int    pos = 0;

                while (true)
                {
                    buf[0] = reader.ReadByte();
                    if (buf[0] == 0xFF)
                    {
                        buf[1] = reader.ReadByte();
                        if (buf[1] != 0xFF)
                        {
                            buf[2] = reader.ReadByte();
                            byte val = buf[1];
                            int  cnt = buf[2] - 1;
                            for (int c = 0; c < cnt; ++c)
                            {
                                if (pos < lineScroll.Length)
                                {
                                    lineScroll[pos++] = val;
                                }
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        if (pos < lineScroll.Length)
                        {
                            lineScroll[pos++] = buf[0];
                        }
                    }
                }

                layout = new byte[height][];
                for (int m = 0; m < height; m++)
                {
                    layout[m] = new byte[width];
                }

                for (int y = 0; y < height; y++)
                {
                    //128x128 Block number is 8-bit in RSDKv2
                    for (int x = 0; x < width; x++)
                    {
                        layout[y][x] = reader.ReadByte();
                    }
                }
            }
示例#37
0
 public int GetTotalLayerPoints(LayerTypes layer)
 {
     int totalLayerPoints = 0;
     foreach (KeyValuePair<ColumnTypes, Column> column in Columns)
     {
         try
         {
             totalLayerPoints += column.Value.GetLayerPoints(layer);
         }
         catch (MissingParametarsException)
         { }
     }
     return totalLayerPoints;
 }
示例#38
0
 public Layers(NeuralNetworks network, LayerTypes layerType, KernelTypes kernelType, int mapCount, int mapWidth, int mapHeight, int receptiveFieldWidth, int receptiveFieldHeight, Mappings mappings, bool lockedWeights = false)
     : this(network, ((network.Layers.Count == 0) ? (0) : (network.Layers.Count)), layerType, kernelType, mapCount * mapWidth * mapHeight, true, mapCount, mapWidth, mapHeight, false, receptiveFieldWidth, receptiveFieldHeight, network.Layers[network.Layers.Count - 1], mappings, lockedWeights)
 {
 }
示例#39
0
        public int GetFieldValue(ColumnTypes column, LayerTypes layer, FieldTypes field)
        {
            int value = 0;
            try
            {
                value = Columns[column].GetFieldValue(layer, field);
            }
            catch (FieldIsEmptyException)
            {
            }
            catch (KeyNotFoundException)
            {
                throw new NonExistingFieldException("There is no such field in the selected layer.");
            }

            return value;
        }
示例#40
0
 public ManagedLayer()
 {
     Type = LayerTypes.Input;
 }