here the programme I think there are some mistakes couldnot know where please any comment will be helpful:
# Firstly, set the size limit for the grid, which shall define how many
# points there are in both the vertical and horizontal direction
# limit is a variable used to set an unobtainable upper bound
# x defined, starting at 1, and two other variables ud (upper diagonal) and
# dd (downward diagonal) begin at 0. All three are used to iterate through
# line creation
# Iteration through x, using the line function to create a number of
# horizontal lines up to the limit point
line([0, size], [x, x]);
# Now iterating through the diagonals pointing upwards, using two sets of
# lines, both starting from the line going through the origin. The first
# iterates through the lines that pass through positive x values at y=0,
# the second iterates through the lines passing through negative x values
# at y=0
# ud must be increased by 2 each time to ensure that equilateral triangles
# are formed.
line([(ud), (size)], [0, (size-ud)]);
line([0, (size-ud)], [(ud), (size)]);
# Similar to before, except this time iterating through downward pointing
line([(dd), 0], [0, (dd)]);
line([(size), (dd)], [(dd), (size)]);
# xvector and yvector set up as two vectors holding x and y co-ordinates of
# points respectively.
xvector = zeros(1, limit);
yvector = zeros(1, limit);
# Reinitiallising x and y values for iterative purposes.
# The program now iterates through potential y values for the potential
# points. Then it tests the value of y to see what orientation the lattice
# is at that point, then randomly selects x values to enter, iterating
# between all the possible x values in the orientation before moving on to
# the next y value.
# The program then enters the two co-ordinate vectors saved previously into
# the scatter function.