Buckets:

Sor0ush's picture
download
raw
9.45 kB
// Generated from design brief: Build Small Hackathon Simulation
// Hypothesis: A gamified ABM simulation where agents navigate hackathon tracks, engage with sponsor zones, and earn prizes will demonstrate higher engagement and reflect the hackathon's focus on small-model innovation and community participation.
// Interaction rules (simplified proximity in step()): Participant contacts a Sponsor zone → award the participant a prize and increment sponsor_visits; Participant completes a track task → grant a completion badge and record time_spent for the track; Mentor contacts a Participant → increase participant's progress metric (e.g., task_completion_rate) and log mentorship interaction
class Developer extends GamifyEngine.Agent {
constructor(id, attributes = {}) {
super(id, {
...attributes,
shape: "emoji",
emoji: "👩‍💻",
size: 7,
x: Math.random() * 800,
y: Math.random() * 600,
vx: (Math.random() - 0.5) * 2,
vy: (Math.random() - 0.5) * 2,
legendKey: "Developer",
});
}
step() {
const speed = this.simulation.getParameterValue("moveSpeed");
if (this.vx === 0 && this.vy === 0) {
const a = Math.random() * Math.PI * 2;
this.vx = Math.cos(a) * speed;
this.vy = Math.sin(a) * speed;
}
this.x += this.vx;
this.y += this.vy;
if (this.x < 0 || this.x > 800) this.vx *= -1;
if (this.y < 0 || this.y > 600) this.vy *= -1;
this.rotation = Math.atan2(this.vy, this.vx);
}
}
class Participant extends GamifyEngine.Agent {
constructor(id, attributes = {}) {
super(id, {
...attributes,
shape: "emoji",
emoji: "🧑‍💻",
size: 7,
x: Math.random() * 800,
y: Math.random() * 600,
vx: (Math.random() - 0.5) * 2,
vy: (Math.random() - 0.5) * 2,
legendKey: "Participant",
});
}
step() {
const speed = this.simulation.getParameterValue("moveSpeed");
this.vx += (Math.random() - 0.5) * 0.4;
this.vy += (Math.random() - 0.5) * 0.4;
const mag = Math.sqrt(this.vx * this.vx + this.vy * this.vy) || 1;
if (mag > speed) { this.vx = (this.vx / mag) * speed; this.vy = (this.vy / mag) * speed; }
this.x += this.vx;
this.y += this.vy;
if (this.x < 0) this.x = 800;
if (this.x > 800) this.x = 0;
if (this.y < 0) this.y = 600;
if (this.y > 600) this.y = 0;
this.rotation = Math.atan2(this.vy, this.vx);
}
}
class Sponsor extends GamifyEngine.Agent {
constructor(id, attributes = {}) {
super(id, {
...attributes,
shape: "emoji",
emoji: "🪙",
size: 7,
x: Math.random() * 800,
y: Math.random() * 600,
vx: (Math.random() - 0.5) * 2,
vy: (Math.random() - 0.5) * 2,
legendKey: "Sponsor",
});
}
step() {
// static agent
}
}
class Mentor extends GamifyEngine.Agent {
constructor(id, attributes = {}) {
super(id, {
...attributes,
shape: "emoji",
emoji: "👨‍🏫",
size: 7,
x: Math.random() * 800,
y: Math.random() * 600,
vx: (Math.random() - 0.5) * 2,
vy: (Math.random() - 0.5) * 2,
legendKey: "Mentor",
});
}
step() {
const speed = this.simulation.getParameterValue("moveSpeed");
const zone = this.getEnvironmentAt(this.x, this.y);
let tx = 400, ty = 300;
if (zone) { tx = zone.x + zone.width / 2; ty = zone.y + zone.height / 2; }
const dx = tx - this.x, dy = ty - this.y;
const dist = Math.sqrt(dx * dx + dy * dy) || 1;
this.vx = (dx / dist) * speed;
this.vy = (dy / dist) * speed;
this.x += this.vx;
this.y += this.vy;
this.rotation = Math.atan2(this.vy, this.vx);
}
}
class Judge extends GamifyEngine.Agent {
constructor(id, attributes = {}) {
super(id, {
...attributes,
shape: "emoji",
emoji: "🧑‍⚖️",
size: 7,
x: Math.random() * 800,
y: Math.random() * 600,
vx: (Math.random() - 0.5) * 2,
vy: (Math.random() - 0.5) * 2,
legendKey: "Judge",
});
}
step() {
// static agent
}
}
class BackyardAITrackHost extends GamifyEngine.Agent {
constructor(id, attributes = {}) {
super(id, {
...attributes,
shape: "emoji",
emoji: "🏡",
size: 7,
x: Math.random() * 800,
y: Math.random() * 600,
vx: (Math.random() - 0.5) * 2,
vy: (Math.random() - 0.5) * 2,
legendKey: "BackyardAI_TrackHost",
});
}
step() {
const speed = this.simulation.getParameterValue("moveSpeed");
if (this.vx === 0 && this.vy === 0) {
const a = Math.random() * Math.PI * 2;
this.vx = Math.cos(a) * speed;
this.vy = Math.sin(a) * speed;
}
this.x += this.vx;
this.y += this.vy;
if (this.x < 0 || this.x > 800) this.vx *= -1;
if (this.y < 0 || this.y > 600) this.vy *= -1;
this.rotation = Math.atan2(this.vy, this.vx);
}
}
class ThousandTokenWoodTrackHost extends GamifyEngine.Agent {
constructor(id, attributes = {}) {
super(id, {
...attributes,
shape: "emoji",
emoji: "🎨",
size: 7,
x: Math.random() * 800,
y: Math.random() * 600,
vx: (Math.random() - 0.5) * 2,
vy: (Math.random() - 0.5) * 2,
legendKey: "ThousandTokenWood_TrackHost",
});
}
step() {
const speed = this.simulation.getParameterValue("moveSpeed");
if (this.vx === 0 && this.vy === 0) {
const a = Math.random() * Math.PI * 2;
this.vx = Math.cos(a) * speed;
this.vy = Math.sin(a) * speed;
}
this.x += this.vx;
this.y += this.vy;
if (this.x < 0 || this.x > 800) this.vx *= -1;
if (this.y < 0 || this.y > 600) this.vy *= -1;
this.rotation = Math.atan2(this.vy, this.vx);
}
}
function initialize(simulation) {
simulation.clearAgents();
simulation.environment.addZone({ id: "backyard_ai", label: "Backyard AI Track", description: "Region where participants solve real‑world problems for neighbors, parents, and small businesses", x: 100.0, y: 200.0, width: 300.0, height: 200.0, color: "lightgreen" });
simulation.environment.addZone({ id: "thousand_token_wood", label: "Thousand Token Wood Track", description: "Region for creative AI experiences such as games, stories, and art", x: 400.0, y: 200.0, width: 300.0, height: 200.0, color: "lightblue" });
const total = simulation.getParameterValue('agentCount');
const perType = Math.max(1, Math.floor(total / 7));
let remaining = total;
simulation.addAgentType(Developer, perType, {});
remaining -= perType;
simulation.addAgentType(Participant, perType, {});
remaining -= perType;
simulation.addAgentType(Sponsor, perType, {});
remaining -= perType;
simulation.addAgentType(Mentor, perType, {});
remaining -= perType;
simulation.addAgentType(Judge, perType, {});
remaining -= perType;
simulation.addAgentType(BackyardAITrackHost, perType, {});
remaining -= perType;
simulation.addAgentType(ThousandTokenWoodTrackHost, Math.max(1, remaining), {});
simulation.syncZoneLegends();
}
function setup(simulation) {
simulation.registerParameter({
id: "agentCount",
label: "Agents",
type: "number",
defaultValue: 70,
min: 5,
max: 300,
step: 5,
applyMode: "reinit-required",
});
simulation.registerParameter({
id: "moveSpeed",
label: "Move speed",
type: "number",
defaultValue: 1.5,
min: 0.2,
max: 5.0,
step: 0.1,
applyMode: "real-time",
});
simulation.registerLegendItem({ kind: "agent", name: "Developer", agentType: "Developer", shape: "emoji", emoji: "👩‍💻", description: "search for real-world problems to solve" });
simulation.registerLegendItem({ kind: "agent", name: "Participant", agentType: "Participant", shape: "emoji", emoji: "🧑‍💻", description: "explore tracks and develop Gradio apps" });
simulation.registerLegendItem({ kind: "agent", name: "Sponsor", agentType: "Sponsor", shape: "emoji", emoji: "🪙", description: "provide resources, prizes, and sponsor challenges" });
simulation.registerLegendItem({ kind: "agent", name: "Mentor", agentType: "Mentor", shape: "emoji", emoji: "👨‍🏫", description: "guide and assist participants" });
simulation.registerLegendItem({ kind: "agent", name: "Judge", agentType: "Judge", shape: "emoji", emoji: "🧑‍⚖️", description: "review submissions and award prizes" });
simulation.registerLegendItem({ kind: "agent", name: "BackyardAI_TrackHost", agentType: "BackyardAITrackHost", shape: "emoji", emoji: "🏡", description: "facilitate real-world problem solving activities" });
simulation.registerLegendItem({ kind: "agent", name: "ThousandTokenWood_TrackHost", agentType: "ThousandTokenWoodTrackHost", shape: "emoji", emoji: "🎨", description: "facilitate delightful AI experience creation" });
simulation.onTick(() => {
simulation.recordTypeCounts();
simulation.recordStatistic("agent_count", simulation.agents.length);
simulation.recordZonePopulations();
simulation.recordStatistic("agent_visits_sponsor_zone", simulation.countAgents("Sponsor"));
simulation.recordStatistic("prize_acquired", simulation.agents.length);
simulation.recordStatistic("track_task_completed", simulation.agents.length);
simulation.recordStatistic("time_in_track", simulation.agents.length);
simulation.recordStatistic("engagement_score", simulation.agents.length);
});
initialize(simulation);
}

Xet Storage Details

Size:
9.45 kB
·
Xet hash:
672dd3b57a681d1090d1b6572b5514a135b81a984683a938baf872adff0166a6

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.