Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*.dll
*.exe

*.pro.user
*.pro.user*
build-KN2CSSL-*
tmp/*
build-*
Expand Down
5 changes: 2 additions & 3 deletions config/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
[Game]
Mode=Real;Simulation;
[Team]
Color =Yellow;Blue;
Color =Blue;Yellow;
Side =Left;Right;
[Field]
Size = Double;Single;
[Transmitter]
SerialPort = /dev/ttyUSB1
SerialPort = /dev/ttyUSB0

[VisionConfig]
UsingCameras = 7;CAMERA_NONE = 0, CAMERA_0 = 1, CAMERA_1 = 2, CAMERA_2 = 3, CAMERA_3 = 4, CAMERA_BOTH_L = 5,CAMERA_BOTH_R = 6,CAMERA_ALL = 7
Expand Down Expand Up @@ -44,4 +44,3 @@ RefIP = 224.5.23.10
RefPort = 10010
RefPortNew = 10030
RefUseNew = 1

12 changes: 12 additions & 0 deletions src/ai/Skills.h.autosave
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef SKILLS_H
#define SKILLS_H

#include "skill.h"
#include "skill/skillkick.h"
#include "skill/skilltest.h"
#include "skill/skillonetouch.h"
#include "skill/skillpassreceive.h"
//seyed ali hejazi
#include "skill/shootball.h"

#endif // SKILLS_H
Empty file modified src/ai/agent.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/agent.h
100644 → 100755
Empty file.
6 changes: 6 additions & 0 deletions src/ai/ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include "play/playtest2.h"
#include "play/playlearning.h"
#include "play/playformations.h"
//ali hejazi
#include "play/playhw2_1.h"
#include "play/mantomandefense.h"

AI::AI(WorldModel *worldmodel, QString field_size, OutputBuffer *outputbuffer, QObject *parent) :
QObject(parent),
Expand Down Expand Up @@ -52,6 +55,9 @@ AI::AI(WorldModel *worldmodel, QString field_size, OutputBuffer *outputbuffer, Q
plays.append(new PlayTest2(wm));
plays.append(new PlayLearning(wm));
plays.append(new PlayFormations(wm));
//ali hejazi
plays.append(new PlayHW2_1(wm));
plays.append(new mantomanDefense(wm));
}

void AI::Start()
Expand Down
59 changes: 59 additions & 0 deletions src/ai/play/mantomandefense.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include "mantomandefense.h"

mantomanDefense::mantomanDefense(WorldModel *worldmodel, QObject *parent) :
Play("PlayTest", worldmodel, parent)
{

}

int mantomanDefense::enterCondition()
{
return 0;
}

void mantomanDefense::initRole()
{
}

void mantomanDefense::execute()
{

QList <int> diffender = wm->kn->ActiveAgents();
QList <int> enemy = wm->kn->ActiveOppAgents();
QList <QList<double>> distances;
for(int i = diffender.length() ; i > 0 ; i--){
AlgorithmMin(diffender,enemy);
}
}

void mantomanDefense::AlgorithmMin(QList<int>& enm,QList<int>& ally){
QList <QList<double>> distances;
for(int i = 0 ; i < ally.length() ; i++){
QList<double> dists;
for(int j = 0 ; j < enm.length() ; j++){
Segment2D seg(wm->ourRobot[ally[i]].pos.loc,wm->oppRobot[enm[j]].pos.loc);
std::cout << "i am here" << std::endl;
dists.append(seg.length());
}
distances.append(dists);
}

double min = 99999999;
int minIndex1 = 0;
int minIndex2 = 0;
for(int i = 0 ; i < ally.length() ; i++){
for(int j = 0 ; j < enm.length() ; j++){
if(distances[i][j] < min){
min = distances[i][j];
minIndex1 = i;
minIndex2 = j;
}
}
}
tacticmantoman = new TacticTestStandingForwardEnemy(wm);
tacticmantoman->setDistance(4);
tacticmantoman->setOppRobotIndex(enm[minIndex2]);
tactics[ally[minIndex1]] = tacticmantoman;
ally.removeAt(minIndex1);
enm.removeAt(minIndex2);
}
19 changes: 19 additions & 0 deletions src/ai/play/mantomandefense.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef MANTOMANDEFENSE_H
#define MANTOMANDEFENSE_H
#include "play.h"
#include "man2man.h"

class mantomanDefense : public Play
{
Q_OBJECT
public:
explicit mantomanDefense(WorldModel *worldmodel, QObject *parent = 0);
virtual void execute();
virtual void initRole();
virtual int enterCondition();
private:
TacticTestStandingForwardEnemy* tacticmantoman;
void AlgorithmMin(QList<int>& enm, QList<int>& ally);
};

#endif // MANTOMANDEFENSE_H
6 changes: 3 additions & 3 deletions src/ai/play/playhalt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ PlayHalt::PlayHalt(WorldModel *worldmodel, QObject *parent) :

int PlayHalt::enterCondition()
{
if(wm->cmgs.canMove() == false || wm->cmgs.timeout())
return 1000000;
else
// if(wm->cmgs.canMove() == false || wm->cmgs.timeout())
// return 1000000;
// else
return 0;
}

Expand Down
23 changes: 23 additions & 0 deletions src/ai/play/playhw2_1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "playhw2_1.h"

PlayHW2_1::PlayHW2_1(WorldModel *worldmodel, QObject *parent) :
Play("PlayTest", worldmodel, parent)
{
tTest = new TacticTestStandingForwardEnemy(wm);
}

int PlayHW2_1::enterCondition()
{
return 0;
}

void PlayHW2_1::initRole()
{
}

void PlayHW2_1::execute()
{
tTest->setDistance(5);
tactics[wm->kn->ActiveAgents()[0]] = tTest;

}
20 changes: 20 additions & 0 deletions src/ai/play/playhw2_1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef PLAYHW2_1_H
#define PLAYHW2_1_H
#include "play.h"
#include "man2man.h"
#include "tactic/tacticteststandingforwardenemy.h"

class PlayHW2_1 : public Play
{

Q_OBJECT
public:
explicit PlayHW2_1(WorldModel *worldmodel, QObject *parent = 0);
virtual void execute();
virtual void initRole();
virtual int enterCondition();
private:
TacticTestStandingForwardEnemy* tTest;
};

#endif // PLAYHW2_1_H
3 changes: 3 additions & 0 deletions src/ai/play/playstop_hejazi.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "playstop_hejazi.h"


15 changes: 15 additions & 0 deletions src/ai/play/playstop_hejazi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef PLAYSTOP_HEJAZI_H
#define PLAYSTOP_HEJAZI_H
#include "play.h"
#include <QObject>

class PlayStop_Hejazi : public Play
{
public:
explicit PlayStop_Hejazi(WorldModel *worldmodel, QObject *parent = 0);
virtual void execute();
virtual void initRole();
PlayStop_Hejazi();
};

#endif // PLAYSTOP_HEJAZI_H
19 changes: 8 additions & 11 deletions src/ai/play/playtest.cpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
#include "playtest.h"
PlayTest::PlayTest(WorldModel *worldmodel, QObject *parent) :
Play("PlayTest", worldmodel, parent)
{//////////////////////////////////
test = new TacticTest(wm);
test2 = new TacticTest2(wm);
///////////////////////////////////
{
tTest = new TacticTest(wm);
tTest2 = new TacticTest(wm);
}

int PlayTest::enterCondition()
{
return 0;
return 99990;
}

void PlayTest::initRole()
{
}

void PlayTest::execute()
{//---////////////////////////////////////////////////////

tactics[0] = test;
tactics[1] = test;
tactics[2] = test;

{
tactics[3]= tTest;
wm->debug_type=2;
wm->debug_pos.append(wm->ourRobot[5].pos.loc);
}
9 changes: 3 additions & 6 deletions src/ai/play/playtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ class PlayTest : public Play
virtual void execute();
virtual void initRole();
virtual int enterCondition();

////////////////////////////
int flag=0;
private:
int flag=0;
TacticTest *test;
TacticTest2 *test2;
///////////////////////////
TacticTest* tTest;
TacticTest* tTest2;
};
#endif // PLAYTEST_H
53 changes: 45 additions & 8 deletions src/ai/play/playtest2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
PlayTest2::PlayTest2(WorldModel *worldmodel, QObject *parent) :
Play("PlayTest2", worldmodel, parent)
{
// Goaler.
tGolie = new TacticGoalie(wm);
tTF = new TacticTestFriction(wm);
thalt = new TacticHalt(wm);
tTest = new TacticTest(wm);
tTest = new TacticTest2(wm);
}

int PlayTest2::enterCondition()
Expand All @@ -22,8 +18,49 @@ void PlayTest2::initRole()

void PlayTest2::execute()
{
// tactics[wm->ref_goalie_our] = tGolie;
tactics[3] = tTest;
qDebug()<<"Ball Speed is "<<wm->ball.vel.loc.length();
if(wm->gs == STATE_Stop){
tactics[wm->ref_goalie_our] = tTest;
//step1
if(wm->kn->ActiveAgents().size() == 3){
tactics[wm->kn->ActiveAgents()[0]] = tTest;
tactics[wm->kn->ActiveAgents()[1]] = tTest;
tactics[wm->kn->ActiveAgents()[2]] = tTest;
}
if(wm->kn->ActiveAgents().size() == 4){
tactics[wm->kn->ActiveAgents()[0]] = tTest;
tactics[wm->kn->ActiveAgents()[1]] = tTest;
tactics[wm->kn->ActiveAgents()[2]] = tTest;
tactics[wm->kn->ActiveAgents()[3]] = tTest;
}
if(wm->kn->ActiveAgents().size() == 5){
tactics[wm->kn->ActiveAgents()[0]] = tTest;
tactics[wm->kn->ActiveAgents()[1]] = tTest;
tactics[wm->kn->ActiveAgents()[2]] = tTest;
tactics[wm->kn->ActiveAgents()[3]] = tTest;
tactics[wm->kn->ActiveAgents()[4]] = tTest;
}
if(wm->kn->ActiveAgents().size() == 6){
tactics[wm->kn->ActiveAgents()[0]] = tTest;
tactics[wm->kn->ActiveAgents()[1]] = tTest;
tactics[wm->kn->ActiveAgents()[2]] = tTest;
tactics[wm->kn->ActiveAgents()[3]] = tTest;
tactics[wm->kn->ActiveAgents()[4]] = tTest;
tactics[wm->kn->ActiveAgents()[5]] = tTest;
}
}
if(wm->gs == STATE_Halt){
for(int i = 0 ; i < wm->kn->ActiveAgents().size() ; i++){
tactics[i] = new TacticHalt(wm);
}
}
if(wm->gs == STATE_Free_kick_Opp){
tactics[wm->ref_goalie_our] = tTest;
}
if(wm->gs == STATE_Free_kick_Our){
tactics[0] = (Tactic*) (new TacticTest(wm));
}
}

//Vector2D PlayTest2::generatePos(int radius,double alpha){
// return Vector2D(wm->ball.pos.loc.x + radius*std::sin()
//}
8 changes: 3 additions & 5 deletions src/ai/play/playtest2.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "play.h"
#include "QDebug"
#include "tactic/tactichalt.h"

class PlayTest2 : public Play
{
Expand All @@ -12,14 +13,11 @@ class PlayTest2 : public Play
virtual void execute();
//virtual Tactic* getTactic(int id);
virtual int enterCondition();
Vector2D generatePos (int radius,double alpha);

private:
TacticGoalie* tGolie;
TacticTestFriction* tTF;
TacticHalt* thalt;
TacticTest* tTest;

virtual void initRole();
TacticTest2* tTest;
};

#endif // PLAYTEST2_H
2 changes: 2 additions & 0 deletions src/ai/skill/shootball.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "shootball.h"

22 changes: 22 additions & 0 deletions src/ai/skill/shootball.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef SHOOTBALL_H
#define SHOOTBALL_H
#include <QObject>
#include "skill.h"

//class shootBall : public Skill
//{
// Q_OBJECT
//public:
// shootBall();
// explicit shootBall(WorldModel* wm, QObject *parent = 0);
// bool execute(RobotCommand& rc);
//private:
// bool targetMove;
// Vector2D* _target;
// /*!
// is ball shooted or not.
// */
// bool ballShooted;
//};

#endif // SHOOTBALL_H
Loading