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 developing this for Bukkit, but I am open to porting a java-only solution.
Now, I have a character in a room with an opening exposed to the outside for radiation to seep in like this:
(sorry for terrible paint skills) In this picture the algorithm should return false, however if that white bit was covered, it would return true.
I need a way of detecting whether the character is inside a room or not. Please remember that a room can be any size, and does not have to be a cuboid.
The way I'd like it to work is that I'd have an arbitrary position above the roof, and if this maze algorithm would be able to reach this position, I'd know that the character is not completely covered.
EDIT: Actually if the exit was 20+ units away, I wouldn't mind the algorithm timing out.
This is not an answer per se, but it may be a good point to move on from.
The definition for room:
a part or division of a building enclosed by walls, floor, and
ceiling.
The definition for building:
a structure with a roof and walls
The definition of a structure:
a building or other object constructed from several parts
Can you see how poorly defined these are? (The definitions for building and structure are recursive!) Until you can come up with a clear cut, black and white definition for what you consider to be a room, you (and us) have very little hope of coming up with a good solution.
Related
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 3 years ago.
Improve this question
I got involved with some folks making a new 2D game engine in Java, and I got curious when I learned they avoided using any variation of Graphics.create in their engine's code.
When asked, they said they feared making copies of Graphics for every graphical component seemed like "(...)quite some amount of overhead."
But they could not provide any proof of the claim. Instead of making use of the clipRect and translation properties of Graphics, they instead provide their own support API for drawing in the right place.
I'm not a part of their team, but I do use their unfinished engine in my own project, so I want to find out.
Looking for an answer myself resulted only in a brick wall. The Graphics class is abstract, and I have so far not found any implementation code. So I can't find the answer.
And so I end up asking here.
What performance/memory cost if any, is there for using the Graphics.create() function?
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 6 years ago.
Improve this question
I'm a beginner in Java and programming but I'm already creating a Texas Hold'em Poker game as a "practice and learn" project.
I know the rules of the game, but I'm not sure how to include bots or computer player that can decide when to go in and when to quit, how much to bet (including All-in bet),and if possible even to bluff from time to time.
At this point my question is:
Should I take an effort to "explain with if's and then's, when to do that or is there an algorithm that allows the bot player to do that?
If it exists, would that algorithm be specific for poker or is possible to reuse it to any game to allow the computer to "learn" the rules described in the programming, for different rules or even different games (so it applies to chess or monopoly, etc)?
The complexity and state space of the Poker is not large. Therefore it is possible to just exhaustively search all the combinations. In fact you can even calculate the probability of getting each cards with some arithmetic. I would recommend you to read Poker Theory and Analytics by Kevin Desmond on MIT Open Courseware to understand more.
Your idea is exactly what decision trees or random forests are. They are machine learning techniques that can build human-understandable rules with a tree of if-s.
On the other hand, there are also non-human-understandable machine learning. Neural network is a kind of that. The models are non-intuitive to human. They are mainly used for the problems that are hard to formulate or with extremely large state space, for example, playing Go (just like AlphaGo), identifying all the objects in an image, or how to win Starcraft.
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 9 years ago.
Improve this question
I'm currently doing a project where I want to randomly generate mazes for a game. After studying performance levels etc for maze generation I've decided to use the Recursive Division method. Whilst the explanation of the algorithm is somewhat understandable I'm struggling to formulate the algorithm in a pseudo format so that I can understand it fully and begin coding it. Can someone help me with a detailed explanation of the process or some pseudo-code? All help is greatly appreciated.
EDIT: From what I understand I will need to decide whether to divide horizontally or vertically. How is this decision made and what is the process of this division with regards to starting point and finishing point?
Begin with an empty field.
Bisect the field with a wall, either horizontally or vertically. Add a single passage through the wall.
Repeat step #2 with the areas on either side of the wall.
Continue, recursively, until the maze reaches the desired resolution.
Jamis Buck on Maze Generation: Recursive Backtracking
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 9 years ago.
Improve this question
Ok I gave been playing around with java for a year now an I can say that is is in my power to write a fully functional program.
A month ago I started studying vectors and so, when I tempted to implementing them into the LWJGL I realized that Java is not fast enough for the level of graphics that I wish to generate.
Now that is my problem and I have decided that I must learn a stronger Language but where do I begin I have tinkered around in C/C++ before but it kills my ambition to go and start over after already using a hole year.
my "algors" for rendering a vector are:
z = r(cos t+j sin t) //where the t is degrees and r is its length
(for the curious)
the program the continues a loop that alters its length with 1, gets its end X and Y and draws a pixel on that spot.
Not for game coding.
Name 1 free E-Book that will get Me on My feet with C
I realized that Java is not fast enough for the level of graphics that I wish to generate.
Java is plenty fast. Unless you want to work with high performance graphics, you can use it safely (and you will probably be able to use it even with high performance graphics).
In the vast majority of cases, the speed of your application will be a function of algorithmic complexity, not language used.
After your application is completed, if it doesn't run fast enough, you can optimize. If it still doesn't run fast enough, you can implement critical parts in C/C++/your-language-here.
If you start from "the language is not fast enough", you're already doing it wrong.
If you want to write a game, use an engine. There are many great engines in many languages. If you wonder about language-inherent performance, and you try to solve technological issues yourself, you are gonna be stuck doing that forever.
Do not reinvent the wheel. Stop worrying about which programming language is the best fit, and rather think about which engine is best suited for what you want to make.
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'm into a project of a resource-game simulation. What I have to do is...
"If there are enough resources available, the request will be satisfied, and the requested quantities will be subtracted from the available quantities. If there are not enough resources, the animat consumes the available quantities and wait for more resources to be available."
The question is how do I make this possible... To reduce the resource and then hold somewhere what is still needed and reduce it when there are available resources(like a loan)...
Example:
... 100 GOLD NEEDED.... but ... 50 GOLD AVAILABLE...
... REDUCE GOLD BY 50... and wait untill gold>=50 and then
... REDUCE GOLD BY 50...
etc...
Sample Code...
public void feedArmy(){
if(food>=100){
food=food-100;
System.out.println("*Feed Soldiers (-100 Food)");
System.out.println(toString());
}
else{
System.out.println("*Feed Soldiers (-100 Food)");
System.out.println("-Not Enough Food!"); //get loan instead
}
}
(After Edit)
BEST SOLUTION FOR NOW:
Actually ... I thought of just reducing the wanted value from the wood and then if the number goes negative I keep the negative value turn it to positive with
Math.abs();
so if the wood is 30 and I want 100... I do 30-100=-70; then loan=-70; ...
then I Math.abs(loan); so that loan=70;
and then I do an if(wood>loan){ wood=wood-loan} //i might need to put a sleep untill wood is refreshed again... and thats it...
I still have no idea what is that Producer/Consumer stuff...
So the solution you are looking for is well known and much studied in computer science. The problem itself is called the Producer Consumer problem. Do a search for this and you will find numerous examples and code to solve the problem.
Here is a stackoverflow question about it, Producer/Consumer threads using a Queue.
Wikipedia page explaining the problem in detail.
Consider creating an unfulfilled request object; just resource type and outstanding amount. Then add one to an arraylist every time one of these debts needs to be raised. Then every game loop (how ever you are implementing that in your game) check through the unfulfilled list and debt the resources if you can