public override void Make(Frame frame)
    {
        walkers = new List <Walker>();
        foreach (Edge edge in frame.FrameWalls.Keys)
        {
            if (!frame.FrameWalls[edge].HasEntry)
            {
                continue;
            }
            MakeWalkerFromTo(-edge.ToAngle(), frame.EntryPosition(edge),
                             new Vector2(frame.Width / 2.0f, frame.Height / 2.0f));
        }
        groundArray = new bool[frame.Width - 2, frame.Height - 2];
        PutWalkersOnGroundArray();
        groundArray.Add(groundArray.ThinOutline());
        int thickness = random.Next(thicknessRange.x, thicknessRange.y);

        for (int i = 0; i < thickness; i++)
        {
            groundArray.Add(groundArray.Outline(), probability: edgeSmoothness, random: this.random);
        }
        groundArray = groundArray.WithBorder();
        foreach (KeyValuePair <Edge, FrameWall> item in frame.FrameWalls)
        {
            if (item.Value.HasEntry)
            {
                MakeEntry(item.Key, item.Value);
            }
        }
        base.Make(frame);
    }
Exemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();
            var input   = File.ReadAllText("input.in").Split(Environment.NewLine.ToCharArray());
            var pattern = "(e|se|sw|w|nw|ne)+";

            List <List <direction> > Tiles = new List <List <direction> >();

            foreach (var line in input)
            {
                var matches        = Regex.Matches(line, pattern).Cast <Match>();
                List <direction> d = new List <direction>();

                foreach (var item in matches.First().Groups[1].Captures)
                {
                    d.Add(getDirection(item.ToString()));
                }
                Tiles.Add(d);
            }

            var refTile = (0, 0);

            found = new Dictionary <(int, int), bool>();
            found.Add(refTile, false);
            foreach (var tile in Tiles)
            {
                var current    = refTile;
                var directions = tile.ToList();
                foreach (var d in directions)
                {
                    current = current.GetNeighbor(d);
                    if (!found.ContainsKey(current))
                    {
                        found.Add(current, false);
                    }
                }
                found[current] = !found[current];
                if (found[current])
                {
                    var neighborsneighbors = current.GetNeighbors();
                    foreach (var nn in neighborsneighbors)
                    {
                        if (!found.ContainsKey(nn))
                        {
                            found.Add(nn, false);
                        }
                    }
                }
            }

            dtimer          = new DispatcherTimer();
            dtimer.Interval = TimeSpan.FromMilliseconds(100);
            dtimer.Tick    += Timer_Tick;
            dtimer.Start();
        }
        public void AddErrTest()
        {
            try {
                var leftSequence  = new bool[] { true, true, true, true, true };
                var rightSequence = new bool[] { true, true, true, true, true };

                bool[] res = leftSequence.Add(rightSequence).ToArray();
                Assert.Fail();
            }
            catch (InvalidOperationException) {}
            catch (Exception) {
                Assert.Fail();
            }
        }
Exemplo n.º 4
0
    static void Main()
    {
        var s = new bool[18].Select(_ => Console.ReadLine().Select(c => c - '0').ToArray()).ToList();

        s.Insert(0, new int[6]);
        s.Insert(0, new int[6]);
        s.Add(new int[6]);
        s.Add(new int[6]);

        var s2 = NewArray2(s.Count, 1 << 6, true);

        for (int i = 0; i < s.Count; i++)
        {
            for (int x = 0; x < 1 << 6; x++)
            {
                for (int xi = 0; xi < 6; xi++)
                {
                    var expected = (x >> xi) & 1;
                    if (s[i][xi] == 1 - expected)
                    {
                        s2[i][x] = false;
                        break;
                    }
                }
            }
        }

        var valid = Array.ConvertAll(new bool[1 << 18], _ => true);

        for (int x = 0; x < 1 << 18; x++)
        {
            var a = NewArray2 <int>(3, 8);
            for (int xi = 0; xi < 18; xi++)
            {
                a[xi / 6][xi % 6 + 1] = (x >> xi) & 1;
            }

            for (int j = 1; j <= 6; j++)
            {
                var p = new P(1, j);
                if ((p.Nexts().Sum(q => a[q.i][q.j]) >= 3 ? 1 : 0) != a[1][j])
                {
                    valid[x] = false;
                    break;
                }
            }
        }

        var dp = NewArray2 <long>(21, 1 << 12);

        dp[0][0] = 1;
        for (int i = 0; i < 20; i++)
        {
            for (int x = 0; x < 1 << 12; x++)
            {
                if (dp[i][x] == 0)
                {
                    continue;
                }
                for (int y = 0; y < 1 << 6; y++)
                {
                    var xy = (y << 12) | x;
                    if (valid[xy] && s2[i + 2][y])
                    {
                        dp[i + 1][xy >> 6] += dp[i][x];
                    }
                }
            }
        }
        Console.WriteLine(dp[20][0]);
    }
