diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | c90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch) | |
tree | 6d8391395bce9eaea4ad78958617edb20c6a7573 /kspaceduel/ai.h | |
download | tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kspaceduel/ai.h')
-rw-r--r-- | kspaceduel/ai.h | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/kspaceduel/ai.h b/kspaceduel/ai.h new file mode 100644 index 00000000..0369ea02 --- /dev/null +++ b/kspaceduel/ai.h @@ -0,0 +1,102 @@ +#ifndef __KSD_AI_H +#define __KSD_AI_H + +#include <krandomsequence.h> + +#include <qptrlist.h> +#include <qmemarray.h> + +#include "sprites.h" +#include "dialogs.h" +#include "options.h" + +enum Rotation {RLEFT,RNONE,RRIGHT}; + +struct MineHit +{ + int mineNumber,hitTime; + double distance; +}; + +enum HitObject {HSHIP,HMINE,HSHOT,HNOTHING}; + +struct Hit +{ + HitObject object; + int playerNumber,objectNumber,hitTime; + double distance; //distance^2 +}; + +struct Shot +{ + Hit hit; + Rotation rotation; + int rotationFrames; + double score; +}; + + +class Ai +{ +public: + Ai(int pn,ShipSprite* s[2],QPtrList<BulletSprite> *b[2], + QPtrList<MineSprite> *m[2],SConfig *c); + void newRound(); + void think(); + bool rotateLeft(){return rotation==RLEFT;} + bool rotateRight(){return rotation==RRIGHT;} + bool accelerate(){return acc;} + bool shootBullet(){return bullet;} + bool layMine(){return mine;} +private: + AiSprite nextPosition(AiSprite sp,double mult); + void nextPositions(AiSprite sp,QMemArray<AiSprite> *a,int frames); + Hit firstObject(AiSprite shot,int shotframes,int frames); + void shotScores(); + void calculateNextPositions(); + void setSpriteFieldSize(); + void testForHits(); + void tryShots(); + void chooseAction(); + + SConfig *cfg; + + KRandomSequence random; + + //actions + Rotation rotation; + bool acc; + bool bullet,mine; + //what to do when + int rotateFramesNumber,accelerateFramesNumber; + bool shoot; + double score; + //sprites + int playerNumber,opponentNumber; + ShipSprite *ship[2]; + QPtrList<BulletSprite> *bullets[2]; + QPtrList<MineSprite> *mines[2]; + QMemArray<AiSprite> *shipsNextPositions[2]; + QMemArray<AiSprite> *aiMines[2]; + int mineNumber[2]; + //possible Hits + QPtrList<Shot> myShots; + QPtrList<Hit> objectsHitByShip; + QPtrList<Hit> minesHitByShot; + int borderTime; + int sunTime; + //SpriteField width and height + double sfwidth,sfheight,sfwidth_2,sfheight_2; + //Difficulty + static int calcFrameIncrement[Options::EnumAiDifficulty::COUNT]; + static int calcPositionNumber[Options::EnumAiDifficulty::COUNT]; + static int calcShotDirections[Options::EnumAiDifficulty::COUNT]; + static int calcCollisions[Options::EnumAiDifficulty::COUNT]; + static int calcNextShot[Options::EnumAiDifficulty::COUNT]; + static double calcShotRandom[Options::EnumAiDifficulty::COUNT]; + + int calculateCollisions; + int waitShot; +}; + +#endif |