Game Rubber Band and Pegs

I need to make a flash game as follows: It has a board with holes (more than 1000). Initially, 3 pegs and a rubber band around them were placed on the board. We have 3 possible operations: 1. Add a binding - adds a binding on the board 2. Remove the pin - removes the pin (if there are more than 3 pins) - the rubber tape should be in the form of the remaining pins. 3. Move the pin - the rubber band should be updated with the current positions of the pins.

How would you solve the problem of finding the optimal shape with an elastic band?

I have 2 ideeas, but I have to work a bit on them. The main idea is that we should change the shape of the rubber band only during the “Move” operation, and we use the same number of pegs, only one changes position:

  • Conclusion of the convex hull algorithm. We should know that the pegs are inside rubber and outside. This can be a little complicated.

  • We work with only three pegs: 2 anchors and 1 medium. 2 anchors form the line boundary for the interaction of the 1st middle pin. On the active side of the line, the rubber band functions as 2 segments between two safety pins and the middle pin. On the inactive side 1, the middle pin is free to move, while the rubber band functions as a straight line between the two tie pins. A caveat to the foregoing is that there are times when moving 1 midpoint in the active side of the boundary line can cause one of the 2 segments to come into contact with the 4th pin. The program should detect this event and update the new anchors accordingly. These are just suggestions from limited experience in this concept. The developer must determine the best approach,based on his experience and judgment.

- ?

+3
1

" , ". - , ?:)

"" , , " " . , .

, , , . , , , ( ).

, A a a.

, , , a a , , . , , , , , .

, ?

  • Peg A "" . ( , A , a-a ' .)
  • Peg A "" . ( , A B C, a-a ' B-C.)
  • Peg A . ( , A , B A, a-a'-B C.)
  • Peg A . ( , A , A-B-C, B a-a'-C.)

, ; , ; ; (); .

( , ? .)

: , (, A-B-A-C-A). , .

, . , , B C. A 8 B C ( B, C, ). , , A . , , - , - . , (, , , , , , ).

+3

Source: https://habr.com/ru/post/1773423/


All Articles