wc3edit.net

United Warcraft 3 map hacking!
It is currently March 28th, 2024, 11:41 pm

All times are UTC




Post new topic Reply to topic  [ 16 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: January 6th, 2012, 9:47 pm 
Offline
Super Moderator

Joined: February 3rd, 2009, 11:28 pm
Posts: 2394
If I remember correctly, arrays start at 0, so player[3] is actually 4 players.

If I understand the problem you posted below correctly..
In your pool of random names, when a name is selected, set the value to "" (empty string) and if an empty string is selected you re-roll.

Ex:
playername[0] = "some name 1"
playername[1] = "some name 2"
playername[2] = "some name 2"

Math.Random gets 0.
Now the array looks like this.

playername[0] = ""
playername[1] = "some name 2"
playername[2] = "some name 2"

Math.Random gets 0, and re-rolls and gets something else.

Don't really get your second problem. But use a trigger to set the name of the player, and it remains consistent through the whole game.


Top
 Profile  
 
PostPosted: January 7th, 2012, 12:32 am 
Offline
Newcomer

Joined: November 15th, 2011, 1:02 am
Posts: 3
Hello, owner123. Thank you for the swift reply.

Not exactly sure if this hits the mark. I'm a bit of confused, but I will try to understand this more. Empty string returns are pretty much even new to me at this junction.

Well, to make it clear, it's like this:

I have a list of 5 names. I have 3 players.
The 5 names are: {John, Tim, Mark, Dick, Harry}

Now, I will create an array of 3 players. Once each player is created, they will pick a name before they enter the game.
Nameless Player 1 gets to pick Dick. Now, I don't want Dick to be selected by Player 2, so he'll choose from the four remaining ones.
Player 2 gets Tim. Now, I don't want Player 3 to be either Tim or Dick. And so on and so on.

This is what's a little complicated. I know there's a solution somewhere down the line, but I'm modifying code to fit what I've learned so far. And so far, I've basically only learned loops, conditions, class calling, and arrays. Basically, the first four chapters of Head First to Java (and some borrowed ideas from Thinking in Java).

As for the second problem, it's actually pretty easy (and simple). I was thinking that as long as the game continues, the players would have to choose names again and again. Moving the block of names from the while() loop eliminates the repetition of finding players.

If anyone would want to check it out, I can e-mail or post the codes for the GuessGame, GameLauncher, and the three Player classes. :/


Top
 Profile  
 
PostPosted: January 7th, 2012, 12:57 am 
Offline
Super Moderator

Joined: February 3rd, 2009, 11:28 pm
Posts: 2394
An empty string is basically just nothing. A quote and then an end quote. In wc3edit.net, looks like this.
Code:

If Player 1 chooses the name "Dick" (aka the 4th available player name) then you set PlayerNameArray(3) to empty string (aka nothing)
This is because arrays start at 0. So:
PlayerNameArray(0) = "John"
PlayerNameArray(1) = "Tim"
PlayerNameArray(2) = "Mark"
PlayerNameArray(3) = "Dick"
PlayerNameArray(4) = "Harry"

Now in your procedure for choosing names put the condition:
If the name being chosen by the user is equal to an empty string, then ask the user to re-choose.

Empty String on wikipedia: http://en.wikipedia.org/wiki/Empty_stri ... _Languages


Top
 Profile  
 
PostPosted: January 7th, 2012, 1:08 am 
Offline
Newcomer

Joined: November 15th, 2011, 1:02 am
Posts: 3
Hello, owner123!

Thank you! This one is a bit clearer. Pardon me for not getting it faster. Of course, if the value matches, and if I use an if() block, it has to run again and search for a name. Will try it out right now. I will update in a few hours or so. :)


Top
 Profile  
 
PostPosted: March 3rd, 2012, 9:29 pm 
Offline
Senior Member
User avatar

Joined: June 17th, 2009, 11:31 pm
Posts: 121
Title: Assassin
just go and start doing problems, ex. projecteuler in ANY language. it's better than spending time questioning what is the best.
if you really want to do something practical: http://www.stephenfrasier.com/blog/tech ... xt-decade/

Java is slow but has libraries and is used alot in mobile devices.


Top
 Profile  
 
PostPosted: March 4th, 2012, 2:35 am 
Offline
Forum Drunk
User avatar

Joined: January 17th, 2007, 4:22 pm
Posts: 2903
Location: Darmstadt, Germany
I beg to differ, Java isn't slow. (Look at the Jake2 benchmarks for example, a Quake2 port) It eats memory like a small memory eating animal though.

_________________
Don't pm me with Warcraft questions, this is a forum so just make a post!

In the world of thinking we are all immigrants. -Robert Nozick


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 25 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

phpBB SEO


Privacy Policy Statement
Impressum (German)