Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/AI_HS15/src/modules/mini4dgame/Mini4DgameAI.cc @ 10832

Last change on this file since 10832 was 10230, checked in by landauf, 10 years ago

replaced tabs with spaces. no changes in code.

  • Property svn:eol-style set to native
File size: 3.2 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file Mini4DgameAI.cc
31    @brief Implementation of the Mini4DgameAI class.
32*/
33
34#include "Mini4DgameAI.h"
35
36#include "core/CoreIncludes.h"
37#include "core/config/ConfigValueIncludes.h"
38#include "core/command/Executor.h"
39#include "tools/Timer.h"
40
41#include <list>
42
43#include "worldentities/ControllableEntity.h"
44
45#include "Mini4DgameCenterpoint.h"
46
47namespace orxonox
48{
49    RegisterUnloadableClass(Mini4DgameAI);
50
51    //const static float MAX_REACTION_TIME = 0.4f;
52
53    /**
54    @brief
55        Constructor. Registers and initializes the object.
56    */
57    Mini4DgameAI::Mini4DgameAI(Context* context) : Controller(context)
58    {
59        RegisterObject(Mini4DgameAI);
60
61        this->setConfigValues();
62        this->center_ = 0;
63    }
64
65    /**
66    @brief
67        Destructor. Cleans up the list fo reaction timers.
68    */
69    Mini4DgameAI::~Mini4DgameAI()
70    {
71
72    }
73
74    Vector4 Mini4DgameAI::makeMove(float timeout)
75    {
76        this->copyBoard();
77        std::list<Vector4> possibleMoves = this->getPossibleMoves();
78
79        //TODO: alphabeta ueber possibleMoves
80
81        //when timeout
82        Vector4 move = possibleMoves.front();
83        return move;
84    }
85
86    void Mini4DgameAI::copyBoard()
87    {
88        for(int i=0;i<4;i++){
89            for(int j=0;j<4;j++){
90                for(int k=0;k<4;k++){
91                    for(int l=0;l<4;l++){
92                        this->board_[i][j][k][l]=this->center_->board[i][j][k][l];
93                    }
94                }
95            }
96        }
97    }
98
99    std::list<Vector4> Mini4DgameAI::getPossibleMoves()
100    {
101        std::list<Vector4> possibleMoves = new std::list<Vector4>;
102        for(int i=0;i<4;i++){
103            for(int j=0;j<4;j++){
104                for(int k=0;k<4;k++){
105                    for(int l=0;l<4;l++){
106                        if (this->board_[i][j][k][l]==mini4DgamePlayerColor::none)
107                            possibleMoves.push_back(Vector4(i,j,k,l));
108                    }
109                }
110            }
111        }
112        return possibleMoves;
113    }
114
115    /**
116    @brief
117        Is called each tick.
118        Implements the behavior of the PongAI (i.e. its intelligence).
119    @param dt
120        The time that has elapsed since the last tick.
121    */
122    void Mini4DgameAI::tick(float dt)
123    {
124
125    }
126}
Note: See TracBrowser for help on using the repository browser.