class Walker{
constructor(element,x,y,r,fill){
this.x = x
this.y = y
this.circle = element.append("circle")
.attr("r",r)
.attr("cx",x)
.attr("cy",y)
.attr("fill",fill)
.attr("stroke","black")
}
step(dx,dy){
this.x = this.x + dx
this.y = this.y + dy
const d = Math.sqrt(dx*dx + dy*dy)
return this.circle.transition().duration(10*d).ease(d3.easeLinear).attr("cx",this.x).attr("cy",this.y)
}
async walk(steps,maxStepSize){
for(let i = 0;i < steps;i = i + 1){
const dx = d3.randomUniform(-1,1)()*maxStepSize
const dy = d3.randomUniform(-1,1)()*maxStepSize
await this.step(dx,dy).end()
console.log(i)
}
}
}