How to make snake game with random walls appearing? [closed] - algorithm

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I almost wrote a snake game, but I still can’t get one of the main ideas.
I would like for random walls to appear on the map during the game, as it happens in google snake game in wall mode. Here is the link to game.
My question is only about the idea of ​​the algorithm and it's disconnected from a specific programming language.
The problem is that absolutely random walls could create “unreachable” places in the level, such as enclosed spaces, where the snake could not get theoretically. So how to check such "unreachable" places on a level and not create incorrect walls?
PS: Sorry for my poor English.

Just do a google search for the "A*" Algorithm. The head of the snake is your starting point, the apples your end point and the walls your obstacles. (of course you would have to think about, how to get around the problem of interfering with your tail)

Related

How to create random incongruous shapes that don't overlap each others in P5.js [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm looking to create shapes like this :
https://www.lucegallard.com/?lightbox=dataItem-isiz1h39
But they have to be generated at random and never overlap. It would be too easy to just use beginShape() and curveVErtex(x,y), etc.
Plus the result would we static, it needs to be changed easily and randomly. My question is "is there a function to create 'weird' ellipses?" or "Could anyone help me with an algorithm to achieve this?"
Thanks allot in advance!
Stack Overflow isn't really designed for general "how do I do this" type questions. It's for specific "I tried X, expected Y, but got Z instead" type questions. But I'll try to help in a general sense:
You need to break your problem down into smaller pieces and take those pieces on one at a time. Try to create a program that just generates a single random shape. Then try to add a second randomly-generated shape that doesn't intersect with the first shape.
Think about how you would describe this program to somebody who can't see the website you've linked in your post. Try to describe it in as much detail as you can. Pretend you have a friend who has never seen what you're talking about. Can you write down a set of steps that this friend could follow to draw what you're talking about? When you have those steps written down, that's an algorithm that you can start thinking about implementing with code.
A simple check would be for each new point you generate, check whether it's inside any previous shapes. If so, go back and pick a different new point. That will at least get you started going in a direction.
If you get stuck, please post a MCVE along with a more specific technical question. Good luck.

Algorithm for finding similar words [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
In order to support users learning English, I want to make a multiple-choice quiz using the vocabulary that the user is studying.
For example, if the user is learning "angel" then I need an algorithm to produce some similar words such as "angle" and "angled"
Another example, if the user is learning "accountant" then I need an algorithm to produce some similar words such as "accounttant" and "acountant", "acounttant"
You could compute the Levenshtein Distance from the starting word to each word in your vocabulary and pick the 2 or 3 shortest ones.
Depending on how many words are in your dictionary this might take a long time though, so I would recommend bailing out after a certain (small) number of steps - i.e. if you have made 3 mutations and still haven't arrived at your target word then stop and move on to the next one.

Why trees are structured from up to down not as real trees the root is first to the ground? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Why trees are structured downward not as real trees the root is first to the ground?!
It is because you dont know before hand how hight it can grow when writing on paper.
Suppose you are explaining this problem to someone with an array, and you start drawing, you will need to know how much space to leave on a paper before beginning to draw.
This also has the problem in online publishing where user will need to scroll down, a lot, for a really complex tree to get to the root of a tree to understand the tree. Writing the root at the top solves this problem as well.
Maybe i think because human beings start writing on papers and sheets at the top.

What is the algorithm behind photoshop's quick selection tool? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
The community reviewed whether to reopen this question 7 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I work on image processing. I just saw the quick selection tool of photoshop and I was quite impressed to see that this tool was capable to segment images along real edges, most of the time.
I could imagine two or more ways of doing what that tool does:
starting with an edge detector (say Canny), with adapted parameters I would just get the connected region (maybe after some dilate, then compensating with some "open" operation on the segment).
Doing watershed algorithm with additional boundary constraints, virtually sth like surface tension.
But maybe Im wrong.
I plan to implement a similar segmentation algorithm, so I'm interested in an idea description (like my two guesses). Can you point me to the right direction?

Algorithm for creating infinite terrain/landscape/surface? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Does any have an algorithm for creating infinite terrain/landscape/surface?
Constraints
The algorithm should start by a random seed
The algorithm should be one to one, (the same seed gives the same result)
Other input parameter are allowed as long as 2 is fulfilled
The algorithm may output a 2d map
It suppose to create only surface with varying height (mountains), not three, ocean etc.
I’m looking for an algorithm and not a software.
It should be fast
None of other related questions in here answers this question.
If anything is unclear please let me know!
I would suggest something like Perlin noise, I've used it before for something like you're describing above, and it fits the bill. Check out this Example and you can see the sort of output you would expect from the noise generator.Here is a link to algorithm p-code too.
http://freespace.virgin.net/hugo.elias/models/m_perlin.htm
As others already said perlin noise is a possibility. Gpugems 3 has a nice capter about procedual generation using (IIRC, it has been some time since I read this) 3D Perlin noise.
Of course there are other methods too, e.g. Vterrain.org might be worth a look.

Resources