
RoboCom · China Robot and AI Competition
This was not two teams of robots fighting over a ball. Each team fields two attacking robots (yellow, #3 and #5); the goalkeeper is supplied by the organisers (blue, #4, position unknown and able to move). The referee places the ball on five fixed spots in turn, and each spot gets its own attacking play: (1) back zone, (2) midfield point, (3) front zone, (4) corner zone, (5) penalty point. The exact locations of the back, front and corner zones are not published before the event.
Two constraints, both hard:
Scoring: a goal is +20, no goal 0, ball out 0; each foul is −5 and voids the goal (fouls are shooting directly, entering the penalty area, and touching the ball twice); skipping a spot is −10. The final mark is 80% on-field execution plus 20% technical report.
In other words, the rulebook is a fixed acceptance test: fifteen seconds, one compulsory pass, a keeper that moves. It turns “robot football” from an open problem into a flow problem with two actors, three fouls and five starting points — which is exactly why it can be solved with a script.

The mandated software was SOM 3.4.2, running on the organisers’ machine; teams submitted two kinds of artefact:
Team/lua_scripts/play/Package/<scenario>/, one state machine per spot, choreographing who runs where, who receives, when to pass, when to shoot;Team/user_skills/ and called them straight from Lua, controlling kick power, kick angle, the facing after receiving the ball, and the shooting direction.Roles are fixed: #1 Goalie, #3 Kicker, #5 Receiver. Writing task.KickerTask("shemen") in Lua ultimately loads user_skills/shemen.dll — the names map one to one, and Lua only passes coordinates, heading and power (kp=127, cp=6 by default).
All five spots share the same skeleton: get the ball → pass → shoot (GetBall → PassBall → Shoot). Below is the back-zone free kick script in full; it is essentially identical to the front-zone and corner versions:
gPlayTable.CreatePlay{
firstState = "GetBall",
["GetBall"] = {
switch = function()
if Cbuf_cnt((CBall2RoleDist("Receiver") < 30 and CRole2TargetDist("Kicker")< 5),120) then
return "PassBall"
end
end,
Kicker=task.GotoPos("Kicker",80,5,KickerRole2BallDir),
Receiver = task.GetBall("Receiver","Kicker"),
},
["PassBall"] = {
switch = function()
if CIsBallKick("Receiver") or CBall2RoleDist("Receiver") < 5 or Cbuf_cnt(ture,120) then
return "Shoot"
end
end,
Kicker=task.RobotHalt("Kicker"),
Receiver = task.ReceiverTask("chuanqiu"),
Goalie = task.Goalie()
},
["Shoot"] = {
switch = function()
if CIsBallKick("Kicker") then
return "finish"
end
end,
Receiver = task.GotoPos("Receiver",-176,-178,0),
Kicker = task.KickerTask("shemen"),
Goalie = task.Goalie()
},
name = "P_Back"
}
Three details are worth pointing out:
Cbuf_cnt(condition, 120) does not mean “if the condition holds” but “if it has held for 120 consecutive frames”. A single flickering frame resets the counter, so one bad vision reading cannot push the play forward;CBall2RoleDist("Receiver") < 30 checks whether the ball is with #5, and CRole2TargetDist("Kicker") < 5 checks whether #3 has reached its spot. Both must hold before the state advances;(-176, -178) to clear the shooting line — that is not tactics, just basic manners about not standing in front of your own striker.
The three-stage play ran beautifully in simulation. The first on-site session (28 June) dismantled it. The next two months were mostly spent patching four things:
Frame confirmation plus a timeout guard. On the real carpet the robots routinely stopped “just short” of the target, so the transition condition never became true and the play waited forever. From 3 July every stage carries a Cbuf_cnt timer: even if the condition is not met, the timeout forces the next block of instructions, so at least the ball gets kicked.
A guard stage between pass and receive. A missed pass was the most frequent failure: #5 assumed the ball had left, when in fact it was still sitting there. So we inserted a stage between PassBall and Shoot that only advances once the receiver really has the ball, while the receiver keeps running to its spot; the guard duration is tunable through the delay function.
Mirroring the runs left and right. We started with hard-coded “striker stands here, receiver stands there”, and the two robots kept crowding the same point. The later K_* rewrite decides the receiving point from the sign of CGetBallY(): mirrored to -35 / -148 when the ball is in the left half, +35 / +148 in the right half.
Kick power in distance bands. A single fixed power either overshot short passes or undershot long ones, so the power became a piecewise function of the target distance (kp and cp control the flat and chip kicks separately). I made that change on 27 June.
One more item is not technical, but it saved the competition: we prepared two complete script sets. Our own DLLs behaved well in simulation and often barely at all on the field, so we also wrote a second set using only official functions and swapped the whole set on site whenever the custom DLLs failed. That guaranteed we would never score zero.
18 September 2022, field 2, match 1. Two script runs, best result counted:
| Run | Spots scored | Points | Total time | Fouls |
|---|---|---|---|---|
| First | 4 / 5 | 80 | 35.68 s | 0 |
| Second | 2 / 5 | 40 | 34.21 s | 0 |
Eighty points and zero fouls in the first run earned a first prize at the provincial final; the national final in October brought a third prize. In July and August we also entered the China Robot and AI Competition circuit — first prize in the Shanghai region, second prize in the national final — although from that line only the two certificates survive, no code and no report.
The number I remember best is 13.94 s: the back-zone free kick, from the referee placing the ball to the ball crossing the line, took almost fourteen seconds — one second under the limit. The technical report is honest about the rest too: simulated scoring went from 50% to 90%, hardware-in-the-loop from 40% to 80%, and per-skill simulation success was 95% for passing, 95% for shooting, 60% for receiving and 100% for penalties. Nearly usable in simulation, barely enough on the field.
Reading through the submitted code while archiving it turned up more problems than expected. All are left untouched — patching them would make the repository disagree with what was actually submitted — and are flagged in 代码导读.md:
Cbuf_cnt(ture, 120) — ture is a typo for true, which in Lua is nil. The timeout guard therefore never fires, and once a pass is missed the P_ series simply sits in PassBall until the fifteen seconds run out. That bug maps exactly onto the “missed pass” difficulty listed in the technical report.name, with the Kicker standing at (80, 5) in all three. Only the midfield script moved to (130, 5). So the corner spot was actually running the back-zone choreography.kp=127, cp=6 are hard-coded across a dozen scripts. Changing one number meant opening seven or eight files, which is why on-site tuning ended up as handwritten notes in test.txt.Looking back, all three have the same root cause: because we had no field, we put parameters inside the code instead of a configuration file. With a parameter table, none of the three would have required a code change.
The competition documents, both technical reports, the scanned official score sheet, the four certificates, and the Lua scripts and skill DLLs we wrote are collected in the repository:
https://github.com/yicongl1/iLoboke-Robot-Soccer-2022
It does not include the SOM 3.4.2 platform itself (commercial software of the technical support company), so a clone can be read but not run. The encrypted submission packages — encrypted as the rules required, password since lost — are kept as Release attachments as evidence of what was actually submitted.



