Forum
A place to discuss topics/games with other webDiplomacy players.
Page 666 of 1419
FirstPreviousNextLast
Enzyme (100 D)
16 Oct 10 UTC
Can someone explain what just happened?
New to the site, and I'm having some trouble interpreting the symbols/rules. I'm *NOT* looking for advice, just an explanation of what happened.
5 replies
Open
Le Masticateur (119 D)
15 Oct 10 UTC
Question About Retreating
I have a question regarding the rules of retreating. I'm new to this game and I didn't venture to read all of the threads, so I'm sorry if this topic was already reviewed.
5 replies
Open
basvanopheusden (2176 D)
16 Oct 10 UTC
a great gunboat game
To all in this game, well played.
3 replies
Open
fuzz (0 DX)
16 Oct 10 UTC
need 1 more like rite now
1 reply
Open
Z (0 DX)
13 Oct 10 UTC
Question for Programmers
Im making an array, and I insert a value at a point in the array, and any unused area is assigned a zero. eg [7,3] and each previous cell gets a zero. My question is how do i write a method that deletes the excess zeros, but keeps the value. Later on, ill have to have it delete zeros when i have information in the first, third, seventh cell etc, and the rest are filled with zeros.
Page 1 of 4
FirstPreviousNextLast
 
ava2790 (232 D(S))
13 Oct 10 UTC
Draugnar is asleep
fiedler (1293 D)
13 Oct 10 UTC
sounds like you are a beginner? is it a string array? if you are just using numbers, you should use a number data type for the array.
abgemacht (1076 D(G))
13 Oct 10 UTC
Let me make sure I understand the question:

You have an array of a certain size. You want to remove any zero entries, shrinking the size of the array?
Z (0 DX)
13 Oct 10 UTC
at fiedler, yes i am a beginner.

for abge. I dont want to shrink the size of the array, just be able to move the cells with actual data to the front but keep the array size the same. so after i call the method, i could enter another instance of data to cell 7 for example
fiedler (1293 D)
13 Oct 10 UTC
use a queue rather than an array?
Draugnar (0 DX)
13 Oct 10 UTC
The specifics would vary from language to language, but arrays are typically fixed in size, unlike collections (i.e. lists). Create a new array with the same size. Loop through the array and increment a counter every time you find a non-zero value and assign that value to the counter position in the new array. I'm assuming you are in VB here, so redim preserve the new array to the counter size. You now have a scaled down version of your array without any zero values.
Draugnar (0 DX)
13 Oct 10 UTC
Well, I just saw what you really want done and it just got easier.

Initialize a counter to 1 (or 0 depending on the language).

Check the array value at counter.
If it is non-zero loop through the array incrementing the counter until you find a zero value. This will get your first zero value.

Loop through the array starting at counter+1.
Every time you find a non-zero value, swap it with the zero in the counter position and increment the counter until you find a zero value.

This will result in pushing all the values to the front (or back if youy work backwards and decrement instead of increment).

Just remember to include checks in you counter loops so you don't exceed the end of the array.
stumerac (101 D)
13 Oct 10 UTC
You can just use a recursive loop to drain the values to the front of the array, if that is what you need.

