//Player ai_color;
        public AIPlayer(ObservableCollection<ChessPiece> pieces_collection, Dictionary<int, ChessPiece> pieces_dict)
        {
            move_generator = new MoveGenerator();

            //ai color to use;
            //this.ai_color = ai_color;

            //machine clock instantiation
            machine_timer = new TimerViewModel
            {
                Participant = Participant.PC,
                TimeSpan = TimeSpan.FromMinutes(30),
                TimerDispatcher = new DispatcherTimer(),
                Display = "00:30:00"
            };

            //human move messenger registration
            Messenger.Default.Register<HumanMoveMessage>(this, (action) => HumanPiecePositionChangeHandler(action));

            //captured stack instantiation
            machine_stack = new SPCapturedViewModel { CapturedPiecesCollection = new ObservableCollection<BitmapImage>() };

            //collection and dictionary referencing
            this.pieces_collection = pieces_collection;
            this.pieces_dict = pieces_dict;

            //algorithm thread instantiation
            algo_thread = new Thread(new ThreadStart(AlgorithmThread));
            algo_thread.IsBackground = true; //terminate thread when window is closed
            algo_thread.Start();
        }
        //private Image cap_piece_image;
        //servableCollection<ChessPiece> all_pieces;
        //ctionary<int, ChessPiece> board_layout;
        public HMPlayer(ObservableCollection<ChessPiece> pieces_collection, Dictionary<int, ChessPiece> pieces_dict)
        {
            human_timer = new TimerViewModel
            {
                Participant = Participant.Player,
                TimeSpan = TimeSpan.FromMinutes(30),
                TimerDispatcher = new DispatcherTimer(),
                Display = "00:30:00"
            };

            Messenger.Default.Register<HumanMoveMessage>(this, (action) => HumanPiecePositionChangeHandler(action));
            Messenger.Default.Register<MachineMoveMessage>(this, (action) => MachinePiecePositionChangeHandler(action));
            human_capture = new SPCapturedViewModel { CapturedPiecesCollection = new ObservableCollection<BitmapImage>() };
            this.pieces_collection = pieces_collection;
            this.pieces_dict = pieces_dict;
        }
Esempio n. 3
0
        public HMPlayer(ObservableCollection<ChessPiece> pieces_collection, Dictionary<int, ChessPiece> pieces_dict)
        {
            human_timer = new TimerViewModel
            {
                Participant = Participant.Player,
                TimeSpan = TimeSpan.FromMinutes(0),
                TimerDispatcher = new DispatcherTimer(),
                Display = "00:00:00"
            };

            Messenger.Default.Register<HumanMoveMessage>(this, (action) => HumanPiecePositionChangeHandler(action));
            Messenger.Default.Register<MachineMoveMessage>(this, (action) => MachinePiecePositionChangeHandler(action));
            human_capture = new SPCapturedViewModel { CapturedPiecesCollection = new ObservableCollection<BitmapImage>() };
            this.pieces_collection = pieces_collection;
            this.pieces_dict = pieces_dict;
            foreach (KeyValuePair<int, ChessPiece> item in this.pieces_dict)
            {
                if (item.Value.Player == Player.Black && !MoveGenerator.player_color)
                {
                 item.Value.Ownership = false;
                }
            }
        }