parent
							
								
									5710ad2b59
								
							
						
					
					
						commit
						45d9dd949d
					
				@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					#include "ChessGame.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ChessGame::ChessGame(Player* player, AI* ai, Chess* chess)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						this->player = player;
 | 
				
			||||||
 | 
						this->ai = ai;
 | 
				
			||||||
 | 
						this->chess = chess;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						player->init(chess);
 | 
				
			||||||
 | 
						ai->init(chess);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//对局开始
 | 
				
			||||||
 | 
					void ChessGame::play()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						chess->init();
 | 
				
			||||||
 | 
						while (1)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							//玩家执黑先彳亍
 | 
				
			||||||
 | 
							player->go();
 | 
				
			||||||
 | 
							if (chess->checkOver())
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							//人机后落子
 | 
				
			||||||
 | 
							ai->go();
 | 
				
			||||||
 | 
							if (chess->checkOver())
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
					Loading…
					
					
				
		Reference in new issue