wc3edit.net
https://forum.wc3edit.net/

[General Query] Programming languages.
http://forum.wc3edit.net/general-chat-f7/programming-languages-t23454-10.html
Page 2 of 2

Author:  owner123 [ January 6th, 2012, 9:47 pm ]
Post subject:  Re: [General Query] Programming languages.

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.

Author:  Jome [ January 7th, 2012, 12:32 am ]
Post subject:  Re: [General Query] Programming languages.

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. :/

Author:  owner123 [ January 7th, 2012, 12:57 am ]
Post subject:  Re: [General Query] Programming languages.

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

Author:  Jome [ January 7th, 2012, 1:08 am ]
Post subject:  Re: [General Query] Programming languages.

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. :)

Author:  ilovepie [ March 3rd, 2012, 9:29 pm ]
Post subject:  Re: [General Query] Programming languages.

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.

Author:  Dekar [ March 4th, 2012, 2:35 am ]
Post subject:  Re: [General Query] Programming languages.

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.

Page 2 of 2 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/