Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3344600
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:05:17+00:00 2026-05-18T01:05:17+00:00

I have to make a flash game like this: There is a board with

  • 0

I have to make a flash game like this:
There is a board with holes in it (more than 1000). Initially, there are 3 pegs placed on the board and a rubber band around them.
We have 3 possible operations:
1. Add peg – adds a peg on the board
2. Remove peg – removes a peg ( if there are more than 3 pegs) – the rubber band must take the shape of the remaining pegs.
3. Move peg – rubber band must be updated with current positions of the pegs.

How would you solve the problem of finding the rubber band’s shape optimally?

I have 2 ideeas, but I have to work on them a little bit. The main ideea is that we have to change the rubber band’s shape only at “Move” operation, and we use the same number of pegs, only one is changing position:

  1. A derivation from convex hull algorithm. We have to know wich pegs are inside the rubber band and wich are outside. It might get a little complicated.

  2. We work with only 3 pegs: 2 anchors and 1 middle. The 2 anchors form a boundary line for the interaction of the 1 middle peg. On the active side of the line the rubber band functions as 2 segments between the 2 anchor pegs and the middle peg. On the inactive side the 1 middle peg is free to move while the rubber band functions as a straight line between the 2 anchor pegs. The caveat to the above is that there are cases in which movement of the 1 middle peg in the active side of the boundary line can can cause one of the 2 segments to contact a 4th peg. The program must detect this occurrence and update the new anchor pegs accordingly. These are just suggestions from some limited experience with this concept. The developer should determine the best approach based on his experience and judgement.

Do you have any other ideeas, or suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:05:18+00:00Added an answer on May 18, 2026 at 1:05 am

    “The developer should determine the best approach based on his experience and judgement.” — did you copy and paste this from the spec you were given? 🙂

    You ask for an “optimal” solution but if I were you I’d aim for a “correct, and fast enough” solution. You’ve got a contract to fulfil, you can leave the asymptotics to the academics.

    Anyway, your plan to update the band only when the player moves a peg looks like a good one. We are going to need to remember all the pegs that are touching the rubber band, and for each peg we have to remember which side of the rubber band it’s on (in order to draw the band correctly).

    Now, suppose the player moves peg A from a to a’.

    As a general principle, it’s worth bearing in mind that even if your time segments are short, and the distance from a to a’ is small, nonetheless there might be multiple things that happen. So you’re going to have to consider all the events that might happen in that time segment, pick the earliest such event, update your data structures accordingly, and then continue with the remainder of the time segment.

    So what kind of events are there?

    • Peg A “picks up” the band. (It does so if peg A was not already on the band, and the line a–a’ crosses one of the lines between pegs on the band.)
    • Peg A “puts down” the band. (It does so if peg A was on the band, with neighbours B and C, and the line a–a’ crosses the line B–C.)
    • Peg A gains a neighbour on the band. (This happens when peg A is on the band, B is a neighbour of A and the triangle a–a’–B contains another peg C.)
    • Peg A loses a neighbour on the band. (This happens when peg A is on the band, the neighbouring pegs on the band go A–B–C, and peg B is in the triangle a–a’–C.)

    So you should determine all such events; work out the time that each event would happen; sort the events into order by time; handle the earliest event (only); repeat for the remainder of the time segment.

    (What to do if two events happen simultaneously? I’ll leave that up to your experience and judgement.)

    Edited to add: a complication is that a peg may appear on more than one segment of the rubber band (for example, the band may go A-B–A-C-A). But I think the above sketch of an algorithm still works.

    A further wrinkle is that even with a small number of pegs, you can make arbitrarily twisty configurations of the band. For example, suppose the band is stretched between pegs B and C. Now take peg A and move it in a figure-of-8 around pegs B and C (clockwise around B, anti-clockwise around C, let’s say). Each time round the loop, peg A picks up another couple of pieces of the band. You can’t afford to let the complexity of the configuration grow without bound, so need some way of stopping things getting out of hand. I suggest imposing a maximum limit on the length of the band, so that any attempt to stretch it too far causes it to snap (of course you’d have warning signs before this happens, e.g. band getting thinner, changing colour, ominous creaky sounds).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building an iPhone game and I have a UIBarButtonItem that will provide the
How can I make a USB controller control my AS3 game. I'm using the
I have been asked to research teaching a module in game development to beginners
I'm looking for a way have some way of communication between an AIR application
When I run my swf locally in the Flash Player application, its memory usage
I've picked up some action scripting lately and I decided to make myself a
I have vast programming knowledge; C++/C#/ActionScript/ASM/PHP..... so learning the language of SilverLight itself isn't
As I've found recently, setting width / height properties on a Sprite only forces
I am going to use Flask micro-framework (based on Werkzeug , and I'll be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.