Author Topic: EBot - 10points (v0.12 demo bot)  (Read 5155 times)

jedislight

  • Administrator
  • Newbie
  • *****
  • Posts: 4
    • View Profile
EBot - 10points (v0.12 demo bot)
« on: December 07, 2012, 10:41:38 PM »
Code: [Select]
#Ebot
#Author - Jedislight
#Concept - Test bed for finding pain points in the language
#Points - 10
armor:2
shields:2
cpu:2
generator:2
battery:1

#build options, cost 1 point for each enabled option
scanner:off
radar:on
missiles: off
broadcastdish:off
explosiveshot:off
repairshot:off

instructions:
radarbots
45 radar_arc store
-1 target_facing store
-1 target_distance store
2 maxshield store
15 maxarmor store
4 global_speed store

radar_arc radararcset
radar_arc 2 div radar_half store
radar_arc 9 div radar_sweep_angle store

x wander_target_x store
y wander_target_y store

MOVEMENT_THREAD thread
TURRET_THREAD thread
DEFENSE_THREAD goto

DEFENSE_THREAD:
maxshield curshield sub 2 mul energy min shield # fill shield to max stable value, but don't overdraw from battery
DEFENSE_THREAD goto

MOVEMENT_THREAD:
(north y sub abs 32 <
south y sub abs 32 <
east x sub abs 32 <
west x sub abs 32 <
or or or )if
{
0 xvel
0 yvel
}

CLOSE_RANGE

(armor 6 <) if
{
MAXIMIZE_RANGE
}

(target_distance -1 =) if
{
WANDER
}

call
dropall
MOVEMENT_THREAD goto

TURRET_THREAD:
NO_TARGET

(radar) if
{
SOFT_TARGET
}

(range 0 >) if
{
HARD_TARGET
}

call # call method on top of stack
dropall #drop all stack in case multiple methods stacked
TURRET_THREAD goto # loop

NO_TARGET:
-1 target_distance store
-1 target_facing store
aiming radar_arc radar_sweep_angle sub add aim
return

HARD_TARGET:
energy 2 sub 4 div shot_power var
shot_power fire
aiming 1.5 sub aim
shot_power fire
aiming 3 add aim
shot_power fire
aiming 1.5 sub aim
shot_power fire

range target_distance store
return

SOFT_TARGET:
radar target_distance store
aiming target_facing store

LOCKON call
return

LOCKON:
radar_half i var
LOCKON_LOOP:
i radar_sweep_angle sub i var

i radar_half chs < if # break if i reaches -45 (full sweep)
{
return
}
target_facing i add aim
(range not) if # loop until range found
{
LOCKON_LOOP goto
}

return

WANDER:
(wander_target_x x sub 2 pow) (wander_target_y y sub 2 pow) add squared_distance var

((squared_distance 256 >) (xv yv add) and) if
{
return
}

energy global_speed < if
{
return
}

east 2 mul rand east sub wander_target_x store
north 2 mul rand north sub wander_target_y store

global_speed wander_target_y wander_target_x GOTO_LOCATION call

return

CLOSE_RANGE:
energy global_speed < if
{
return
}

global_speed target_facing MOVE_BY_DIRECTION call
return

MAXIMIZE_RANGE:
energy global_speed < if
{
return
}
(global_speed chs) target_facing MOVE_BY_DIRECTION call
return

MOVE_BY_DIRECTION: (direction_to_move var, speed var)
direction_to_move rad theta var
theta cos xd var
theta sin yd var

xd speed mul xvel
yd speed mul yvel
return

GOTO_LOCATION: (target_x var, target_y var, speed var)
target_x x sub xd var
target_y y sub yd var

xd 2 pow yd 2 pow add .5 pow magnitude var
xd magnitude div speed mul xvel
yd magnitude div speed mul yvel
return


impalasiC

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Mojoheadz Records Los Angeles
-
« Reply #1 on: July 15, 2021, 06:04:30 AM »
I consider, that you commit an error. I can defend the position.
House music Mojoheadz Records music blogs