• I need your help! - Algorithums
    8 replies, posted
Hello, so I'm working on a mobile game in Corona(not that it matters), it's a multiplayer game where you're connected randomly to someone else playing the game to defuse a bomb before them. Bombs generate with 4 modules and each has a chance to generate "powercells" which kinda alter how they work. One of those modules is a wire cutting module where by wires are generated and you must cut them in a specific order. And there's the problem, generating them with a order that can be determined by the user to then defuse it. I need help coming up with a system that works "well". (generation info below) I've tried writing and re writing it over and over and I can get anything that can be logically solved. At first I just had randomly generating the wires then had a million if statements to make a order something like; if there's a blue in the 3 spot it's first or if there's red wire that's first but if there is a powercell on that module then the first is black and if there is no blacks then it's the last wire... as you can see it's a bit chaotic. I'm not asking for someone to code anything just a layout for a algorithm I could then write out. 6 wire color: - red -blue -black -yellow -gray -white 3 difficulties: dif 1 - 4 wires dif 2 - 4-6 wires dif 3 - 4-8 wires Thanks in advance, Drew <3
What language is this in? So based on the module, there will be a certain order of input in order to complete that module. Why not just hardcode the order to the module?
Why not just generate some sort of subtle effect? Maybe when you cut the correct wire, one of the other wires will spark slightly for a second then stop? You're already trying to defuse a bomb before another player, "blink and you'll miss it" type effects would fit in nicely here. [editline]2nd February 2016[/editline] It would make the "predictability" thing less important since the game would give you a hint
I think making a trie of possibilities on some rules would work?
I think this guy is looking for some sort of design pattern or SOLID principle to accomplish what he wants. Why not just delegate some wire solution to the module.
[QUOTE=brianosaur;49668162]I think this guy is looking for some sort of design pattern or SOLID principle to accomplish what he wants. Why not just delegate some wire solution to the module.[/QUOTE] Sorry my internet went down and I hate navigating this website on mobile... any way it's being written in lua in the corona engine as a mobile game. brianosaur your getting it thankfully! there could be multiple wire modules, but there will only be 4 modules per bomb. each module is generated separately to the other modules.A solid pattern could be determined by a little bit of logic and process of elimination. Hard coding it is becoming the best answer but I really don't want to that cause its going to end up so inefficient! :P [QUOTE=Shadaez;49659233]I think making a trie of possibilities on some rules would work?[/QUOTE] That sounds pretty good I'll give that a try didn't think of that :D [QUOTE=lavacano;49658698]Why not just generate some sort of subtle effect? Maybe when you cut the correct wire, one of the other wires will spark slightly for a second then stop? You're already trying to defuse a bomb before another player, "blink and you'll miss it" type effects would fit in nicely here. [editline]2nd February 2016[/editline] It would make the "predictability" thing less important since the game would give you a hint[/QUOTE] That actually sounds like a pretty good idea I'll do that if all else doesn't work out :)
[QUOTE=lavacano;49658698]Why not just generate some sort of subtle effect? Maybe when you cut the correct wire, one of the other wires will spark slightly for a second then stop? You're already trying to defuse a bomb before another player, "blink and you'll miss it" type effects would fit in nicely here. [editline]2nd February 2016[/editline] It would make the "predictability" thing less important since the game would give you a hint[/QUOTE] Alternatively, he could make it so that different modules provide hints for each other. Like to figure out the order of wires to cut, you need to solve one or two other modules first which hint at the order.
[QUOTE=Hoodiecraft;49673737]Sorry my internet went down and I hate navigating this website on mobile... any way it's being written in lua in the corona engine as a mobile game. brianosaur your getting it thankfully! there could be multiple wire modules, but there will only be 4 modules per bomb. each module is generated separately to the other modules.A solid pattern could be determined by a little bit of logic and process of elimination. Hard coding it is becoming the best answer but I really don't want to that cause its going to end up so inefficient! :P [/QUOTE] I honestly wouldn't worry too much about being efficient, and getting it "right" the first time. You can always refactor to a more efficient/optimal solution. There's trade-offs with different implementations. With each module, I would simply hardcode it. Why? Because your problem does not seem to be a "one-size-fits-all" kind of thing that a single algorithm can solve. Each module has a unique solution, so I would see no reason to ever (later on) go an change a module's hardcoded solution. If you wanted a different module and accompanying solution, just create a new module class/file and add it to a list of wiring modules that that will be attached to the bomb at runtime. Hardcoding itself would be an anti-pattern, but to me, it seems like the best solution in this case, in my opinion.
Okay I got it working how I want it to work copied a algorithm strangely enough from and old fantasy adventure book, ya know the ones where it's like if this is true go here. Thankfully there was a max of six paths so it worked perfectly and with a little logic the bomb can be easily defused. :) of course I'd forget how to close the thread XD
Sorry, you need to Log In to post a reply to this thread.