Пример #1
0
        static void Main(string[] args)
        {
            bool gameFinished = false;

            while (!gameFinished)
            {
                Console.WriteLine("Welcome to the SUDOKU RESOLVE!");
                SudokuGame theGame = new SudokuGame();
                gameFinished = theGame.ResolveSudoku();
            }
        }
Пример #2
0
        private string Move()
        {
            if (Games != null)
            {
                SudokuGame game = Games.Get(new Guid(GameId));
                if (!game.Move(this))
                {
                    return(String.Format("error_move#{0}#{1}", X, Y));
                }
            }

            return("");
        }
Пример #3
0
        private string Exit()
        {
            if (Games != null)
            {
                SudokuGame game = Games.Get(new Guid(GameId));
                if (game != null)
                {
                    game.RemovePlayer(Name);
                }
            }

            return("");
        }
Пример #4
0
        private string Join()
        {
            if (Games != null)
            {
                SudokuGame game = Games.Get(new Guid(GameId));
                if (!game.AddPlayer(new Player(Name, WebSocket)))
                {
                    return("error#Такой игрок уже в игре");
                }

                return(String.Format("{0}#{1}#{2}#{3}", "join", game.Id, game.SudokuGrid.ToString(), Name));
            }

            return("");
        }
Пример #5
0
        private string New()
        {
            if (Games != null)
            {
                int size      = Convert.ToInt32(GameId);
                int difficult = Convert.ToInt32(X);

                SudokuGame game = new SudokuGame(new SudokuGrid(size, difficult), Games);
                game.Name = Y;
                game.AddPlayer(new Player(Name, WebSocket));

                return(String.Format("{0}#{1}#{2}#{3}", "new", game.Id, game.SudokuGrid.ToString(), Name));
            }

            return("");
        }
Пример #6
0
 public void Remove(SudokuGame game)
 {
     Games.Remove(game.Id);
 }
Пример #7
0
 public void Add(SudokuGame game)
 {
     Games.Add(game.Id, game);
 }
Пример #8
0
 public MainWindow()
 {
     InitializeComponent();
     SudokuGame game = new SudokuGame(BoardGrid, NewGameButton, HintButton, SolveButton);
 }
Пример #9
0
        private void MulaiBaru_Click(object sender, RoutedEventArgs e)
        {
            if (k != 0)
            {
                MessageBoxResult yakin = System.Windows.MessageBox.Show("Permainan belum berakhir, Anda ingin mulai baru?", "Mulai Baru", System.Windows.MessageBoxButton.YesNo);
                if (yakin == MessageBoxResult.No)
                {
                    return;
                }
            }

            if (sw.IsRunning)
            {
                sw.Stop();
                dt.Stop();
                sw.Reset();
                time.Text = "00:00:00";
            }

            Random random = new Random();

            if (level.Text.Equals("Demo"))
            {
                K = 5;
            }
            else if (level.Text.Equals("Normal"))
            {
                K = random.Next(20, 41);
            }
            else
            {
                K = 0;
            }

            SudokuGame = new SudokuGame(K);
            k          = K;
            hint       = 0;
            mistake    = 0;
            SudokuGame.generate();
            isEnabledAll(true);

            for (int i = 0; i < 9; ++i)
            {
                for (int j = 0; j < 9; ++j)
                {
                    answer[i, j]   = string.Format("{0}", SudokuGame.solution[i, j]);
                    question[i, j] = string.Format("{0}", SudokuGame.arr[i, j]);
                    if (question[i, j].Equals("0"))
                    {
                        question[i, j] = "";
                    }
                    TextBox tb = (TextBox)this.FindName(string.Format("Cell{0}{1}", i, j));
                    tb.Text       = question[i, j];
                    tb.Foreground = Brushes.Black;
                    if (question[i, j].Equals(answer[i, j]))
                    {
                        tb.IsEnabled = false;
                    }
                }
            }

            sw.Start();
            dt.Start();
        }