Example #1
0
        public void Solve(int index, SolveType solveType)
        {
            _index = index;
            col    = _gameFile.Grid.GetColumnByIndex(_index);
            row    = _gameFile.Grid.GetRowByIndex(_index);

            if ((solveType & SolveType.reduceByColumn) != 0)
            {
                SolveColumn();
            }
            if ((solveType & SolveType.reduceByRow) != 0)
            {
                SolveRow();
            }
            if ((solveType & SolveType.reduceByGroup) != 0)
            {
                SolveGroup();
            }
            if ((solveType & SolveType.eliminateColumn) != 0)
            {
                SolveColumnByElimination();
            }
            if ((solveType & SolveType.eliminateRow) != 0)
            {
                SolveRowByElimination();
            }
            if ((solveType & SolveType.eliminateGroup) != 0)
            {
                SolveGroupByElimination();
            }
            if ((solveType & SolveType.pairWise) != 0)
            {
                SolvePairs();
            }
        }
Example #2
0
    public static float getDelay(SolveType type, int curpos, int dlen, int slen, float time)
    {
        float allowance = (time - 0.05f) / slen;

        if (allowance < 0.05f)
        {
            return(allowance);
        }

        switch (type)
        {
        case SolveType.SLOWSTART: {
            if (curpos < 8)
            {
                return(0.5f + Random.value * 2.5f);
            }
            return(0.05f);
        }

        case SolveType.ACCELERATOR: return(Mathf.Max(3f / (float)(curpos + 1), 0.05f));

        case SolveType.TRIPLETS: {
            if (curpos % 3 == 0)
            {
                return(0.25f);
            }
            return(0.05f);
        }

        default: return(0.05f);
        }
    }
Example #3
0
 public static bool getMusicToggle(SolveType type, int curpos, int dlen, int slen)
 {
     if (type == SolveType.SLOWSTART)
     {
         return((curpos == 1) || (curpos == 12));
     }
     return(false);
 }
    public static float getDelay(SolveType type, int curpos, int dlen, int slen)
    {
        switch (type)
        {
        case SolveType.SLOWSTART: {
            if (curpos < 8)
            {
                return(0.5f + Random.value * 2.5f);
            }
            return(0.05f);
        }

        case SolveType.ACCELERATOR: return(Mathf.Max(3f / (float)(curpos + 1), 0.05f));

        default: return(0.05f);
        }
    }
Example #5
0
		/// <summary>
		/// Solve the dependence of package.
		/// </summary>
		/// <returns>
		/// Packages that is needed to install.
		/// </returns>
		/// <param name='r'>
		/// A package that you want to solve its dependence. 
		/// </param>
		/// <exception cref='GuignolException'>
		/// Is thrown when some exception happens in solving dependence.
		/// </exception>
		public static Package[] SolveDepend(Package r,SolveType t)
		{
			try
			{
				var ret = new List<Package>();
				ret.Add(r);
				if(t == SolveType.Obverse)Solve(r,ref ret);
				else SolveR(r,ref ret);
				return ret.ToArray();
			}
			catch (Exception)
			{
				throw new GuignolException(
					"Some of Dependences isn't found from database." +
					"Please update repository datas and retry later.");
			}
		}
 public void SetSolver(SolveType solv)
 {
 }
Example #7
0
        public static string SolveTypeName(SolveType type)
        {
            IntPtr name = SudokuLib.SolveTypeName((int)type);

            return(Marshal.PtrToStringAnsi(name));
        }
Example #8
0
    public IEnumerator ProcessTwitchCommand(string cmd)
    {
        if (Solution == null || Position >= Solution.Length)
        {
            yield break;
        }
        cmd = cmd.ToLowerInvariant();

        int cut;

        if (cmd.StartsWith("submit "))
        {
            cut = 7;
        }
        else if (cmd.StartsWith("press "))
        {
            cut = 6;
        }
        else
        {
            yield return("sendtochaterror Use either 'submit' or 'press' followed by a number sequence.");

            yield break;
        }

        List <int> digits = new List <int>();

        char[] strSplit = cmd.Substring(cut).ToCharArray();
        foreach (char c in strSplit)
        {
            if (!"0123456789 ,".Contains(c))
            {
                yield return("sendtochaterror Invalid character in number sequence: '" + c + "'.\nValid characters are 0-9, space, and comma.");

                yield break;
            }

            int d = GetDigit(c);
            if (d != -1)
            {
                digits.Add(d);
            }
        }
        if (digits.Count == 0)
        {
            yield break;
        }

        int progress = BombInfo.GetSolvedModuleNames().Where(x => !ignoredModules.Contains(x)).Count() + ADDED_STAGES;

        if (progress < Solution.Length)
        {
            yield return("Forget Me Not");

            yield return("sendtochat DansGame A little early, don't you think?");

            Handle(digits[0]);
            yield break;
        }
        // moved to be after early-attempt since that should always be punished
        if (digits.Count > (Solution.Length - Position))
        {
            yield return("sendtochaterror NotLikeThis Too many digits submitted.");

            yield break;
        }

        yield return("Forget Me Not");

        if (FirstTry)
        {
            yield return("sendtochat OhMyDog Here we go!");
        }
        else
        {
            yield return("sendtochat Maybe this time?");
        }
        FirstTry = false;
        yield return("multiple strikes"); //Needed for fake solve.

        SolveType solve = pickSolveType(digits.Count, Solution.Length - Position);

        if (BombInfo.GetTime() / (Solution.Length - Position) < 0.1f)
        {
            solve = SolveType.REGULAR;
        }

        foreach (int d in digits)
        {
            Buttons[d].OnInteract();
            if (litButton != -1)
            {
                if (solve == SolveType.REGULAR && BombInfo.GetTime() >= 45 && Random.value > 0.95)
                {
                    yield return(new WaitForSeconds(2));

                    yield return("sendtochat Kreygasm We did it " + PlaceNames.PickRandom() + "!");

                    yield return(new WaitForSeconds(1));

                    yield return("sendtochat Kappa Nope, just kidding.");
                }
                else
                {
                    yield return("sendtochat DansGame This isn't correct...");
                }
                yield return("sendtochat Correct digits entered: " + Position);

                break;
            }
            if (Position >= Solution.Length)
            {
                yield return("sendtochat Kreygasm We did it " + PlaceNames.PickRandom() + "!");

                break;
            }

            if (getMusicToggle(solve, Position, digits.Count, Solution.Length - Position))
            {
                yield return("toggle waiting music");
            }
            yield return(new WaitForSeconds(getDelay(solve, Position, digits.Count, Solution.Length - Position, BombInfo.GetTime())));
        }
        yield return("end multiple strikes");

        yield break;
    }
Example #9
0
 public SolvedCell(Cell cell, SolveType type)
 {
     Cell = cell;
     Type = type;
 }