I'm working on a personal project linked to the ant colony problem. I successfully developed everything for a console project and now I want to transpose the code in a more graphic layout with windows forms.
Using the code below the form shows correctly one moving pixel, but I'm not able to find a way to show the left trail of the movement. I tried to remove the pictureBox1.Invalidate(), but this brings me to a static pixel in the starting point.
I would like not to reparse the map matrix and draw the pheromone trail, but only leave the drawn positions as if I'm drawing something with a pen on a piece of paper.
public void RenderAnts(object sender, PaintEventArgs e)
{
pictureBox1.Invalidate();
foreach (Ant a in ants)
{
Brush c;
c = Brushes.DarkBlue;
if (a.role == AntRole.Scout)
{
a.Move(i);
c = Brushes.Red;
}
e.Graphics.FillRectangle(c, a.position.x, a.position.y, 1, 1);
}
pictureBox1.Show();
}