Rollo's blog

By Rollo, 11 days ago, In English,

Hello,

Can anyone share a polygon of n vertices generator (not necessarily convex) , and validator, its best if it was used in a previous CF round.

 
 
 
 
  • Vote: I like it  
  • +7
  • Vote: I do not like it  

»
11 days ago, # |
Rev. 2   Vote: I like it +24 Vote: I do not like it

jngen can generate you a convex polygon. I assume you wanted convex, did you actually?)

»
11 days ago, # |
  Vote: I like it 0 Vote: I do not like it

All CF rounds use Polygon.

»
23 hours ago, # |
  Vote: I like it +3 Vote: I do not like it

Slow generation: generate some random point and join them randomly. If two edges (a,b) and (c,d) intersect -> swap them to edges (a,c) and (b, d).

  • »
    »
    11 hours ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    I think this is likely to generate a set of non-intersecting polygons instead of one polygon with this method.

»
21 hour(s) ago, # |
  Vote: I like it 0 Vote: I do not like it

Generate some random points and find the convex hull :D

  • »
    »
    21 hour(s) ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Using this method with totally random points leads to really small amounts of points remaining.

»
11 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

The following approach sounds fun. Generate convex polygon. Select arbitrary point O inside of it. Then for each side draw infinite triangle (or limited by your constraints for coords) through O and border points of that side. After that generate random points in that triangle (randomize angle, randomize distance from O, find the closest integer coordinate point to it), sort them by angle from O, delete the side itself and connect points one by one including the original border points.