drain(array)
{
for(each)
{
abgemacht (1076 D(G))
13 Oct 10 UTC
OK, here's the pseudo-code:

do i from 1 to size of array
if(a(i)==0)
do from j=i+1 to size of array
if(a(j)=/=0)
temp=a(i)
a(i)=a(j)
a(j)=temp
exit loop
endloop
peterwiggin (15158 D)
13 Oct 10 UTC
Goodness if I'd known it was homework help night I could have had some interesting problems . . . =)
abgemacht (1076 D(G))
13 Oct 10 UTC
argh, so much for tabs, but you get the idea.
Draugnar (0 DX)
13 Oct 10 UTC
What language is that, stumerac?
stumerac (101 D)
13 Oct 10 UTC
stupid forums are weird for my computer. I lose control of the keyboard sometimes.

drain(array[point])
{
for(each)
{
if ( array[i] does not equal 0 AND i does not equal maxArraySize )
drain(i +1)
else
i = i + 1
}
}

Or something like that. I bow to real programmers.
stumerac (101 D)
13 Oct 10 UTC
Late night half-inebriated language.
abgemacht (1076 D(G))
13 Oct 10 UTC
I hate recursive code. It's probably from that one time I had to code recursively in Assembly for an exam. Never got that bad taste out of my mouth.
bigworm (390 D)
13 Oct 10 UTC
That question still doesn't make any sense to me.
Draugnar (0 DX)
13 Oct 10 UTC
Eeeeeew! A recursive function. Blech!

Keeping the parallel counter is more efficient because you don't have to run an internal loop from I+1.

int curPos = 0;
for (int i=0; i < array.length; i++) {
if (array[i] != 0) {
while (curPos < array.length && array[curPos] != 0) {curPos++;}
array[curPos]=array[i];
}
}
Draugnar (0 DX)
13 Oct 10 UTC
Oops, I forgot to reset the value at i.

Right after:
array[curPos]=array[i];

add:
array[i]=0;
Draugnar (0 DX)
13 Oct 10 UTC
Found another bug, so here is the corrected version.

int curPos = 0;
for (int i=0; i < array.length; i++) {
if (array[i] != 0) {
while (curPos < array.length && array[curPos] != 0) {curPos++;}
if (curPos < i) {
array[curPos]=array[i];
array[i]=0;
}
}
}
fortknox (2059 D)
13 Oct 10 UTC
Recursion sure is pretty, but it is destructive to memory and only deserves to be in academia, not real life ;)

What problem are you solving that your array starts off with values in random places, and you need to shrink it? Are you hashing the values, then need to get the values? I've got a pretty OO way of doing this if you are against queues.
Draugnar (0 DX)
13 Oct 10 UTC
fortknox +1

That's why I said "Eeeeeew!" to his needless recursion. It has it's place, but not as a substitute for a simple "for next", "for each" or "do while" loop. If you need to traverse through containers and you don't know what depth they are at, recursion is the way to go, but not here.
Draugnar (0 DX)
13 Oct 10 UTC
Also, if you list what the purpose of the process is overall, we might be able to build a better solution for you.
fortknox (2059 D)
13 Oct 10 UTC
Here's java code I just whipped up (no good error checking, and very basic for the newbie), but since it isn't going to format right, I'll put it somewhere you can download it:
http://dl.dropbox.com/u/6076492/ArrayFun.java

The output looks like this:
--Start array
Array values: [0, 0, 3, 0, 0, 0, 7, 0, ]
--New array, initialized
Array values: [0, 0, 0, 0, 0, 0, 0, 0, ]
--New array, drained
Array values: [3, 7, 0, 0, 0, 0, 0, 0, ]
fortknox (2059 D)
13 Oct 10 UTC
That code, obviously, just does what you ask, but if I knew WHAT you were doing, I could give you a much more elegant solution (because it sounds like what you are doing shouldn't involve arrays).
Draugnar (0 DX)
13 Oct 10 UTC
But fortknox, you missed one of the requirements. He said " so after i call the method, i could enter another instance of data to cell 7 for example" which means it needs to be the same array or reload the array from your new one. My C# code does just that by just reorganizing and processing one array. I'll take a few moments and transfer it into a command line program in VS with the instantiation code and post the results here.
fortknox (2059 D)
13 Oct 10 UTC
What's wrong with reassigning the pointer?
array = newArray;
fortknox (2059 D)
13 Oct 10 UTC
I was just trying to simplify it as much as possible for the newbie so it wasn't hard to read. You are basically writing almost a sorting algorithm, which he should start to understand, but may be a bit beyond him (just an assumption on my part)
Draugnar (0 DX)
13 Oct 10 UTC
OK, back from my meeting. Let me sit down and throw together a working C# example of my algorithm.
Draugnar (0 DX)
13 Oct 10 UTC
Start
array [ 0, 0, 3, 0, 0, 0, 7, 0]

Drained
array [ 3, 7, 0, 0, 0, 0, 0, 0]

I'll find some place to post the code up and post the link here.
Draugnar (0 DX)
13 Oct 10 UTC
www.draugnar.com/Program.cs

Page 1 of 4
FirstPreviousNextLast
 

93 replies
curtis (8870 D)
15 Oct 10 UTC
gunboat live
7 replies
Open
Dpddouglass (908 D)
14 Oct 10 UTC
New public game, 150 pts, 3 day turns
http://webdiplomacy.net/board.php?gameID=39976
1 reply
Open
President Eden (2750 D)
15 Oct 10 UTC
HEY JACKASS, VOTE DRAW
In case you missed it the first couple times. You cannot advance past the stalemate line, you're not doing anything to try, so stop dragging the game out and vote draw. For the bystanders: http://webdiplomacy.net/board.php?gameID=40053#gamePanel
20 replies
Open
Stenrosen (1110 D)
15 Oct 10 UTC
Bug?
In this game (http://webdiplomacy.net/board.php?gameID=39585) Oz retreated a fleet from Dumont dUrville to Vostok (in spring 2003, retreats). It seems like a bug to me, but please enlighten me...
3 replies
Open
penguinflying (111 D)
15 Oct 10 UTC
Signaling in gunboat games?
Can someone please explain any standard conventions that exist for signaling in gunboat games? Like...I think ordering a support hold to someone else's unit must mean something, but I'm not sure what.
8 replies
Open
Fear Rua (133 D)
14 Oct 10 UTC
Moves saved or ready
Hi, another newby question. If you have moves saved but not ready when the movement phase ends, will these moves be implemented, or will you be treated as having not entered any moves?

Is there any help page that explains how the webdiplomacy interface works, as opposed to the rules of the game? All I can find are the FAQ, the introduction, and the rulebook, none of which provide many details of this.
6 replies
Open
peterwiggin (15158 D)
15 Oct 10 UTC
linux help?
In light of recent tradition . . .
6 replies
Open
Thucydides (864 D(B))
15 Oct 10 UTC
Remember my diplomacy club idea?
I just wanted you blokes to know that it's actually happening, I've been approved.
5 replies
Open
Iceray0 (266 D(B))
15 Oct 10 UTC
Fuck yea
I haven't played a game in forever and i've gone from barely breaking the top 40% to being in the top 30%
I am a badass. It's not due to new members, it's 100% badassness.
3 replies
Open
eaglesfan642 (0 DX)
12 Oct 10 UTC
Please join
Please join http://webdiplomacy.net/board.php?gameID=39922
75 bet
World diplomacy
2 replies
Open
Lando Calrissian (100 D(S))
14 Oct 10 UTC
Live Games Tonight
Is there any interest in a high-ish pot live gunboat tonight? I'd set up a game and make it password protected. I'm thinking maybe 50 yen buy-in. Reply or message if this interests you.
1 reply
Open
mapleleaf (0 DX)
09 Oct 10 UTC
read ZEITOUN...
...if you haven't read it already. It's by Dave Eggers.
2 replies
Open
Tom Bombadil (4023 D(G))
14 Oct 10 UTC
New 101d WTA anon game
36 hour phases. All press. Join up!
2 replies
Open
hopsyturvy (521 D)
14 Oct 10 UTC
Server errors
for info, *not* a moaning thread.
5 replies
Open
no pants (100 D)
13 Oct 10 UTC
StP bug?
see post
8 replies
Open
Thucydides (864 D(B))
12 Oct 10 UTC
Personal Philosophy
A this risk of appearing egotistical... I would like to share with you guys something I wrote.
33 replies
Open
Conservative Man (100 D)
13 Oct 10 UTC
What did I do wrong on this math problem?
I'm trying to find the equation of a parabola by using 3 of its points. The points are (1,6) (3,26) and (-2,21). I'm trying to find the form y=ax^2+bx+c. I worked out a to be 2.5, but the book says it is 3. You can find my work inside.
45 replies
Open
stratagos (3269 D(S))
14 Oct 10 UTC
ARARUGH!
I HATE MISORDERS!

That is all. The EOG comments on this one are going to be fucking *Fascinating* to read, when everyone asks WTF I was thinking
1 reply
Open
obiwanobiwan (248 D)
10 Oct 10 UTC
I am REALLY Losing Faith...
I am rapidly lost my faith in democracy--living through it the last decade plus, from the last couple disgraceful years of Clinton to Bush II's Regime to Obama's Bust (AND Ahnuld and our near-last education, jobs, etc. in CAL) right here in my home state, I now think maybe Plato was right...and Hobbes...I'm not advocating for "1984" or an Emperor or Reich here, but...well, all this bickering and I see FAR more hurt and waste than good...discuss?
126 replies
Open
stratagos (3269 D(S))
14 Oct 10 UTC
Whoo hoo, you go Chile!
You guys have one hell of a country - I can't see us in the states being able to pull off what you guys did anywhere *near* as smoothly. You should be *damn* proud of the bar you've set for the rest of us screwed up, selfish nations when it comes to caring about our citizens.
18 replies
Open
obiwanobiwan (248 D)
10 Oct 10 UTC
Give The Title Of Your Autobiography
Simple enough--one sentence, give a fitting title of your autobiography if you were to write it today.
57 replies
Open
jman777 (407 D)
13 Oct 10 UTC
Who Took The PSAT Today?
Did anyone here take the PSAT today? I did and had form W. It wasn't that bad except for the fact that I messed up some formulas.
8 replies
Open
baumhaeuer (245 D)
25 Aug 10 UTC
Experament
Details inside.
201 replies
Open
omgwhathappened (0 D)
14 Oct 10 UTC
Spring 1903
gameID=39477

need a replacement austria. has 6 centers, and no one is currently aggressive. italy, germany and england are fighting france, and austria is not under fire from either russia or turkey. good set up, and we'd like a replacement for the guy who JUST left.
2 replies
Open
Conservative Man (100 D)
09 Oct 10 UTC
Am I crazy?
See inside
75 replies
Open
Page 666 of 1419
FirstPreviousNextLast
Back to top