// matchmaking: one actor per queue, players arrive as messages
public class MatchmakingActor extends AbstractBehavior<Command> {
private final Deque<Player> queue = new ArrayDeque<>();
private static final int TEAM_SIZE = 5;
Behavior<Command> onJoin(Join msg) {
queue.add(msg.player);
if (queue.size() >= TEAM_SIZE * 2) startMatch();
return this;
}
}
// device service: retry with backoff before giving up on a phone
func (s *DeviceServer) Install(ctx context.Context, req *pb.InstallRequest) (*pb.InstallReply, error) {
for attempt := 1; attempt <= 3; attempt++ {
if err := s.push(ctx, req.Udid, req.Ipa); err == nil {
return &pb.InstallReply{Ok: true}, nil
}
time.Sleep(time.Duration(attempt) * time.Second)
}
return nil, status.Error(codes.Unavailable, "device not responding")
}
# agent loop: plan from the knowledge base, act, verify
async def run(goal: str, device: Device) -> Result:
steps = await kb.plan(goal, app=device.app)
for step in steps:
el = await find(device, step.target) # xml first, image match second
await device.tap(el)
return await verify(device, goal)
// matchmaking: one actor per queue, players arrive as messages
public class MatchmakingActor extends AbstractBehavior<Command> {
private final Deque<Player> queue = new ArrayDeque<>();
private static final int TEAM_SIZE = 5;
Behavior<Command> onJoin(Join msg) {
queue.add(msg.player);
if (queue.size() >= TEAM_SIZE * 2) startMatch();
return this;
}
}
// device service: retry with backoff before giving up on a phone
func (s *DeviceServer) Install(ctx context.Context, req *pb.InstallRequest) (*pb.InstallReply, error) {
for attempt := 1; attempt <= 3; attempt++ {
if err := s.push(ctx, req.Udid, req.Ipa); err == nil {
return &pb.InstallReply{Ok: true}, nil
}
time.Sleep(time.Duration(attempt) * time.Second)
}
return nil, status.Error(codes.Unavailable, "device not responding")
}
# agent loop: plan from the knowledge base, act, verify
async def run(goal: str, device: Device) -> Result:
steps = await kb.plan(goal, app=device.app)
for step in steps:
el = await find(device, step.target) # xml first, image match second
await device.tap(el)
return await verify(device, goal)