private int CalculateScore(BoardPosition[,] boardState, TeamName teamName)
        {
            OptionBuilder        optionBuilder       = new OptionBuilder(teamName);
            List <BoardPosition> ownedBoardPositions = new List <BoardPosition>();
            int totalScore = 0;

            foreach (var bp in boardState)
            {
                if (bp.Owner == teamName)
                {
                    ownedBoardPositions.Add(bp);
                }
            }

            foreach (var pos in ownedBoardPositions)
            {
                Option option = optionBuilder.BuildOption(pos, boardState);
                foreach (var target in option.Targets)
                {
                    if (target.CheckIfTargetValid(boardState, teamName))
                    {
                        int score = target.FourChance(boardState, teamName);
                        if (score == 6 && IsBlockable(target))
                        {
                            score /= 4;
                        }
                        totalScore += score;
                    }
                }
            }
            return(totalScore);
        }
Esempio n. 2
0
        public static string BuildHelp()
        {
            StringBuilder builder = new StringBuilder();

            // Description
            builder.Append("DESCRIPTION:\r\n")
            .Append(TAB1).Append("This is a windows service, it can run other application as service.\r\n\r\n");
            // Usage
            builder.Append("USAGE:\r\n")
            .Append(TAB1).Append(Path.GetFileName(Assembly.GetExecutingAssembly().Location)).Append(" [command] [--ServiceName] <option1> <option2> ...\r\n\r\n");
            Options       opts = CLICommand.CreateOptions();
            OptionBuilder ob   = new OptionBuilder(opts, TAB1);

            // Install
            ob.BuildOption(builder,
                           new string[] { CLI_INSTALL, CLI_DISPLAYNAME, CLI_DESCRIPTION, CLI_STARTMODE, CLI_CLASSPATH, CLI_STARTPARAM, CLI_STOPPARAM },
                           new string[] { TAB1, TAB3, TAB3, TAB3, TAB3, TAB3, TAB3 });
            // Uninstall
            ob.BuildOption(builder,
                           new string[] { CLI_UNINSTALL },
                           new string[] { TAB1 });
            // Start
            ob.BuildOption(builder,
                           new string[] { CLI_START },
                           new string[] { TAB1 });
            // Stop
            ob.BuildOption(builder,
                           new string[] { CLI_STOP },
                           new string[] { TAB1 });
            // Restart
            ob.BuildOption(builder,
                           new string[] { CLI_RESTART },
                           new string[] { TAB1 });
            // Help
            ob.BuildOption(builder,
                           new string[] { CLI_HELP },
                           new string[] { TAB1 });
            return(builder.ToString());
        }