Commit 1efa83a35cab43ca30bab287532146a685ecfe13

Authored by Hakeem
1 parent a69582db

Minimax needs 1 or 2 debugging

CMakeLists.txt
... ... @@ -14,6 +14,8 @@ find_package(Qt5Quick 5.11)
14 14 find_package(Qt5Gui 5.11)
15 15 #find_package(Qt5Qml 5.11)
16 16  
  17 +find_package(Qt53DQuick 5.11) # core components
  18 +find_package(Qt53DExtras 5.11) # resource components such as meshes and materials
17 19  
18 20 set( HDRS
19 21 gamemodel.h
... ...
CMakeLists.txt.user
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3   -<!-- Written by QtCreator 4.7.0, 2018-10-02T18:59:24. -->
  3 +<!-- Written by QtCreator 4.7.1, 2018-10-10T19:12:45. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>EnvironmentId</variable>
... ...
gamemodel.cpp
... ... @@ -67,17 +67,20 @@ uint GameModel::playerTwoScore() const
67 67 return uint(m_game_engine.board().at(1).count());
68 68 }
69 69  
70   -//bool GameModel::currentWinner()
71   -//{
72   -// draw;
73   -// switch(1) {
74   -// case draw:
75   -// if(board_pos.value() < 56)
76   -// return othello::BitPos(board_pos.value() + 8);
77   -// break;
78   -
79   -// }
80   -//}
  70 +void GameModel::setCurrentWinner(uint &current_winner)
  71 +{
  72 + current_winner = 0;
  73 + if (playerOneScore() == playerTwoScore())
  74 + return;
  75 + if (playerOneScore() != playerTwoScore())
  76 + current_winner = currentPlayer();
  77 +}
  78 +
  79 +uint GameModel::getCurrentWinner() const
  80 +{
  81 + //if(current_winner == m_game_engine.m_player_one );
  82 + return current_winner;
  83 +}
81 84  
82 85 QHash<int, QByteArray> GameModel::roleNames() const
83 86 {
... ...
gamemodel.h
... ... @@ -34,6 +34,10 @@ public:
34 34 QHash<int, QByteArray> roleNames() const override;
35 35  
36 36  
  37 + uint getCurrentWinner() const;
  38 +
  39 + void setCurrentWinner(uint &value);
  40 +
37 41 public slots:
38 42 void update();
39 43  
... ... @@ -44,7 +48,7 @@ private:
44 48 uint currentPlayer() const;
45 49 uint playerOneScore() const;
46 50 uint playerTwoScore() const;
47   - bool currentWinner();
  51 + uint current_winner;
48 52  
49 53 signals:
50 54 void boardSizeChanged(size_t);
... ...
guiapplication.cpp
... ... @@ -55,19 +55,6 @@ GuiApplication::GuiApplication(int&amp; argc, char** argv)
55 55 }
56 56 }
57 57  
58   -//void GuiApplication::endOfTurn()
59   -//{
60   -// m_model.update();
61   -// if (m_game_engine.noLegalMoves(m_game_engine.currentPlayerId()) and
62   -// m_game_engine.noLegalMoves(othello::utility::opponent(m_game_engine.currentPlayerId())) )
63   -// emit gameEnded();
64   -// else if (m_game_engine.noLegalMoves(m_game_engine.currentPlayerId()) and not
65   -// m_game_engine.noLegalMoves(othello::utility::opponent(m_game_engine.currentPlayerId()))){
66   -// m_game_engine.switchCurrentPlayerId();
67   -// emit enqueueNextTurn();
68   -// }
69   -//}
70   -
71 58 void GuiApplication::endOfTurn()
72 59 {
73 60 m_model.update();
... ... @@ -83,15 +70,14 @@ void GuiApplication::startNextTurn()
83 70 }
84 71 }
85 72 else{
86   - if (m_game_engine.forfeitedLastTurn() == true)
87   - {
  73 + if (m_game_engine.forfeitedLastTurn() == true){
88 74 emit gameEnded();
89   - qDebug() << "no more moves" ;
90 75 return;
91 76 }
92 77 else
93 78 {
94 79 m_game_engine.forfeitTurn(true);
  80 + m_game_engine.switchCurrentPlayerId();
95 81 emit enqueueNextTurn();
96 82 }
97 83  
... ... @@ -148,8 +134,14 @@ void GuiApplication::endGameAndQuit() {
148 134  
149 135 void GuiApplication::endOfGameActions()
150 136 {
151   - if (othello::utility::occupiedPositions(m_game_engine.board()).all())
152   - emit displayFinalScores();
153 137 qDebug() << "Game Over!" ;
154 138 emit displayFinalScores();
  139 +
  140 + if (othello::utility::occupiedPositions(m_game_engine.board()).all())
  141 + emit displayFinalScores();
  142 + if (m_game_engine.forfeitedLastTurn() == true)
  143 + qDebug() << "no more moves";
  144 +
  145 +
  146 +
155 147 }
... ...
resources/cork.png 0 → 100644