Randomly generated dungeon with Python [closed] - python

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 7 years ago.
Improve this question
I'm trying to figure out how to create a completely random maze/dungeon for a small text game I'm working on. I'm really not sure where to start since I've never done anything like this before. How do I do this? I need the rooms to know what mobs it holds, what items are on the ground, where the exits are and what other rooms they go to. Any help is appreciated.

You can make an 2 dimentional int array (your map). Each "object" such as an item or exit gets another number.
for example:
0 = no object
1 = knife
2 = sword
3 = helm
When you need to make it posible to combine objects on one field (for example put an sword and an helm on one field) you can create an 3d array. So you can add an object on top of another object.
You can generate and random x and y whitin your array dimentions and give this an random number within your object scope (in this example between -1 and 4)
Hope this helps ;-)

Since this is a very broad question I will just give you a general answer. You are probably going to want to make a new class that will contain the data for a room. In this class you could have variable that could store randomly generated numbers (using the random module) and then have methods use those numbers to determine the layout, monsters, and items in each room. All you would then have to do is to have a 2D or 3D grid (probably using lists of the room class) and randomly fill the grid with rooms that each contain random data.

Related

PyOpenGL camera system [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 4 years ago.
Improve this question
I'm confused on how the PyOpenGL camera works or how to implement it. Am I meant to rotate and move the whole world around the camera or is there a different way?
I couldn't find anything that can help me and I don't know how to translate C to python.
I just need a way to transform the camera that can help me understand how it works.
To say it bluntly: There is no such thing as a "camera" in OpenGL (neither there is in DirectX, or Vulkan, or in any of the legacy 3D graphics APIs). The effects of a camera is understood as some parameter that contributes to the ultimate placement of geometry inside the viewport volume.
The sooner you understand that all that current GPUs do is offering massively accelerated computational resources to set the values of pixels in a 2D grid, where the region of the pixels changed are mere points, lines or triangles on a 2D plane onto which they are projected from an arbitrarily dimensioned, abstract space, the better.
You're not even moving around the world around the camera. Setting up transformations is actually errecting the stage in which "the world" will appear in the first place. Any notion of a "camera" is an abstraction created by a higher level framework, like a third party 3D engine or your own creation.
So instead of thinking in terms of a camera, which constrains your thinking, you should think about it this way:
What kind of transformations do I have to chain up, to give a tuple of numbers that are called "position" an actual meaning, by letting this position turn up at a certain place on the visible screen?
You really ought to think that way, because that is what's actually happening.

Comparing two images - python, openCV [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 4 years ago.
Improve this question
Which is the best way to compare two images from same domain, different features in python. Histogram or Image quality functions ?
I have two images for different scenes, the contents inside the images are different, but both of the images are taken during morning.
I want to compare how much these two images are related to each other ?, like my important metric, is to say that these two images were taken during morning for example, even if different contents.
Any idea or way how to do this ?
There is no easy answer to your question. It depends on how do you consider images similar or different. And this is a subjective measure that is totally dependable on what do you want to do with this information.
Anyway, for this kind of problems, opencv is your friend. Here I list some ideas:
use histograms: cv2.histogram https://docs.opencv.org/3.1.0/d1/db7/tutorial_py_histogram_begins.html
with histograms you can know how blueish, greenish or redish an image is. You can compare if 2 images are in the same range (bin) of a specific color. This is something very common when you want to detect skin color.
if you have an specific object that appears in different images, use SIFT or SURF.

Pygame - How to detect if sprites are in area? [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
I need a way to get a list of all sprites in a certain area of the screen, and I cannot find one anywhere on the internet.
Can someone please give me an example code of how to do this?
If it helps, all the sprites are in an "active" list.
Depends on whether you have obstacles or not, i.e. what the definition of "In the Area" means and also home many sprites you are dealing with.
If there's not many sprites and the distance calc is fast then brute force is probably ok.
for sprite in sprites:
if something.distance(sprite) < THRESHOLD:
do_something_with_near_sprite(sprite)
If you have a lot of sprites have a look at quadtrees and things like that. If calculating the distance is complicated then you're probably going to want to look at A* algorithm. There are libraries for these things so you shouldn't have to implement them yourself unless you want to.
This is a pretty general question (prepare to have it voted down by others :)

Python board game grid [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 8 years ago.
Improve this question
I need to make a simple board game for school in python it has to have a grid sort of like a chess board individual spaces where the character can stand. But I have no idea how, we are not allowed to download anything since it's school computers. Also I need to make the character move. I just need this is the most simple form. The example the book gave us looked like this:
..........
..P.......
..........
..T.......
....T.....
..........
..T.......
..........
.........X
P is the player, T is a trap and X is the treasure. I don't need it exactly like that I just need a board like that and how to make the player move on it.
As this question is not very precise the answer can't be as well; but maybe there are some general hints:
-think about how to store the positions of the elements on the boards (lists (-> lines of the game) might be a good start)
-think about what it means to move the figure (taking the list approach this means you can increment or decrement the position in the list or switch to another one)
-think about how you could see that the player has fallen in to a trap/won (check if a position is already acquired before moving the figure)

How to find if player surrounded enemy's cells [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
I am making simple game. (A matrix where players can take cells(x,y), only one player on one cell, and they acquire new cells after the player before). Every player has a unique color. I am trying to find out if one player has surrounded cells of other users. In which case all cells are going to change color. Is there any known algorithm for this problem, to check only when user plays a new move ?
I would suggest that you take a look at a flood fill algorithm, these are simple algorithms that searches from a start point and tries to fill the board. You would simply have to check if the fill algorithm can reach the end of the board or not.

Categories