Example #1
0
        string Wordify(FastWord b)
        {
            var st        = new long[b._stackCount];
            var traceBits = b._trace.Select(t => t.ToSet()).ToList();

            for (int c = 0; c < traceBits.Count; c++)
            {
                foreach (var i in traceBits[c])
                {
                    st[i] |= 1L << c;
                }
            }

            return(string.Join("", st.Select(s =>
            {
                switch (s)
                {
                case 1: return 'x';

                case 2: return 'y';

                case 4: return 'z';

                default: return '?';
                }
            })));
        }
Example #2
0
        public bool Equals(FastWord other)
        {
            if (other == null || _length != other._length)
            {
                return(false);
            }

            for (int i = 0; i < _length; i++)
            {
                if (_trace[i] != other._trace[i])
                {
                    return(false);
                }
            }

            return(true);
        }
Example #3
0
        public bool IsAccessible(FastWord board, HashSet <FastWord> wonBoards)
        {
            for (int i = 0; i < board._length; i++)
            {
                for (int j = i + 1; j < board._length; j++)
                {
                    var x         = board._trace[i];
                    var y         = board._trace[j];
                    var swappable = x ^ y;

                    var winningSwapAlwaysExists = true;
                    foreach (var breakerChoice in GetBreakerChoices(swappable))
                    {
                        var winningSwapExists = false;

                        GetFixerResponses(breakerChoice);
                        for (int k = 1; k < _fixerResponseCount; k++)
                        {
                            var childBoard = new FastWord(board._trace, i, j, _fixerResponses[k], board._stackCount);
                            if (wonBoards.Contains(childBoard))
                            {
                                winningSwapExists = true;
                                break;
                            }
                        }

                        if (!winningSwapExists)
                        {
                            winningSwapAlwaysExists = false;
                            break;
                        }
                    }

                    if (winningSwapAlwaysExists)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }