public ProcessFactory(int gridWidth, int gridHeight, string wfcDebugPath, string tilesetDebugPath)
 {
     myGrid = new IntentionGrid(gridWidth, gridHeight);
     random = new marcRandom(0);
     myTilesetConfiguration = new TilesetConfiguration(wfcDebugPath, tilesetDebugPath);
     myProcess = new T();
     myProcess.Init(random, myGrid, myTilesetConfiguration);
     _wfcDebugPath     = wfcDebugPath;
     _tilesetDebugPath = tilesetDebugPath;
 }
示例#2
0
        public static WcfGrid InitWcfGrid(Random random, IntentionGrid grid, TilesetConfiguration TilesConfig)
        {
            var WcfGrid = new WcfGrid(random);

            WcfGrid.Init(grid.Width, grid.Height, 1, TilesConfig.MainDistinct.Select(x => (IOpinionatedItem)x).ToList());
            List <WcfVector> shape = WcfVector.GetCross3dShape();

            WcfGrid.SetInfluenceShape(shape);
            WcfGrid.handlePropagation(WcfGrid.SuperPositions[WcfGrid.Width / 2, WcfGrid.Height / 2, 0]);
            return(WcfGrid);
        }
示例#3
0
        private static List <List <Bitmap> > ToTilesList(WcfGrid grid, TilesetConfiguration TilesConfig)
        {
            var Tiles = new List <List <Bitmap> >();

            for (var x = 0; x < grid.Width; x++)
            {
                for (var y = 0; y < grid.Height; y++)
                {
                    if (y == 0)
                    {
                        Tiles.Add(new List <Bitmap>());
                    }

                    Tiles.Last().Add(grid.SuperPositions[x, y, 0].FinalPayloadIfExists <Bitmap>(TilesConfig.CautionTile, TilesConfig.ErrorTile));
                }
            }
            return(Tiles);
        }
示例#4
0
        public static bool ApplyIntentionToGrid(IntentionGrid grid, WcfGrid wcfGrid, TilesetConfiguration tilesconfig, iMeaningConverter converter)
        {
            for (var x = 0; x < grid.Width; x++)
            {
                for (var y = 0; y < grid.Height; y++)
                {
                    if (y == 8 && x == 7)
                    {
                        var breaka = "here";
                    }
                    var intentions = grid.Positions[x, y].Intentions;
                    if (intentions.Count != 0)
                    {
                        List <OpinionatedItem <Bitmap> > crossedTiles = new List <OpinionatedItem <Bitmap> >();
                        var firsttime = true;
                        foreach (var intention in intentions)
                        {
                            if (firsttime)
                            {
                                crossedTiles.AddRange(converter.MeaningToTiles(intention.Meaning, tilesconfig));
                                firsttime = false;
                            }
                            else
                            {
                                crossedTiles = crossedTiles.Where(c => converter.MeaningToTiles(intention.Meaning, tilesconfig).Any(n => n.Id == c.Id)).ToList();
                            }
                        }
                        if (crossedTiles.Count == 0)
                        {
                            Console.WriteLine("Crossing Tile Intentions yeilded no items!");
                        }
                        //DebugWfcPrint(crossedTiles, wcfGrid, x, y, tilesconfig.WFCdebugFolderPath);
                        wcfGrid.SuperPositions[x, y, 0].CollapseToItems(crossedTiles.Select(c => c.Id).ToList(), true);
                        if (!wcfGrid.SuperPositions[x, y, 0].slots.Any(s => !s.Collapsed))
                        {
                            Console.WriteLine("Collapse To Specific Item failed for Intentions:");
                            foreach (var meaning in intentions.Select(i => i.Meaning))
                            {
                                Console.WriteLine(" -" + meaning.ToString());
                            }
                            DebugWfcPrint(crossedTiles, wcfGrid, x, y, tilesconfig.WFCdebugFolderPath);
                        }

                        var result = wcfGrid.handlePropagation(wcfGrid.SuperPositions[x, y, 0]);

                        if (!result)
                        {
                            Console.WriteLine("WcfGrid fucke dup");
                            //throw new Exception("WcfGrid fucke dup");
                            return(false);
                        }
                    }
                }
            }

            var recurseresult = wcfGrid.CollapseAllRecursive();

            if (!recurseresult)
            {
                Console.WriteLine("WcfGrid collapse recursive fucke dup");
                //throw new Exception("WcfGrid collapse recursive fucke dup");
                return(false);
            }

            return(true);
        }
示例#5
0
 public static Bitmap ToBitmap(WcfGrid grid, TilesetConfiguration TilesConfig)
 {
     return(BitmapOperations.CreateBitmapFromTiles(ToTilesList(grid, TilesConfig)));
 }