Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asteroids
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hexboard-games
asteroids
Commits
9e86722f
Commit
9e86722f
authored
9 years ago
by
Memo Akten
Browse files
Options
Downloads
Patches
Plain Diff
some fixes
parent
a9f53b02
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/battle/controllers/Memo/MemoController1.java
+17
-15
17 additions, 15 deletions
src/battle/controllers/Memo/MemoController1.java
src/battle/controllers/Memo/MemoControllerRandom.java
+1
-1
1 addition, 1 deletion
src/battle/controllers/Memo/MemoControllerRandom.java
with
18 additions
and
16 deletions
src/battle/controllers/Memo/MemoController1.java
+
17
−
15
View file @
9e86722f
...
...
@@ -24,19 +24,21 @@ public class MemoController1 implements RenderableBattleController {
public
double
DIST_TO_TARGET_THRESH
=
40
;
public
double
ROT_TO_TARGET_THRESH
=
5
*
Math
.
PI
/
180.0
;
public
double
ATTACK_PROB
=
0.
0
;
public
double
ATTACK_PROB
=
0.
5
;
public
double
ATTACK_SHOOT_PROB
=
0.5
;
public
double
ATTACK_THRUST_PROB
=
0.00
;
public
double
ATTACK_ROT_THRESH
=
5
*
Math
.
PI
/
180.0
;
public
double
CHASE_SHOOT_PROB
=
0.1
;
public
double
CHASE_THRUST_PROB
=
0.3
;
public
double
CHASE_DOT_THRESH
=
0.9
;
Action
action
;
double
desired_dist_to_ship
=
0
;
Vector2d
desired_pos
=
new
Vector2d
();
Vector2d
vec_to_desired_pos
=
new
Vector2d
();
Vector2d
target_pos
=
new
Vector2d
();
Vector2d
desired_pos
=
new
Vector2d
(
true
);
Vector2d
vec_to_desired_pos
=
new
Vector2d
(
true
);
Vector2d
target_pos
=
new
Vector2d
(
true
);
public
MemoController1
()
{
action
=
new
Action
();
...
...
@@ -56,32 +58,32 @@ public class MemoController1 implements RenderableBattleController {
if
(
Math
.
random
()
<
ATTACK_PROB
)
{
do_attack
=
true
;
}
else
{
// pick desired distance to ship
if
(
desired_dist_to_ship
==
0
||
Math
.
random
()
<
DESIRED_DIST_CHANGE_PROB
)
{
desired_dist_to_ship
=
Math
.
random
()
*
(
DESIRED_DIST_TO_SHIP_MAX
-
DESIRED_DIST_TO_SHIP_MIN
)
+
DESIRED_DIST_TO_SHIP_MIN
;
}
// position
desired_pos
=
otherShip
.
s
.
copy
();
desired_pos
.
add
(
otherShip
.
d
,
-
desired_dist_to_ship
);
vec_to_desired_pos
=
desired_pos
.
copy
();
vec_to_desired_pos
.
add
(
thisShip
.
s
,
-
1
);
// set desired position behind enemy ship
desired_pos
=
Vector2d
.
add
(
otherShip
.
s
,
otherShip
.
d
,
-
desired_dist_to_ship
);
vec_to_desired_pos
=
Vector2d
.
subtract
(
desired_pos
,
thisShip
.
s
);
// goto
target
pos
// goto
desired
pos
boolean
reached_desired_pos
=
MemoControllerUtils
.
thrustTo
(
thisShip
.
s
,
thisShip
.
d
,
desired_pos
,
DIST_TO_TARGET_THRESH
,
ROT_TO_TARGET_THRESH
,
action
);
// attack if we're there
if
(
reached_desired_pos
)
{
do_attack
=
true
;
}
else
{
// add randomness
action
.
thrust
=
Math
.
random
()
<
CHASE_THRUST_PROB
?
1
:
0
;
// otherwise thrust (random)
if
(
Vector2d
.
scalarProduct
(
thisShip
.
d
,
Vector2d
.
normalise
(
vec_to_desired_pos
))
>
CHASE_DOT_THRESH
)
{
action
.
thrust
=
Math
.
random
()
<
CHASE_THRUST_PROB
?
1
:
0
;
}
}
}
if
(
do_attack
)
{
action
.
thrust
=
Math
.
random
()
<
ATTACK_THRUST_PROB
?
1
:
0
;
target_pos
=
otherShip
.
s
.
copy
(
);
// TODO, include velocity vector in target pos
target_pos
=
new
Vector2d
(
otherShip
.
s
,
true
);
// TODO, include velocity vector in target pos
action
.
turn
=
MemoControllerUtils
.
lookAt
(
thisShip
.
s
,
thisShip
.
d
,
otherShip
.
s
,
ATTACK_ROT_THRESH
);
action
.
shoot
=
action
.
turn
==
0
?
Math
.
random
()
<
ATTACK_SHOOT_PROB
:
false
;
}
...
...
This diff is collapsed.
Click to expand it.
src/battle/controllers/Memo/MemoControllerRandom.java
+
1
−
1
View file @
9e86722f
...
...
@@ -14,7 +14,7 @@ import battle.controllers.Memo.MemoControllerUtils;
* Created by Memo Akten on 11/06/15.
*/
public
class
MemoControllerRandom
implements
BattleController
{
public
double
MULT
=
0
.0
1
;
public
double
MULT
=
1
.0
;
public
double
ATTACK_PROB
=
0.2
*
MULT
;
public
double
ATTACK_SHOOT_PROB
=
0.5
*
MULT
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment