예제 #1
0
        public void newGame()
        {
            int[] org = {
                        99,	99,	99,	99,	99,	99,	99,	99,	99,	99,
                        99,	99,	99,	99,	99,	99,	99,	99,	99,	99,
                        99,	124,	22,	23,	25,	126,	23,	22,	124,	99,
                        99,	21,	21,	21,	21,	21,	21,	21,	21,	99,
                        99,	00,	00,	00,	00,	00,	00,	00,	00,	99,
                        99,	00,	00,	00,	00,	00,	00,	00,	00,	99,
                        99,	00,	00,	00,	00,	00,	00,	00,	00,	99,
                        99,	00,	00,	00,	00,	00,	00,	00,	00,	99,
                        99,	11,	11,	11,	11,	11,	11,	11,	11,	99,
                        99,	114,	12,	13,	15,	116,	13,	12,	114,	99,
                        99,	99,	99,	99,	99,	99,	99,	99,	99,	99,
                        99,	99,	99,	99,	99,	99,	99,	99,	99,	99 };

            board = new int[120];

            for (int i = 0; i < 120; i++)
                board[i] = org[i];

            // Quy dinh player
            isP1Run = true;
            player1 = new Player(Player.Type.Human,1);
            player2 = new Player(Player.Type.Human,2);

            ProcessMove = new Move();
        }
        public void newGame(string choose_player)
        {
            this.isRuning = true;
            int[] org = {
                        99,	99,	99,	99,	99,	99,	99,	99,	99,	99,
                        99,	99,	99,	99,	99,	99,	99,	99,	99,	99,
                        99,	124,22,	23,	25,	126,23,	22,	124,99,
                        99,	21,	21,	21,	21,	21,	21,	21,	21,	99,
                        99,	00,	00,	00,	00,	00,	00,	00,	00,	99,
                        99,	00,	00,	00,	00,	00,	00,	00,	00,	99,
                        99,	00,	00,	00,	00,	00,	00,	00,	00,	99,
                        99,	00,	00,	00,	00,	00,	00,	00,	00,	99,
                        99,	11,	11,	11,	11,	11,	11,	11,	11,	99,
                        99,	114,12,	13,	15,	116,13,	12,	114,99,
                        99,	99,	99,	99,	99,	99,	99,	99,	99,	99,
                        99,	99,	99,	99,	99,	99,	99,	99,	99,	99 };

            board = new int[120];

            for (int i = 0; i < 120; i++)
                board[i] = org[i];

            // Quy dinh player
            isP1Run = true;
            player1 = new Player(Player.Type.Human,1);
            if (choose_player.ToLower() == "human")
                player2 = new Player(Player.Type.Human, 2);
            else
                player2 = new Player(Player.Type.Computer,2);

            ProcessMove = new Move();
            sound.NewGame();
            sound.isBgSound = true; //nhac nen
        }
예제 #3
0
        public void newGame()
        {
            this.isRuning = true;
            int[] org = {
                        99,	99,	99,	99,	99,	99,	99,	99,	99,	99,
                        99,	99,	99,	99,	99,	99,	99,	99,	99,	99,
                        99,	124,	22,	23,	25,	126,	23,	22,	124,	99,
                        99,	21,	21,	21,	21,	21,	21,	21,	21,	99,
                        99,	00,	00,	00,	00,	00,	00,	00,	00,	99,
                        99,	00,	00,	00,	00,	00,	00,	00,	00,	99,
                        99,	00,	00,	00,	00,	00,	00,	00,	00,	99,
                        99,	00,	00,	00,	00,	00,	00,	00,	00,	99,
                        99,	11,	11,	11,	11,	11,	11,	11,	11,	99,
                        99,	114,	12,	13,	15,	116,	13,	12,	114,	99,
                        99,	99,	99,	99,	99,	99,	99,	99,	99,	99,
                        99,	99,	99,	99,	99,	99,	99,	99,	99,	99 };

            board = new int[120];

            for (int i = 0; i < 120; i++)
                board[i] = org[i];

            // Quy dinh player
            isP1Run = true;

            player1 = new Player(p1,1);
            player2 = new Player(p2,2);

            ProcessMove = new Move();
            sound.NewGame();
            sound.isBgSound = true; //nhac nen
        }
예제 #4
0
 private void Form1_Load(object sender, EventArgs e)
 {
     comboBox1.SelectedIndex = comboBox2.SelectedIndex = 0;
     Functions.Precalc();
     _tWhite = TypeOfGamer.Human;
     _tBlack = TypeOfGamer.Human;
     _curPlayer = Player.White;
     _game = new Game(_mainBoard);
     _ai = new AI();
     _lastStep = null;
     pictureBox1.Invalidate();
 }
예제 #5
0
 private void ThreadEnd()
 {
     pictureBox1.Invalidate();
     if (stringState.InvokeRequired)
         stringState.BeginInvoke(new Action<string> (s => stringState.Text = s), "Ходит игрок");
     else stringState.Text = "Ходит игрок";
     _curPlayer = _game.Player;
     var state = _game.calcState();
     if (state == State.Check) MessageBox.Show("Шах!");
     if (state == State.Checkmate) MessageBox.Show("Мат!");
     if (state == State.Draw) MessageBox.Show("Пат");
     _isBlock = false;
 }
예제 #6
0
 private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
 {
     if (_isBlock) return;
     var nsy = e.X / 70;
     var nsx = 7 - (e.Y / 70);
     if (_isSelectFigure)
     {
         if (nsx == sx && nsy == sy)
         {
             _isSelectFigure = false;
             pictureBox1.Invalidate();
         }
         else
         {
             try
             {
                 var s = new Step(sx, sy, nsx, nsy);
                 _game.doMove(s);
                 AddStepForHistory(s);
                 _curPlayer = _game.Player;
             }
             catch (ErrorStepExveption ex)
             {
                 MessageBox.Show("Недопустимый ход!");
             }
             _isSelectFigure = false;
             pictureBox1.Invalidate();
         }
     }
     else
     {
         sx = nsx;
         sy = nsy;
         if (_mainBoard[(sx << 3) + sy] == null || _mainBoard[(sx << 3) + sy].Player != _curPlayer) return;
         _isSelectFigure = true;
         pictureBox1.Invalidate();
     }
 }