1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
|
-- Reduced but very effective bot.
-- Borrows from axji.lua, com_10.lua and com_11.lua as distributed with
-- Blobby Volley.
-- Copyright (C) 2010 Soeren D. Schulze
-- The terms of the GPLv2 or later apply.
-- See the Blobby Volley distribution for the license text.
modeLock = 0
timeto = 0
target = 0
naivetarget = 0
estimbspeedx = 0
direct = true
servrand = nil
-- Knostanten
CONST_BALL_RADIUS = 31.5
CONST_MITTE = 400
CONST_BLOBBY_HOEHE = 89
CONST_BLOBBY_KOPF_RADIUS = 25
CONST_BLOBBY_BAUCH_RADIUS = 33
CONST_NETZ_RADIUS = 7
CONST_NETZ_HOEHE = 157
CONST_FELD_LAENGE = 800
CONST_BALL_RADIUS = 31.5
CONST_GROUND_PLANE = 100
CONST_BALL_GRAVITY = 0.28
CONST_MITTE = CONST_FELD_LAENGE/2
CONST_RECHTER_RAND = CONST_FELD_LAENGE - CONST_BALL_RADIUS
-- Berührungsebene des Balls falls er ans Netz kommt
CONST_NETZ_LINKS = CONST_MITTE - CONST_NETZ_RADIUS - CONST_BALL_RADIUS
CONST_NETZ_RECHTS = CONST_MITTE + CONST_NETZ_RADIUS + CONST_BALL_RADIUS
CONST_BLOBBY_HOEHE = 89
CONST_BLOBBY_KOPF_RADIUS = 25
CONST_BLOBBY_BAUCH_RADIUS = 33
CONST_BLOBBY_KOPF_BERUEHRUNG = CONST_GROUND_PLANE + CONST_BLOBBY_HOEHE + CONST_BALL_RADIUS
CONST_BLOBBY_MAXJUMP = 393.625
function OnServe(ballready)
if servrand == nil then
servrand = math.random()
end
moveto(ballx() + servrand * 5)
if ballready and math.abs(posx() - (ballx() + servrand * 5)) < 3 then
jump()
servrand = nil
end
end
function OnOpponentServe()
moveto(100)
end
function OnGame()
estimImpactHigh()
if (not (target == nil))
and naivetarget < 400
and (modeLock == 1
or timeto > math.abs(posx()-highPlayPos())/4.5 + 26)
and touches() < 3
then
if (timeto < 30) then
modeLock = 1
else
modeLock = 0
servrand = nil
end
highPlay()
else
modeLock = 0
servrand = nil
estimImpactLow()
if (not (target == nil))
and ((estimbspeedx > 0 and timeto > (target-posx()-10)/4.5)
or (estimbspeedx < 0 and timeto > (posx()-target-10)/4.5)
or naivetarget >= 400) then
lowPlay()
else
-- HEELLPPP...
if not (target == nil)
and naivetarget < 400 then
-- This often saves your ass if you're standing inside a
-- corner and the ball bounces from the wall or the net.
lowPlay()
jump()
end
end
end
end
function highPlayPos()
if estimbspeedx < 0 then
-- safety againt fast balls
return target - 50 - estimbspeedx*5
else
return target - 50
end
end
function highPlay()
if (target > 400) then
moveto(100)
else
moveto(highPlayPos())
-- 33 time units for jumping to max height
-- Regarding naive target here.
-- If the ball really bounces back, it would be a bad idea to jump...
if servrand == nil then
servrand = math.random()
end
if naivetarget < 400 and timeto < 28 + servrand then
jump()
end
end
end
function lowPlay()
if (target > 400) then
moveto(100)
else
moveto(target)
end
end
function estimImpactHigh()
estimImpact2(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP - 25,1)
end
function estimImpactLow()
estimImpact2(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,1)
end
function estimImpact2(bx,by,vbx,vby,destY,Frage) -- erlaubt ein besseres Estimate mit ein paar unbeding nötigen Angaben
bgrav = 0.28
if ((vby^2)-(-2*bgrav*(by-destY))) < 0 then
target = nil
return
end
time1 =(-vby-math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav)
--time2 =(-vby+math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav)
timeto = time1
if (timeto < 0) then
target = nil
return
end
naivetarget = (vbx * time1) + bx
resultX = naivetarget
estimbspeedx=bspeedx()
direct = true
if(resultX > CONST_RECHTER_RAND) then
resultX = 2 * CONST_RECHTER_RAND - resultX
estimbspeedx=-estimbspeedx
direct = true
end
if(resultX < CONST_BALL_RADIUS) then -- korrigieren der Appraller an der linken Ebene
resultX = 2 * CONST_BALL_RADIUS - resultX
estimbspeedx=-estimbspeedx
direct = false
end
if (estimbspeedx > 0) and (resultX > CONST_NETZ_LINKS) then
direct = false
resultX = 2 * CONST_NETZ_LINKS - resultX
estimbspeedx=-estimbspeedx
end
target = resultX
end
|