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 59935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:04:59+00:00 2026-05-10T18:04:59+00:00

I was thinking earlier today about an idea for a small game and stumbled

  • 0

I was thinking earlier today about an idea for a small game and stumbled upon how to implement it. The idea is that the player can make a series of moves that cause a little effect, but if done in a specific sequence would cause a greater effect. So far so good, this I know how to do. Obviously, I had to make it be more complicated (because we love to make it more complicated), so I thought that there could be more than one possible path for the sequence that would both cause greater effects, albeit different ones. Also, part of some sequences could be the beggining of other sequences, or even whole sequences could be contained by other bigger sequences. Now I don’t know for sure the best way to implement this. I had some ideas, though.

1) I could implement a circular n-linked list. But since the list of moves never end, I fear it might cause a stack overflow ™. The idea is that every node would have n children and upon receiving a command, it might lead you to one of his children or, if no children was available to such command, lead you back to the beggining. Upon arrival on any children, a couple of functions would be executed causing the small and big effect. This might, though, lead to a lot of duplicated nodes on the tree to cope up with all the possible sequences ending on that specific move with different effects, which might be a pain to maintain but I am not sure. I never tried something this complex on code, only theoretically. Does this algorithm exist and have a name? Is it a good idea?

2) I could implement a state machine. Then instead of wandering around a linked list, I’d have some giant nested switch that would call functions and update the machine state accordingly. Seems simpler to implement, but… well… doesn’t seem fun… nor ellegant. Giant switchs always seem ugly to me, but would this work better?

3) Suggestions? I am good, but I am far inexperienced. The good thing of the coding field is that no matter how weird your problem is, someone solved it in the past, but you must know where to look. Someone might have a better idea than those I had, and I really wanted to hear suggestions.

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-10T18:05:00+00:00Added an answer on May 10, 2026 at 6:05 pm

    I’m not absolutely completely sure that I understand exactly what you’re saying, but as an analagous situation, say someone’s inputting an endless stream of numbers on the keyboard. ‘117’ is a magic sequence, ‘468’ is another one, ‘411799’ is another (which contains the first one).

    So if the user enters:

    55468411799

    you want to fire ‘magic events’ at the *s:

    55468*4117*99*

    or something like that, right? If that’s analagous to the problem you’re talking about, then what about something like (Java-like pseudocode):

    MagicSequence fireworks = new MagicSequence(new FireworksAction(), 1, 1, 7); MagicSequence playMusic = new MagicSequence(new MusicAction(), 4, 6, 8); MagicSequence fixUserADrink = new MagicSequence(new ManhattanAction(), 4, 1, 1, 7, 9, 9);  Collection<MagicSequence> sequences = ... all of the above ...;  while (true) {   int num = readNumberFromUser();   for (MagicSequence seq : sequences) {     seq.handleNumber(num);   } } 

    while MagicSequence has something like:

    Action action = ... populated from constructor ...; int[] sequence = ... populated from constructor ...; int position = 0;  public void handleNumber(int num) {   if (num == sequence[position]) {     // They've entered the next number in the sequence     position++;     if (position == sequence.length) {        // They've got it all!        action.fire();        position = 0; // Or disable this Sequence from accepting more numbers if it's a once-off     }   } else {     position = 0; // missed a number, start again!   } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thinking about a Windows-hosted build process that will periodically drop files to disk to
Thinking about my other problem , i decided I can't even create a regular
While thinking about this question and conversing with the participants, the idea came up
Earlier today, I decided to start working on a small control panel for administration
I was thinking about this earlier and figured I'd ask. If I made an
Was looking at some code earlier, and am thinking that there has to be
Here's another one I've been thinking about lately. We have concluded in earlier discussions
After thinking that I finally figured git out, I'm now finding myself super-confused about
Thinking about getting into .net technology project management I've had plenty of experience with
Without thinking about it at all I just want to say I should allow

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.