Exemplo n.º 5
0
    static void Main()
    {
        var s = new bool[18].Select(_ => Console.ReadLine().Select(c => c - '0').ToArray()).ToList();

        s.Insert(0, new int[6]);
        s.Insert(0, new int[6]);
        s.Add(new int[6]);
        s.Add(new int[6]);

        var valid = new List <int>();

        for (int x = 0; x < 1 << 18; x++)
        {
            var a = NewArray2 <int>(3, 8);
            for (int xi = 0; xi < 18; xi++)
            {
                a[xi / 6][xi % 6 + 1] = (x >> xi) & 1;
            }

            var ok = true;
            for (int j = 1; j <= 6; j++)
            {
                var p = new P(1, j);
                if ((p.Nexts().Sum(q => a[q.i][q.j]) >= 3 ? 1 : 0) != a[1][j])
                {
                    ok = false;
                    break;
                }
            }
            if (ok)
            {
                valid.Add(x);
            }
        }

        var dp = NewArray2 <long>(21, 1 << 12);

        dp[0][0] = 1;
        for (int i = 1; i <= 20; i++)
        {
            foreach (var x in valid)
            {
                if (Matches(i - 1, x))
                {
                    dp[i][x >> 6] += dp[i - 1][x & ((1 << 12) - 1)];
                }
            }
        }
        Console.WriteLine(dp[20][0]);

        bool Matches(int i, int x)
        {
            for (int xi = 0; xi < 18; xi++)
            {
                var c        = s[xi / 6 + i][xi % 6];
                var expected = (x >> xi) & 1;
                if (c == 1 - expected)
                {
                    return(false);
                }
            }
            return(true);
        }
    }
Exemplo n.º 6
0
    static void Main()
    {
        var h = Read();
        int n = h[0], m = h[1];
        var x = Read();
        int xab = x[0], xac = x[1], xbc = x[2];
        var s  = Console.ReadLine();
        var es = new bool[m].Select(_ => Read()).ToList();

        es.AddRange(es.ToArray().Select(e => new[] { e[1], e[0], e[2] }));

        // 1: AB, 2: BA
        // 3: AC, 4: CA
        // 5: BC, 6: CB
        for (int v = 1; v <= n; v++)
        {
            switch (s[v - 1])
            {
            case 'A':
                es.Add(new[] { v, n + 1, xab });
                es.Add(new[] { v, n + 3, xac });
                es.Add(new[] { n + 2, v, 0 });
                es.Add(new[] { n + 4, v, 0 });
                break;

            case 'B':
                es.Add(new[] { v, n + 2, xab });
                es.Add(new[] { v, n + 5, xbc });
                es.Add(new[] { n + 1, v, 0 });
                es.Add(new[] { n + 6, v, 0 });
                break;

            case 'C':
                es.Add(new[] { v, n + 4, xac });
                es.Add(new[] { v, n + 6, xbc });
                es.Add(new[] { n + 3, v, 0 });
                es.Add(new[] { n + 5, v, 0 });
                break;

            default:
                break;
            }
        }

        Console.WriteLine(Dijkstra(n + 7, es.ToArray(), true, 1, n).Item1[n]);
    }