-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4a53ca
commit 99cf1db
Showing
6 changed files
with
203 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
const IntentionPlayer = require('../IntentionPlayer') | ||
const TensorMath = require('../../lib/TensorMath') | ||
const Intention = require('../../Intention') | ||
const LineIntention = require('../../Intention/LineIntention') | ||
const PointIntention = require('../../Intention/PointIntention') | ||
const LookAtIntention = require('../../Intention/LookAtIntention') | ||
const Vector = require('../../lib/Vector') | ||
const RulePlays = require('./RulePlays') | ||
|
||
const BASE_SPEED = 50 | ||
|
||
module.exports = class Midfielder extends RulePlays { | ||
setup(){ | ||
super.setup() | ||
let ball = () => { | ||
let ball = {x: this.match.dataManager.ball.x, y: this.match.dataManager.ball.y} | ||
return ball | ||
} | ||
|
||
let followAttackerShadow = () => { | ||
let pos = this.match.gameManager.coach.attackerRobot.robots.self.position | ||
/* | ||
A projeção não é usada nos casos onde: | ||
- Não existe vetor projeção (ocorre no primeiro frame de execução) | ||
- Velocidade da bola inferior a 1.2 cm/s (praticamente parada) | ||
- Quando a bola ira bater longe do gol (acima de 30 cm em relação ao centro do gol) | ||
*/ | ||
return {x: -250, y: -pos.y/2} | ||
} | ||
|
||
this.addIntetion(new LineIntention('KeepGoalLine', { | ||
target: {x: -250, y: 0}, | ||
theta: Vector.direction("up"), | ||
lineSize: 1700, | ||
lineDist: 260, | ||
decay: TensorMath.new.finish, | ||
multiplier: BASE_SPEED | ||
})) | ||
|
||
this.addIntetion(new LineIntention('followAttackerShadow', { | ||
target: followAttackerShadow, | ||
theta: Vector.direction("left"), | ||
lineSize: 1700, | ||
lineDist: 250, | ||
decay: TensorMath.new.finish, | ||
multiplier: BASE_SPEED | ||
})) | ||
|
||
this.addIntetion(new LookAtIntention('LookAtBall', { | ||
target: ball, | ||
decay: TensorMath.new.constant(1).finish, | ||
multiplier: 100 | ||
})) | ||
} | ||
loop(){ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
const IntentionPlayer = require('../IntentionPlayer') | ||
const TensorMath = require('../../lib/TensorMath') | ||
const Intention = require('../../Intention') | ||
const LineIntention = require('../../Intention/LineIntention') | ||
const PointIntention = require('../../Intention/PointIntention') | ||
const LookAtIntention = require('../../Intention/LookAtIntention') | ||
const OrbitalIntention = require('../../Intention/OrbitalIntention') | ||
const Vector = require('../../lib/Vector') | ||
const RulePlays = require('./RulePlays') | ||
|
||
const BASE_SPEED = 65 | ||
|
||
module.exports = class MidfieldDefender extends RulePlays { | ||
setup () { | ||
super.setup() | ||
let ballAntecipation = () => { | ||
let ball = {x: this.match.dataManager.ball.x, y: this.match.dataManager.ball.y} | ||
let ballToCenterGoal = Vector.sub({x: 700, y: 0}, ball) | ||
let ballToCenterGoalNorm = Vector.norm(ballToCenterGoal) | ||
let antecipation = { | ||
x: ballToCenterGoalNorm.x * 130, | ||
y: ballToCenterGoalNorm.y * 130 | ||
} | ||
antecipation = {x: ball.x - antecipation.x, y: ball.y - antecipation.y} | ||
return antecipation | ||
} | ||
|
||
let ball = () => { | ||
let ball = {x: this.match.dataManager.ball.x, y: this.match.dataManager.ball.y} | ||
return ball | ||
} | ||
|
||
let ballSpeedBasedMultiplier = () => { | ||
let ballSpeed = Vector.size(this.match.dataManager.ball.speed) | ||
let multiplier = Math.max(Math.min(ballSpeed + 30, 80), 55) | ||
return multiplier | ||
} | ||
|
||
this.addIntetion(new PointIntention('goBall', { | ||
target: ballAntecipation, | ||
radius: 50, | ||
decay: TensorMath.new.finish, | ||
multiplier: ballSpeedBasedMultiplier, | ||
})) | ||
|
||
this.addIntetion(new LineIntention('avoidBallOwnGoal', { | ||
target: ball, | ||
theta: Vector.direction("down"), | ||
lineSize: 50, // Largura do segmento de reta | ||
lineDist: 180, // Tamanho da repelência | ||
lineDistMax: 200, // Tamanho da repelência | ||
lineDistSingleSide: true, | ||
decay: TensorMath.new.mult(-1).finish, | ||
multiplier: 55, | ||
})) | ||
|
||
this.addIntetion(new LineIntention('avoidBallOwnGoallateral', { | ||
target: ball, | ||
theta: Vector.direction("right"), | ||
lineSize: 400, // Largura do segmento de reta | ||
lineDist: 120, // Tamanho da repelência | ||
lineDistMax: 130, // Tamanho da repelência | ||
lineSizeSingleSide: true, | ||
decay: TensorMath.new.constant(1).mult(-1).finish, | ||
multiplier: 50, | ||
})) | ||
|
||
} | ||
loop(){ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters