Changeset 10131 for code/branches/minigame4DHS14/src/modules/mini4Dgame
- Timestamp:
- Nov 19, 2014, 4:08:42 PM (10 years ago)
- Location:
- code/branches/minigame4DHS14/src/modules/mini4Dgame
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/minigame4DHS14/src/modules/mini4Dgame/CMakeLists.txt
r10121 r10131 1 1 SET_SOURCE_FILES(Mini4Dgame_SRC_FILES 2 2 Mini4Dgame.cc 3 Mini4DgameAI.cc 3 #Mini4DgameAI.cc 4 Mini4DgameBoard.cc 4 5 Mini4DgameCenterpoint.cc 5 6 ) -
code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.cc
r10121 r10131 45 45 #include "core/config/ConfigValueIncludes.h" 46 46 #include "infos/PlayerInfo.h" 47 #include "core/command/ConsoleCommand.h" 47 48 48 49 #include "gamestates/GSLevel.h" … … 53 54 namespace orxonox 54 55 { 56 57 SetConsoleCommand("Mini4Dgame", "setStone", &Mini4Dgame::setStone).addShortcut(); 55 58 56 59 RegisterUnloadableClass(Mini4Dgame); … … 65 68 66 69 this->center_ = 0; 67 //TODO: player Null setzen 70 this->board_ = 0; 71 72 // Set the type of Bots for this particular Gametype. 73 //this->botclass_ = Class(Mini4DgameBot); 68 74 } 69 75 … … 87 93 } 88 94 89 /*90 bool Mini4Dgame::isValidMove(Vector4* move, const Mini4DgameBoard* board)91 {92 93 }94 */95 96 97 95 /** 98 96 @brief 99 Starts the Tetris minigame.97 Starts the mini4Dgame. 100 98 */ 101 99 void Mini4Dgame::start() … … 103 101 if (this->center_ != NULL) // There needs to be a Mini4DgameCenterpoint, i.e. the area the game takes place. 104 102 { 105 //TODO: create all objects if they don't exist so far and attach the parameters specified in the centerpoint to them 103 if (this->board_ == NULL) 104 { 105 this->board_ = new Mini4DgameBoard(this->center_->getContext()); 106 // Apply the template for the ball specified by the centerpoint. 107 this->board_->addTemplate(this->center_->getBoardtemplate()); 108 } 109 110 // Attach the board to the centerpoint and set the parameters as specified in the centerpoint, the ball is attached to. 111 this->center_->attach(this->board_); 112 this->board_->setPosition(0, 0, 0); 113 106 114 } 107 115 else // If no centerpoint was specified, an error is thrown and the level is exited. … … 169 177 } 170 178 179 static void Mini4Dgame::setStone(Vector4 move, const int playerColor, Mini4DgameBoard* board) 180 { 181 board->makeMove(move,playerColor); 182 } 171 183 184 void Mini4Dgame::win(Mini4DgameWinner winner) 185 { 186 187 } 172 188 } -
code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.h
r10121 r10131 37 37 #include "gametypes/Deathmatch.h" 38 38 #include "mini4Dgame/Mini4DgamePrereqs.h" 39 #include "Mini4DgameCenterpoint.h" 40 #include "Mini4DgameBoard.h" 39 41 40 42 namespace orxonox 41 43 { 44 42 45 namespace mini4DgamePlayerColor 43 46 { … … 51 54 } 52 55 53 struct Mini4DgamePlayer54 {55 Player player;56 mini4DgamePlayerColor::color color_;57 };58 59 struct Mini4DgameWinner60 {61 int winningRow[4];62 int winningColumn[4];63 int winningHeight[4];64 int winningNumber[4];65 mini4DgamePlayerColor::color color_;66 };67 56 /** 68 57 @brief … … 85 74 { this->center_ = center; } 86 75 76 static void setStone(Vector4 move, const int playerColor, Mini4DgameBoard* board); 77 87 78 void win(Mini4DgameWinner winner); 88 79 … … 94 85 void cleanup(void); //!< Cleans up the Gametype by destroying the ball and the bats. 95 86 96 Mini4DgamePlayer players[2];87 //Player players[2]; 97 88 98 WeakPtr<Mini4DgameCenterpoint> center_; //!< The playing field. 89 WeakPtr<Mini4DgameCenterpoint> center_; //!< The centerpoint to which the objects are attached 90 WeakPtr<Mini4DgameBoard> board_; 99 91 }; 100 92 } -
code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgameAI.h
r10121 r10131 71 71 The move that the AI decided to make. 72 72 */ 73 Vector4 Mini4DgameAI::makeMove(float timeout);73 Vector4 makeMove(float timeout); 74 74 75 75 … … 86 86 private: 87 87 88 std::list<Vector4> Mini4DgameAI::getPossibleMoves();89 void Mini4DgameAI::copyBoard();88 std::list<Vector4> getPossibleMoves(); 89 void copyBoard(); 90 90 mini4DgamePlayerColor::color board_[4][4][4][4]; 91 91 }; -
code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgameCenterpoint.cc
r10121 r10131 37 37 #include "core/XMLPort.h" 38 38 39 #include "../orxonox/graphics/BlinkingBillboard.h" 40 39 41 #include "Mini4Dgame.h" 40 42 41 43 namespace orxonox 42 44 { 45 43 46 RegisterClass(Mini4DgameCenterpoint); 44 45 47 /** 46 48 @brief … … 54 56 this->height_ = 200; 55 57 this->length_ = 200; 56 57 for(int i=0;i<4;i++){58 for(int j=0;j<4;j++){59 for(int k=0;k<4;k++){60 for(int l=0;l<4;l++){61 this->board[i][j][k][l]=mini4DgamePlayerColor::none;62 }63 }64 }65 }66 58 67 59 this->checkGametype(); … … 77 69 78 70 XMLPortParam(Mini4DgameCenterpoint, "dimension", setFieldDimension, getFieldDimension, xmlelement, mode); 71 XMLPortParam(Mini4DgameCenterpoint, "boardtemplate", setBoardtemplate, getBoardtemplate, xmlelement, mode); 79 72 } 80 73 … … 103 96 } 104 97 } 105 106 /**107 @brief checks if the move is valid108 @param the position where to put the stone plus the player who makes the move109 */110 bool Mini4DgameCenterpoint::isValidMove(const Vector4 move)111 {112 return (this->board[(int)move.x][(int)move.y][(int)move.z][(int)move.w] == mini4DgamePlayerColor::none);113 }114 115 /**116 @brief makes a move on the logic playboard117 @param the position where to put the stone plus the player who makes the move118 */119 void Mini4DgameCenterpoint::makeMove(const Vector4 move, const mini4DgamePlayerColor::color playerColor)120 {121 if(this->isValidMove(move))122 {123 this->board[(int)move.x][(int)move.y][(int)move.z][(int)move.w] = playerColor;124 Mini4DgameWinner winner = this->getWinner();125 if(winner.color_ != mini4DgamePlayerColor::none)126 {127 Mini4Dgame->win(winner);128 }129 }130 }131 132 Mini4DgameWinner Mini4DgameCenterpoint::getWinner()133 {134 Mini4DgameWinner winner;135 winner.color_ = mini4DgamePlayerColor::none;136 137 //check diagonals rows-columns-height-numbers138 for(int i=1; i<4; i++)139 {140 if(this->board[i][i][i][i]==mini4DgamePlayerColor::none || this->board[0][0][0][0] != this->board[i][i][i][i])141 break;142 if(i==3)143 {144 winner.color_ = this->board[0][0][0][0];145 for(int x=0; x<4; x++){146 winner.winningRow[x] = x;147 winner.winningColumn[x] = x;148 winner.winningHeight[x] = x;149 winner.winningNumber[x] = x;150 }151 return winner;152 }153 }154 for(int i=1; i<4; i++)155 {156 if(this->board[3-i][i][i][i]==mini4DgamePlayerColor::none || this->board[3][0][0][0] != this->board[3-i][i][i][i])157 break;158 if(i==3)159 {160 winner.color_ = this->board[3][0][0][0];161 for(int x=0; x<4; x++){162 winner.winningRow[x] = 3-x;163 winner.winningColumn[x] = x;164 winner.winningHeight[x] = x;165 winner.winningNumber[x] = x;166 }167 return winner;168 }169 }170 for(int i=1; i<4; i++)171 {172 if(this->board[i][3-i][i][i]==mini4DgamePlayerColor::none || this->board[0][3][0][0] != this->board[i][3-i][i][i])173 break;174 if(i==3)175 {176 winner.color_ = this->board[0][3][0][0];177 for(int x=0; x<4; x++){178 winner.winningRow[x] = x;179 winner.winningColumn[x] = 3-x;180 winner.winningHeight[x] = x;181 winner.winningNumber[x] = x;182 }183 return winner;184 }185 }186 for(int i=1; i<4; i++)187 {188 if(this->board[i][i][3-i][i]==mini4DgamePlayerColor::none || this->board[0][0][3][0] != this->board[i][i][3-i][i])189 break;190 if(i==3)191 {192 winner.color_ = this->board[0][0][3][0];193 for(int x=0; x<4; x++){194 winner.winningRow[x] = x;195 winner.winningColumn[x] = x;196 winner.winningHeight[x] = 3-x;197 winner.winningNumber[x] = x;198 }199 return winner;200 }201 }202 for(int i=1; i<4; i++)203 {204 if(this->board[i][i][i][3-i]==mini4DgamePlayerColor::none || this->board[0][0][0][3] != this->board[i][i][i][3-i])205 break;206 if(i==3)207 {208 winner.color_ = this->board[0][0][0][3];209 for(int x=0; x<4; x++){210 winner.winningRow[x] = x;211 winner.winningColumn[x] = x;212 winner.winningHeight[x] = x;213 winner.winningNumber[x] = 3-x;214 }215 return winner;216 }217 }218 for(int i=1; i<4; i++)219 {220 if(this->board[3-i][3-i][i][i]==mini4DgamePlayerColor::none || this->board[3][3][0][0] != this->board[3-i][3-i][i][i])221 break;222 if(i==3)223 {224 winner.color_ = this->board[3][3][0][0];225 for(int x=0; x<4; x++){226 winner.winningRow[x] = 3-x;227 winner.winningColumn[x] = 3-x;228 winner.winningHeight[x] = x;229 winner.winningNumber[x] = x;230 }231 return winner;232 }233 }234 for(int i=1; i<4; i++)235 {236 if(this->board[3-i][i][3-i][i]==mini4DgamePlayerColor::none || this->board[3][0][3][0] != this->board[3-i][i][3-i][i])237 break;238 if(i==3)239 {240 winner.color_ = this->board[3][0][3][0];241 for(int x=0; x<4; x++){242 winner.winningRow[x] = 3-x;243 winner.winningColumn[x] = x;244 winner.winningHeight[x] = 3-x;245 winner.winningNumber[x] = x;246 }247 return winner;248 }249 }250 for(int i=1; i<4; i++)251 {252 if(this->board[3-i][i][i][3-i]==mini4DgamePlayerColor::none || this->board[3][0][0][3] != this->board[3-i][i][i][3-i])253 break;254 if(i==3)255 {256 winner.color_ = this->board[3][0][0][3];257 for(int x=0; x<4; x++){258 winner.winningRow[x] = 3-x;259 winner.winningColumn[x] = x;260 winner.winningHeight[x] = x;261 winner.winningNumber[x] = 3-x;262 }263 return winner;264 }265 }266 267 //check diagonals rows-columns-height268 for(int l=0; l<4; l++)269 {270 for(int i=1; i<4; i++)271 {272 if(this->board[i][i][i][l]==mini4DgamePlayerColor::none || this->board[0][0][0][l] != this->board[i][i][i][l])273 break;274 if(i==3)275 {276 winner.color_ = this->board[0][0][0][l];277 for(int x=0; x<4; x++){278 winner.winningRow[x] = x;279 winner.winningColumn[x] = x;280 winner.winningHeight[x] = x;281 winner.winningNumber[x] = l;282 }283 return winner;284 }285 }286 for(int i=1; i<4; i++)287 {288 if(this->board[3-i][i][i][l]==mini4DgamePlayerColor::none || this->board[3][0][0][l] != this->board[3-i][i][i][l])289 break;290 if(i==3)291 {292 winner.color_ = this->board[3][0][0][l];293 for(int x=0; x<4; x++){294 winner.winningRow[x] = 3-x;295 winner.winningColumn[x] = x;296 winner.winningHeight[x] = x;297 winner.winningNumber[x] = l;298 }299 return winner;300 }301 }302 for(int i=1; i<4; i++)303 {304 if(this->board[i][3-i][i][l]==mini4DgamePlayerColor::none || this->board[0][3][0][l] != this->board[i][3-i][i][l])305 break;306 if(i==3)307 {308 winner.color_ = this->board[0][3][0][l];309 for(int x=0; x<4; x++){310 winner.winningRow[x] = x;311 winner.winningColumn[x] = 3-x;312 winner.winningHeight[x] = x;313 winner.winningNumber[x] = l;314 }315 return winner;316 }317 }318 for(int i=1; i<4; i++)319 {320 if(this->board[i][i][3-i][l]==mini4DgamePlayerColor::none || this->board[0][0][3][l] != this->board[i][i][3-i][l])321 break;322 if(i==3)323 {324 winner.color_ = this->board[0][0][3][l];325 for(int x=0; x<4; x++){326 winner.winningRow[x] = x;327 winner.winningColumn[x] = x;328 winner.winningHeight[x] = 3-x;329 winner.winningNumber[x] = l;330 }331 return winner;332 }333 }334 }335 336 //check diagonals rows-columns-numbers337 for(int l=0; l<4; l++)338 {339 for(int i=1; i<4; i++)340 {341 if(this->board[i][i][l][i]==mini4DgamePlayerColor::none || this->board[0][0][l][0] != this->board[i][i][l][i])342 break;343 if(i==3)344 {345 winner.color_ = this->board[0][0][l][0];346 for(int x=0; x<4; x++){347 winner.winningRow[x] = x;348 winner.winningColumn[x] = x;349 winner.winningHeight[x] = l;350 winner.winningNumber[x] = x;351 }352 return winner;353 }354 }355 for(int i=1; i<4; i++)356 {357 if(this->board[3-i][i][l][i]==mini4DgamePlayerColor::none || this->board[3][0][l][0] != this->board[3-i][i][l][i])358 break;359 if(i==3)360 {361 winner.color_ = this->board[3][0][l][0];362 for(int x=0; x<4; x++){363 winner.winningRow[x] = 3-x;364 winner.winningColumn[x] = x;365 winner.winningHeight[x] = l;366 winner.winningNumber[x] = x;367 }368 return winner;369 }370 }371 for(int i=1; i<4; i++)372 {373 if(this->board[i][3-i][l][i]==mini4DgamePlayerColor::none || this->board[0][3][l][0] != this->board[i][3-i][l][i])374 break;375 if(i==3)376 {377 winner.color_ = this->board[0][3][l][0];378 for(int x=0; x<4; x++){379 winner.winningRow[x] = x;380 winner.winningColumn[x] = 3-x;381 winner.winningHeight[x] = l;382 winner.winningNumber[x] = x;383 }384 return winner;385 }386 }387 for(int i=1; i<4; i++)388 {389 if(this->board[i][i][l][3-i]==mini4DgamePlayerColor::none || this->board[0][0][l][3] != this->board[i][i][l][3-i])390 break;391 if(i==3)392 {393 winner.color_ = this->board[0][0][l][3];394 for(int x=0; x<4; x++){395 winner.winningRow[x] = x;396 winner.winningColumn[x] = x;397 winner.winningHeight[x] = l;398 winner.winningNumber[x] = 3-x;399 }400 return winner;401 }402 }403 }404 405 //check diagonals rows-height-numbers406 for(int l=0; l<4; l++)407 {408 for(int i=1; i<4; i++)409 {410 if(this->board[i][l][i][i]==mini4DgamePlayerColor::none || this->board[0][l][0][0] != this->board[i][l][i][i])411 break;412 if(i==3)413 {414 winner.color_ = this->board[0][l][0][0];415 for(int x=0; x<4; x++){416 winner.winningRow[x] = x;417 winner.winningColumn[x] = l;418 winner.winningHeight[x] = x;419 winner.winningNumber[x] = x;420 }421 return winner;422 }423 }424 for(int i=1; i<4; i++)425 {426 if(this->board[3-i][l][i][i]==mini4DgamePlayerColor::none || this->board[3][l][0][0] != this->board[3-i][l][i][i])427 break;428 if(i==3)429 {430 winner.color_ = this->board[3][l][0][0];431 for(int x=0; x<4; x++){432 winner.winningRow[x] = 3-x;433 winner.winningColumn[x] = l;434 winner.winningHeight[x] = x;435 winner.winningNumber[x] = x;436 }437 return winner;438 }439 }440 for(int i=1; i<4; i++)441 {442 if(this->board[i][l][3-i][i]==mini4DgamePlayerColor::none || this->board[0][l][3][0] != this->board[i][l][3-i][i])443 break;444 if(i==3)445 {446 winner.color_ = this->board[0][l][3][0];447 for(int x=0; x<4; x++){448 winner.winningRow[x] = x;449 winner.winningColumn[x] = l;450 winner.winningHeight[x] = 3-x;451 winner.winningNumber[x] = x;452 }453 return winner;454 }455 }456 for(int i=1; i<4; i++)457 {458 if(this->board[i][l][i][3-i]==mini4DgamePlayerColor::none || this->board[0][l][0][3] != this->board[i][l][i][3-i])459 break;460 if(i==3)461 {462 winner.color_ = this->board[0][l][0][3];463 for(int x=0; x<4; x++){464 winner.winningRow[x] = x;465 winner.winningColumn[x] = l;466 winner.winningHeight[x] = x;467 winner.winningNumber[x] = 3-x;468 }469 return winner;470 }471 }472 }473 474 //check diagonals columns-height-numbers475 for(int l=0; l<4; l++)476 {477 for(int i=1; i<4; i++)478 {479 if(this->board[l][i][i][i]==mini4DgamePlayerColor::none || this->board[l][0][0][0] != this->board[l][i][i][i])480 break;481 if(i==3)482 {483 winner.color_ = this->board[l][0][0][0];484 for(int x=0; x<4; x++){485 winner.winningRow[x] = l;486 winner.winningColumn[x] = x;487 winner.winningHeight[x] = x;488 winner.winningNumber[x] = x;489 }490 return winner;491 }492 }493 for(int i=1; i<4; i++)494 {495 if(this->board[l][3-i][i][i]==mini4DgamePlayerColor::none || this->board[l][3][0][0] != this->board[l][3-i][i][i])496 break;497 if(i==3)498 {499 winner.color_ = this->board[l][3][0][0];500 for(int x=0; x<4; x++){501 winner.winningRow[x] = l;502 winner.winningColumn[x] = 3-x;503 winner.winningHeight[x] = x;504 winner.winningNumber[x] = x;505 }506 return winner;507 }508 }509 for(int i=1; i<4; i++)510 {511 if(this->board[l][i][3-i][i]==mini4DgamePlayerColor::none || this->board[l][0][3][0] != this->board[l][i][3-i][i])512 break;513 if(i==3)514 {515 winner.color_ = this->board[l][0][3][0];516 for(int x=0; x<4; x++){517 winner.winningRow[x] = l;518 winner.winningColumn[x] = x;519 winner.winningHeight[x] = 3-x;520 winner.winningNumber[x] = x;521 }522 return winner;523 }524 }525 for(int i=1; i<4; i++)526 {527 if(this->board[l][i][i][3-i]==mini4DgamePlayerColor::none || this->board[l][0][0][3] != this->board[l][i][i][3-i])528 break;529 if(i==3)530 {531 winner.color_ = this->board[l][0][0][3];532 for(int x=0; x<4; x++){533 winner.winningRow[x] = l;534 winner.winningColumn[x] = x;535 winner.winningHeight[x] = x;536 winner.winningNumber[x] = 3-x;537 }538 return winner;539 }540 }541 }542 543 //check 2d diagonals544 for(int k=0;k<4;k++){545 for(int l=0;l<4;l++){546 //rows-columns547 for(int i=1; i<4; i++)548 {549 if(this->board[i][i][k][l]==mini4DgamePlayerColor::none || this->board[0][0][k][l] != this->board[i][i][k][l])550 break;551 if(i==3)552 {553 winner.color_ = this->board[0][0][k][l];554 for(int x=0; x<4; x++){555 winner.winningRow[x] = x;556 winner.winningColumn[x] = x;557 winner.winningHeight[x] = k;558 winner.winningNumber[x] = l;559 }560 return winner;561 }562 }563 for(int i=1; i<4; i++)564 {565 if(this->board[3-i][i][k][l]==mini4DgamePlayerColor::none || this->board[3][0][k][l] != this->board[3-i][i][k][l])566 break;567 if(i==3)568 {569 winner.color_ = this->board[3][0][k][l];570 for(int x=0; x<4; x++){571 winner.winningRow[x] = 3-x;572 winner.winningColumn[x] = x;573 winner.winningHeight[x] = k;574 winner.winningNumber[x] = l;575 }576 return winner;577 }578 }579 //rows-height580 for(int i=1; i<4; i++)581 {582 if(this->board[i][k][i][l]==mini4DgamePlayerColor::none || this->board[0][k][0][l] != this->board[i][k][i][l])583 break;584 if(i==3)585 {586 winner.color_ = this->board[0][k][0][l];587 for(int x=0; x<4; x++){588 winner.winningRow[x] = x;589 winner.winningColumn[x] = k;590 winner.winningHeight[x] = x;591 winner.winningNumber[x] = l;592 }593 return winner;594 }595 }596 for(int i=1; i<4; i++)597 {598 if(this->board[3-i][k][i][l]==mini4DgamePlayerColor::none || this->board[3][k][0][l] != this->board[3-i][k][i][l])599 break;600 if(i==3)601 {602 winner.color_ = this->board[3][k][0][l];603 for(int x=0; x<4; x++){604 winner.winningRow[x] = 3-x;605 winner.winningColumn[x] = k;606 winner.winningHeight[x] = x;607 winner.winningNumber[x] = l;608 }609 return winner;610 }611 }612 //rows-numbers613 for(int i=1; i<4; i++)614 {615 if(this->board[i][k][l][i]==mini4DgamePlayerColor::none || this->board[0][k][l][0] != this->board[i][k][l][i])616 break;617 if(i==3)618 {619 winner.color_ = this->board[0][k][l][0];620 for(int x=0; x<4; x++){621 winner.winningRow[x] = x;622 winner.winningColumn[x] = k;623 winner.winningHeight[x] = l;624 winner.winningNumber[x] = x;625 }626 return winner;627 }628 }629 for(int i=1; i<4; i++)630 {631 if(this->board[3-i][k][l][i]==mini4DgamePlayerColor::none || this->board[3][k][l][0] != this->board[3-i][k][l][i])632 break;633 if(i==3)634 {635 winner.color_ = this->board[3][k][l][0];636 for(int x=0; x<4; x++){637 winner.winningRow[x] = 3-x;638 winner.winningColumn[x] = k;639 winner.winningHeight[x] = l;640 winner.winningNumber[x] = x;641 }642 return winner;643 }644 }645 //column-height646 for(int i=1; i<4; i++)647 {648 if(this->board[k][i][i][l]==mini4DgamePlayerColor::none || this->board[k][0][0][l] != this->board[k][i][i][l])649 break;650 if(i==3)651 {652 winner.color_ = this->board[k][0][0][l];653 for(int x=0; x<4; x++){654 winner.winningRow[x] = k;655 winner.winningColumn[x] = x;656 winner.winningHeight[x] = x;657 winner.winningNumber[x] = l;658 }659 return winner;660 }661 }662 for(int i=1; i<4; i++)663 {664 if(this->board[k][3-i][i][l]==mini4DgamePlayerColor::none || this->board[k][3][0][l] != this->board[k][3-i][i][l])665 break;666 if(i==3)667 {668 winner.color_ = this->board[k][3][0][l];669 for(int x=0; x<4; x++){670 winner.winningRow[x] = k;671 winner.winningColumn[x] = 3-x;672 winner.winningHeight[x] = x;673 winner.winningNumber[x] = l;674 }675 return winner;676 }677 }678 //column-numbers679 for(int i=1; i<4; i++)680 {681 if(this->board[k][i][l][i]==mini4DgamePlayerColor::none || this->board[k][0][l][0] != this->board[k][i][l][i])682 break;683 if(i==3)684 {685 winner.color_ = this->board[k][0][l][0];686 for(int x=0; x<4; x++){687 winner.winningRow[x] = k;688 winner.winningColumn[x] = x;689 winner.winningHeight[x] = l;690 winner.winningNumber[x] = x;691 }692 return winner;693 }694 }695 for(int i=1; i<4; i++)696 {697 if(this->board[k][3-i][l][i]==mini4DgamePlayerColor::none || this->board[k][3][l][0] != this->board[k][3-i][l][i])698 break;699 if(i==3)700 {701 winner.color_ = this->board[k][3][l][0];702 for(int x=0; x<4; x++){703 winner.winningRow[x] = k;704 winner.winningColumn[x] = 3-x;705 winner.winningHeight[x] = l;706 winner.winningNumber[x] = x;707 }708 return winner;709 }710 }711 //height-numbers712 for(int i=1; i<4; i++)713 {714 if(this->board[k][l][i][i]==mini4DgamePlayerColor::none || this->board[k][l][0][0] != this->board[k][l][i][i])715 break;716 if(i==3)717 {718 winner.color_ = this->board[k][l][0][0];719 for(int x=0; x<4; x++){720 winner.winningRow[x] = k;721 winner.winningColumn[x] = l;722 winner.winningHeight[x] = x;723 winner.winningNumber[x] = x;724 }725 return winner;726 }727 }728 for(int i=1; i<4; i++)729 {730 if(this->board[k][l][3-i][i]==mini4DgamePlayerColor::none || this->board[k][l][3][0] != this->board[k][l][3-i][i])731 break;732 if(i==3)733 {734 winner.color_ = this->board[k][l][3][0];735 for(int x=0; x<4; x++){736 winner.winningRow[x] = k;737 winner.winningColumn[x] = l;738 winner.winningHeight[x] = 3-x;739 winner.winningNumber[x] = x;740 }741 return winner;742 }743 }744 }745 }746 747 //check rows748 for(int j=0;j<4;j++){749 for(int k=0;k<4;k++){750 for(int l=0;l<4;l++){751 if(this->board[0][j][k][l]!= mini4DgamePlayerColor::none752 && this->board[0][j][k][l]==this->board[1][j][k][l]753 && this->board[1][j][k][l]==this->board[2][j][k][l]754 && this->board[2][j][k][l]==this->board[3][j][k][l])755 {756 winner.color_ = this->board[0][j][k][l];757 for(int x=0; x<4; x++){758 winner.winningRow[x] = x;759 winner.winningColumn[x] = j;760 winner.winningHeight[x] = k;761 winner.winningNumber[x] = l;762 }763 return winner;764 }765 }766 }767 }768 769 //check columns770 for(int i=0;i<4;i++){771 for(int k=0;k<4;k++){772 for(int l=0;l<4;l++){773 if(this->board[i][0][k][l]!= mini4DgamePlayerColor::none774 && this->board[i][0][k][l]==this->board[i][1][k][l]775 && this->board[i][1][k][l]==this->board[i][2][k][l]776 && this->board[i][2][k][l]==this->board[i][3][k][l])777 {778 winner.color_ = this->board[i][0][k][l];779 for(int x=0; x<4; x++){780 winner.winningRow[x] = i;781 winner.winningColumn[x] = x;782 winner.winningHeight[x] = k;783 winner.winningNumber[x] = l;784 }785 return winner;786 }787 }788 }789 }790 791 //check height792 for(int i=0;i<4;i++){793 for(int j=0;j<4;j++){794 for(int l=0;l<4;l++){795 if(this->board[i][j][0][l]!= mini4DgamePlayerColor::none796 && this->board[i][j][0][l]==this->board[i][j][1][l]797 && this->board[i][j][1][l]==this->board[i][j][2][l]798 && this->board[i][j][2][l]==this->board[i][j][3][l])799 {800 winner.color_ = this->board[i][j][0][l];801 for(int x=0; x<4; x++){802 winner.winningRow[x] = i;803 winner.winningColumn[x] = j;804 winner.winningHeight[x] = x;805 winner.winningNumber[x] = l;806 }807 return winner;808 }809 }810 }811 }812 813 //check numbers814 for(int i=0;i<4;i++){815 for(int j=0;j<4;j++){816 for(int k=0;k<4;k++){817 if(this->board[i][j][k][0]!= mini4DgamePlayerColor::none818 && this->board[i][j][k][0]==this->board[i][j][k][1]819 && this->board[i][j][k][1]==this->board[i][j][k][2]820 && this->board[i][j][k][2]==this->board[i][j][k][3])821 {822 winner.color_ = this->board[i][j][k][0];823 for(int x=0; x<4; x++){824 winner.winningRow[x] = i;825 winner.winningColumn[x] = j;826 winner.winningHeight[x] = k;827 winner.winningNumber[x] = x;828 }829 return winner;830 }831 }832 }833 }834 return winner;835 }836 98 } -
code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgameCenterpoint.h
r10121 r10131 41 41 #include "worldentities/StaticEntity.h" 42 42 #include "mini4Dgame/Mini4DgamePrereqs.h" 43 #include "mini4Dgame/Mini4Dgame.h"43 //#include "mini4Dgame/Mini4Dgame.h" 44 44 45 45 namespace orxonox 46 46 { 47 48 47 /** 49 48 @brief 50 49 The Mini4DgameCenterpoint implements the playing field @ref orxonox::Mini4Dgame "Mini4Dgame" takes place in and allows for many parameters of the minigame to be set. 51 50 52 Various parameters can be set:53 - The <b>dimension</b> is a vector, that defines the width and height of the playing field. The default is <em>(200, 120)</em>.54 - The <b>balltemplate</b> is a template that is applied to the @ref orxonox::PongBall "PongBall", it can be used to attach different things to it, e.g. its @ref orxonox::Model "Model". See below for a usage example.55 - The <b>battemplate</b> is a template that is applied to the @ref orxonox::PongBall "PongBat", it can be used to attach different things to it, e.g. its @ref orxonox::Model "Model". See below for a usage example.56 - The <b>ballspeed</b> is the speed with which the @ref orxonox::PongBall "PongBall" moves. The default is <em>100</em>.57 - The <b>ballaccfactor</b> is the acceleration factor for the @ref orxonox::PongBall "PongBall". The default is <em>1.0</em>.58 - The <b>batspeed</b> is the speed with which the @ref orxonox::PongBat "PongBats" move. The default is <em>60</em>.59 - The <b>batlength</b> is the length of the @ref orxonox::PongBat "PongBats" as the percentage of the height of the playing field. The default is <em>0.25</em>.60 51 */ 61 52 class _Mini4DgameExport Mini4DgameCenterpoint : public StaticEntity … … 70 61 71 62 /** 72 @brief Set the template for the ball. (e.g. to attach the model of the ball, but also to attach an EventListener to it to detect, when it hits the boundaries, and e.g. display some ParticleEffets, when it does.) 73 @param balltemplate The name of the template to be set. 63 @brief Get the template of the board. 64 @return Returns the name of the template of the board. 65 */ 66 const std::string& getBoardtemplate() const 67 { return this->boardtemplate_; } 74 68 75 void setBalltemplate(const std::string& balltemplate)76 { this->balltemplate_ = balltemplate; }77 */78 69 79 70 /** 80 @brief Get the template of the ball. 81 @return Returns the name of the template of the ball. 71 @brief Set the template for the board. 72 @param boardtemplate The name of the template to be set. 73 */ 74 void setBoardtemplate(const std::string& boardtemplate) 75 { this->boardtemplate_ = boardtemplate; } 82 76 83 const std::string& getBalltemplate() const84 { return this->balltemplate_; }85 */86 87 /**88 @brief Set the template for the bats. (e.g. to attach the model of the bat, but also to attach CameraPositions to it, to be able to view the game from the bats perspective)89 @param battemplate The name of the template to be set.90 91 void setBattemplate(const std::string& battemplate)92 { this->battemplate_ = battemplate; }93 */94 77 95 78 /** … … 106 89 { return Vector3(this->width_, this->height_, this->length_); } 107 90 108 /**109 @brief checks if the move is valid110 @param the position where to put the stone plus the player who makes the move111 */112 bool isValidMove(const Vector4 move);113 114 /**115 @brief makes a move on the logic playboard116 @param the position where to put the stone plus the player who makes the move117 */118 void makeMove(const Vector4 move, const mini4DgamePlayerColor::color playerColor);119 120 /**121 @brief checks if somebody has won122 @return the winner with the winning fields or a winner with winner.color_ == mini4DgamePlayerColor::none if nobody has won so far.123 */124 Mini4DgameWinner Mini4DgameCenterpoint::getWinner();125 126 91 private: 127 92 void checkGametype(); //!< Checks whether the gametype is Mini4Dgame and if it is, sets its centerpoint. 128 93 129 //std::string balltemplate_; //!< The template for the ball. 130 //std::string battemplate_; //!< The template for the bats. 94 std::string boardtemplate_; //!< The template for the board. 131 95 132 96 float width_; //!< The height of the playing field. 133 97 float height_; //!< The width of the playing field. 134 98 float length_; //!< The length of the playing field. 135 mini4DgamePlayerColor::color board[4][4][4][4]; //!< The logical board where the game takes place. board[row][column][height][number]136 99 }; 137 100 } -
code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgamePrereqs.h
r10104 r10131 69 69 { 70 70 class Mini4Dgame; 71 class Mini4DgameBoard; 71 72 class Mini4DgameCenterpoint; 72 73 }
Note: See TracChangeset
for help on using the changeset viewer.