467,140 Members | 1,377 Online

# Looping through variable number of arrays variable times?

 I will be passing my function a two dimensional array of varying length. Within that array is one data point, and the number of times it should loop through. So, for example, I might pass this to the function: example = new Array("A",2); example = new Array("Q",4); function loopIt(example); The function will then do the following: function loopIt(example) { for (x1 = 0; x1 < example; x1++) { for (x2 = 0; x2 < example; x2++) { calculateArray = new Array(example.length); calculateArray = new Array(example,x1); calculateArray = new Array(example,x2); calculate(calculateArray); } } } But loopIt() doesn't know what example.length will be. Here I showed example.length = 2. But if example.length = 41, this function wouldn't work. How can I create a loop like this when example.length will vary? Thanks! Mike Oct 22 '05 #1
• viewed: 2258
Share:
27 Replies
 Mike P wrote: example = new Array("A",2); example = new Array("Q",4); function loopIt(example); The function will then do the following: function loopIt(example) { for (x1 = 0; x1 < example; x1++) { for (x2 = 0; x2 < example; x2++) { calculateArray = new Array(example.length); calculateArray = new Array(example,x1); calculateArray = new Array(example,x2); calculate(calculateArray); } } } But loopIt() doesn't know what example.length will be. Here I showed example.length = 2. But if example.length = 41, this function wouldn't work. How can I create a loop like this when example.length will vary? That means that your array elements are going by pairs: example[i] gives you the value for external loop, example[i+1] gives you the value for internal value. So there is no way your array may contain an odd amount of elements. Is it correct? Oct 22 '05 #2
 "VK" wrote in message news:11**********************@o13g2000cwo.googlegr oups.com... That means that your array elements are going by pairs: example[i] gives you the value for external loop, example[i+1] gives you the value for internal value. So there is no way your array may contain an odd amount of elements. Is it correct? With the code sample, the "example" array can contain 1 to 41 elements (even or odd), but each array within it will be 2 long. So: example.length = 0 to 41 elements, and any integer inbetween (even or odd) but example[x].length will always = 2 where example[x] will always contain a string and example[x] will contain an integer between 0 and 8 If I were to code this a long and ugly way, I could create a switch based on example.length like this: function loopIt(example) { switch(example.length) { case 1: for (x1 = 0; x1 < example; x1++) { calculateArray = new Array(example.length); calculateArray = new Array(example,x1); calculate(calculateArray); } } break; case 2: for (x1 = 0; x1 < example; x1++) { for (x2 = 0; x2 < example; x2++) { calculateArray = new Array(example.length); calculateArray = new Array(example,x1); calculateArray = new Array(example,x2); calculate(calculateArray); } } } break; case 3: for (x1 = 0; x1 < example; x1++) { for (x2 = 0; x2 < example; x2++) { for (x3 = 0; x3 < example; x3++) { calculateArray = new Array(example.length); calculateArray = new Array(example,x1); calculateArray = new Array(example,x2); calculateArray = new Array(example,x3); calculate(calculateArray); } } } break; } } So on, and so forth up to case 41, but that seems excessively inefficient. I'm hoping there's a cleaner way to accomplish this. do you follow? I imagine there's some way to do this with a recursive array or dynamically creating the function (ala, new Function)... I just don't really understand how to go about it. Thanks for your help on this! Mike Oct 22 '05 #3
 > I imagine there's some way to do this with a recursive array or dynamically creating the function (ala, new Function)... I just don't really understand how to go about it. Well, using runtime generated function: Test I would not say that it's any less ugly than 41 case, but definitely shorter. :-) I guess any math prof would kill me for the above. The total amount of loops is factorial of [i] values in your array. It's a strong hint that the problem could be solved in some nice and profoundly academical way using recursions. But it requires good matrix math knowledge more than any JavaScript skills. The last of fine by me, the first is floating miserably :-( It works any way... Oct 22 '05 #4
 Wow... very cool! You rule! I'm going to have to study that a bit to figure out how you did it. Thanks again! Mike "VK" wrote in message news:11**********************@g47g2000cwa.googlegr oups.com... I imagine there's some way to do this with a recursive array or dynamically creating the function (ala, new Function)... I just don't really understand how to go about it. Well, using runtime generated function: Test I would not say that it's any less ugly than 41 case, but definitely shorter. :-) I guess any math prof would kill me for the above. The total amount of loops is factorial of [i] values in your array. It's a strong hint that the problem could be solved in some nice and profoundly academical way using recursions. But it requires good matrix math knowledge more than any JavaScript skills. The last of fine by me, the first is floating miserably :-( It works any way... Oct 22 '05 #5
 VK wrote:I imagine there's some way to do this with a recursive array or dynamicallycreating the function (ala, new Function)... I just don't really understandhow to go about it. Well, using runtime generated function: [...] I would not say that it's any less ugly than 41 case, but definitely shorter. :-) I guess any math prof would kill me for the above. The total amount of loops is factorial of [i] values in your array. It's a strong hint that the problem could be solved in some nice and profoundly academical way using recursions. But it requires good matrix math knowledge more than any JavaScript skills. The last of fine by me, the first is floating miserably :-( It works any way... There *had* to be a better way. This bugged me for hours, here's one that may do the job better and could be considered 'better' - it iterates through the first array of arrays and keeps splicing in elements. I think the use of concat() and splice() may restrict it to JavaScript 1.2 browsers and newer. The function copyA() copies a 1D array, it shouldn't be used with 2D (or more) arrays. I can think of a faster way - go through the first set of loops for the first loop (A), then just copy those for every subsequent loop. But I'll leave the implementation up to the OP. The result is a 2D array: -- Rob Oct 24 '05 #6
 RobG wrote: [...] I can think of a faster way - go through the first set of loops for the first loop (A), then just copy those for every subsequent loop. But I'll leave the implementation up to the OP. This one is a bit faster and a lot tidier, it uses concat to copy the array instead of copyA, everything is in one function. Loopy stuff
[...] -- Rob Oct 24 '05 #7
 Mike P wrote: I will be passing my function a two dimensional array of varying length. Within that array is one data point, and the number of times it should loop through. So, for example, I might pass this to the function: example = new Array("A",2); example = new Array("Q",4); function loopIt(example); The function will then do the following: function loopIt(example) { for (x1 = 0; x1 < example; x1++) { for (x2 = 0; x2 < example; x2++) { calculateArray = new Array(example.length); calculateArray = new Array(example,x1); calculateArray = new Array(example,x2); calculate(calculateArray); } } } But loopIt() doesn't know what example.length will be. Here I showed example.length = 2. But if example.length = 41, this function wouldn't work. How can I create a loop like this when example.length will vary? Thanks! If I have understood the problem correctly, here is a further addition to all the other contributions - a method using recursion:- function LoopIt(e) { this.example=e; this.exampleLength=e.length; this.indexArray=[]; this.recurse(0); } LoopIt.prototype.recurse=function(n) { if (n
 "RobG" wrote in message news:JP******************@news.optus.net.au... This one is a bit faster and a lot tidier, it uses concat to copy the array instead of copyA, everything is in one function. RobG, et al, I'm glad to know this was an interesting intellectual challenge to even the pros... I was completely stumped. I'll play around with the different approaches (run time compile, join/concat, and recursive object function) to figure out, not only which I'll actually use, but to learn how they work. Thanks again, to all! Mike Oct 24 '05 #9
 Mike P wrote: "RobG" wrote in message news:JP******************@news.optus.net.au... This one is a bit faster and a lot tidier, it uses concat to copy the array instead of copyA, everything is in one function. RobG, et al, I'm glad to know this was an interesting intellectual challenge to even the pros... I was completely stumped. I'll play around with the different approaches (run time compile, join/concat, and recursive object function) to figure out, not only which I'll actually use, but to learn how they work. Thanks again, to all! Mike Hey, just for the record, here's a recursive version (sorry, couldn't help myself, this just kept popping into my brain!). var A = [['Q',2],['A',4],['B',3]]; function recA(X, i, B) { var i = i || 0; if (!B) B = [[]]; var root = B[B.length-1].concat(X[i]); var loops = X[i]; for (var j=0; j
 RobG wrote: Mike P wrote: "RobG" wrote in message news:JP******************@news.optus.net.au... This one is a bit faster and a lot tidier, it uses concat to copy the array instead of copyA, everything is in one function. RobG, et al, I'm glad to know this was an interesting intellectual challenge to even the pros... I was completely stumped. I'll play around with the different approaches (run time compile, join/concat, and recursive object function) to figure out, not only which I'll actually use, but to learn how they work. Thanks again, to all! Mike Hey, just for the record, here's a recursive version (sorry, couldn't help myself, this just kept popping into my brain!). var A = [['Q',2],['A',4],['B',3]]; function recA(X, i, B) { var i = i || 0; if (!B) B = [[]]; var root = B[B.length-1].concat(X[i]); var loops = X[i]; for (var j=0; j
 "RobG" wrote in message news:11**********************@g14g2000cwa.googlegr oups.com... Hey, just for the record, here's a recursive version (sorry, couldn't help myself, this just kept popping into my brain!). var A = [['Q',2],['A',4],['B',3]]; function recA(X, i, B) { var i = i || 0; if (!B) B = [[]]; var root = B[B.length-1].concat(X[i]); var loops = X[i]; for (var j=0; j
 "RobG" wrote in message news:11**********************@g14g2000cwa.googlegr oups.com... Hey, just for the record, here's a recursive version (sorry, couldn't help myself, this just kept popping into my brain!). < snip > Rob Wait, I think I got it: function test() { var n = 0; arrays = recA(A); for ( n = 0; n < arrays.length; n++ ) { calculate( arrays[n] ) } } .... I'm still stepping through a debug to try and figure it out :) Mike Oct 26 '05 #13
 Mike P wrote: "RobG" wrote in message news:11**********************@g14g2000cwa.googlegr oups.com... Hey, just for the record, here's a recursive version (sorry, couldn't help myself, this just kept popping into my brain!). < snip > Rob Wait, I think I got it: function test() { var n = 0; arrays = recA(A); for ( n = 0; n < arrays.length; n++ ) { calculate( arrays[n] ) } } ... I'm still stepping through a debug to try and figure it out :) Here's the explanation (with a bit of cleaning up): var A = [['Q',2],['A',4],['B',3]]; // A value is passed for X, but not for i or B function recA(X, i, B) { /* If i is undefined, set its value to zero. This will * only happen the first time recA() is called. When it calls * itself, it passes values for i and B. */ var i = i || 0; /* If B is undefined, make it an array with one element which is * another empty array. The logic here is identical to that * above, only the code is a bit different. The same code * pattern could be use for both. */ if (!B) B = [[]]; // Both the above lines could be replaced with the following // It's a bit cryptic and so not great for maintenance !i && (B=[[]]) && (i=0); /* Get the last row of the result array, B * Make a copy of it and append the value at X[i] * 'A' will be appended the first time through, * 'B' the second, 'C' the third, etc. * The array concat method copies and appends in one go */ var root = B[B.length-1].concat(X[i]); // For this iteration, get the number of loops. var loops = X[i]; // Start doing the loops for (var j=0; j0. * slice modifies in place, so B is modified directly. * Its return value is whatever is deleted (if anything) * We don't need it so it's ignored. * * The number of lines to replace is always 1, when * j=0 the modified line (array) replaces the last, when * j>0 the modified line is appended. Telling splice * to replace lines after the end of the array * effectively does nothing. * * concat is used again to get a copy of root with the * value of j appended * * Lastly, if we aren't at the last element of X, * call recA() again and pass i+1 to i and B to B. * i is local to each instance of recA and so * doesn't affect the value of i in other instances. * All the B's are local too, but they all reference the * same array, so just one array keeps getting modified. */ if ( X[i+1] ) recA(X, i+1, B); } /* The return value is ignored within the recursion * since it's just a reference to an array that we * already have a reference to. * Whatever called recA() should to assign the returned * reference to a variable or do something with it. */ return B; } -- Rob Oct 27 '05 #14
 As a followup: I've been playing around with the various options, trying to learn them, and figure out which makes sense. I got an error @ this.recurse(0) on Julian's recursive function, and wasn't sure how to resolve it, so I skipped testing his. I was able to run a benchmark on both RobG's recursive function and VK's run-time compile version. Remember, worst case, I'll be running this using example.length = 41. The numbers get pretty scary with larger arrays. I used example.length = 6, for the test. Specifically: example = [["A",7],["B",7],["C",7],["D",7],["E",7],["F",7]] While I'm running a pretty slow machine, I came up with the following runtimes: RobG's Recursive Function = 102958 ms VK's runtime compile = 9113 ms ....just thought you might be interested. Thanks! Mike Oct 29 '05 #15
 Mike P wrote: As a followup: I've been playing around with the various options, trying to learn them, and figure out which makes sense. I got an error @ this.recurse(0) on Julian's recursive function, and wasn't sure how to resolve it, so I skipped testing his. I was able to run a benchmark on both RobG's recursive function and VK's run-time compile version. Remember, worst case, I'll be running this using example.length = 41. The numbers get pretty scary with larger arrays. I used example.length = 6, for the test. Specifically: example = [["A",7],["B",7],["C",7],["D",7],["E",7],["F",7]] While I'm running a pretty slow machine, I came up with the following runtimes: RobG's Recursive Function = 102958 ms VK's runtime compile = 9113 ms ...just thought you might be interested. Do you know *what* killed the cat? You've almost spelled a dark secret of JavaScript related with its interpreted (vs. compiled) nature; but your guardian angel stopped you on time. Search this newsgroup using keyword "evil". Look the posters' Names. You were aware... ;-) Oct 29 '05 #16
 "Mike P" wrote: example = [["A",7],["B",7],["C",7],["D",7],["E",7],["F",7]] While I'm running a pretty slow machine, I came up withthe following runtimes: RobG's Recursive Function = 102958 ms VK's runtime compile = 9113 ms ...just thought you might be interested. If you were interested in speed you probably should have said so form the outset, and provided considerably more detail as to the real problem instead of just this one minor part of it. Recursion is inevitably slow, it lends itself to working with more complex structures than yours, such as trees. But there is no need for the 'meta scripting' (building new scripts as strings and having them dynamically interpreted) approach here either. Unfortunately, in not providing details of the wider problem, and particularly your - calculate - function, it is not possible to gauge whether all the Array creation inherent in your original code, and the suggested alternatives, is necessary. If the Arrays are just a way of passing parameters to the - calculate - function, and are effectively thrown away after the function call then there is no need to create a new array for each call at all. The result will be considerably quicker than all of the alternatives proposed so far:- function loopIt(ar){ var len, c, o = []; if((len = ar.length)){ c = --len; do{ o[c] = [ar[c], 0]; }while(c--); do{ c = len; while((++o[c]) == ar[c]){ o[c] = 0; if(--c == -1){ break; } } calculate(o); }while(c != -1); } } But if the - calculate - function does preserve the Arrays in some way, so it does need to be passes a distinct array with each call, then:- function loopIt(ar){ var len, t, c, a1 = []; var a3, a2 = []; if((len = ar.length)){ c = --len; do{ a1[c] = 0; a2[c] = ar[c]; }while(c--); do{ t = len; while((++a1[t]) == ar[t]){ a1[t] = 0; if(--t == -1){ break; } } a3 = []; c = len; do{ a3[c] = [a2[c], a1[c]]; }while(c--); calculate(a3); }while(t != -1); } } - gets the job done with direct code, and mostly quicker than the 'meta scripting' approach. In any case, the desire to pass such a complex structure to a function suggests that the whole problem would be amenable to better (certainly faster) solutions. Richard. Oct 30 '05 #17
 "Richard Cornford" wrote in message news:dk*******************@news.demon.co.uk... If you were interested in speed you probably should have said so form the outset, and provided considerably more detail as to the real problem instead of just this one minor part of it. Richard, Thanks for the feedback, and code on this one. Quite honestly, it didn't occur to me that speed would be an issue when I first approached this. Once I ran the code a few times, I realized that more complex arrays were taking HOURS to run, and started re-evaluating the code and my approach in general. Long-term, I'm working on an ajax-based Monopoly game. At the moment, I'm focusing on some basic AI for the game. I have relative values for each configuration of a property in the game of Monopoly. (e.g., what is Boardwalk with 2 houses worth, long term, as opposed to Park Place with two houses). In this project, I've created a form, where a player can enter all the properties they own, and their current state (e.g., mortgaged, unmortgaged, 3 houses, a hotel, etc.), and how much cash the player has on hand. I'm then running through all the various options they have available to them (e.g., mortgage one property to get cash, then build on another). I'm then calculating the relative value of that complete configuration and comparing them. So, yes, I'm actually running some calculations based on each array. At the end, I tell the player their best possible option. Pretty straightforward, but my approach had been to run through all the permutations. It's taking far too long, when a player owns more than one Monopoly, so I'm open to any ideas you may have. Let me see if I can follow your code samples, and see how it performs in the context of my script. Thanks again! Mike Oct 31 '05 #18
 Mike P wrote: I got an error @ this.recurse(0) on Julian's recursive function, and wasn't sure how to resolve it, so I skipped testing his. Apologies for that. No doubt Richard's solutions are more effective, and recursion is not the best in terms of performance, but if you were still interested, here is a slightly adjusted version of my function to try. You could no doubt try speeding it up with use of "while" and "do while" loops, and reverse loops (i.e. length-1 --> 0) function LoopIt(e) { var L=e.length; var a=[]; Recurse(0); function Recurse(n) { if (n
 Julian Turner wrote: No doubt Richard's solutions are more effective, and recursion is not the best in terms of performance Here is another non-recursive version:- function LoopIt(e) { var L=e.length; var c=[]; var t; var i=L; while(i--) { c[i]=[e[i],0,e[i]]; } Outer: while(1) { t=c[L-1]; while(t
 Mike P wrote: "Richard Cornford" wrote in message news:dk*******************@news.demon.co.uk... If you were interested in speed you probably should have said so form the outset, and provided considerably more detail as to the real problem instead of just this one minor part of it. Richard, Thanks for the feedback, and code on this one. Quite honestly, it didn't occur to me that speed would be an issue when I first approached this. Once I ran the code a few times, I realized that more complex arrays were taking HOURS to run, and started re-evaluating the code and my approach in general. The number of loops will be the product of how many of each element you have (where A0 is one element, A1 another, etc.): [["A",7],["B",7],["C",7],["D",7],["E",7],["F",7]] Thats 7^6 loops of 6 pairs, or 117,649*6 pairs = 705,894 elements. The general formula is n*x^n, where n is the number of elements (in the above case 6 - A-F inclusive) and x is the number of possible values each can have - in the above case 7. That assumes that they all have the same number of possible values. If you work out how many you have using 7 values for each element: Terms values of each e.g. 1 7 [[a,7]] 2 98 [[a,7,[b,7]] 3 1,029 [[a,7,[b,7],[c,7]]] 4 9,604 etc. 5 84,035 6 705,894 7 5,764,801 8 46,118,408 9 363,182,463 10 2,824,752,490 11 21,750,594,173 12 166,095,446,412 13 1,259,557,135,291 You crack 1 billion element pairs at just 10 elements with 7 combinations each, and 1 trillion at 13 elements. As Richard said, speed isn't really an issue, it's a roadblock. You need quantum leaps in speed, not incremental gains. Some comments: I don't know how you did your testing, but according to me the recursive function is easily the fastest. Which browser you use makes a huge difference to the times but not the rankings of each method. The following results were obtained using 5 elements (A,7 to e,7) in IE and Firefox: Iterative Recursive Dynamic 'Cornford' Firefox 3,844 609 1,079 1,046 IE 13,562 7,094 10,096 10,688 Why is Firefox up to 10 times faster than IE? The only way you will finish the task in this lifetime (41*7^41 values which is 1.827E+36 according to Excel) is to reduce the work required - there are various strategies for that. Recursion is often slower than other methods, it is liked because of it's simplicity and ability to travel along any number of forks where they aren't known beforehand. I suspect it works quickly here because it doesn't recurse very deeply. Long-term, I'm working on an ajax-based Monopoly game. At the moment, I'm focusing on some basic AI for the game. I have relative values for each configuration of a property in the game of Monopoly. (e.g., what is Boardwalk with 2 houses worth, long term, as opposed to Park Place with two houses). In this project, I've created a form, where a player can enter all the properties they own, and their current state (e.g., mortgaged, unmortgaged, 3 houses, a hotel, etc.), and how much cash the player has on hand. I'm then running through all the various options they have available to them (e.g., mortgage one property to get cash, then build on another). I'm then calculating the relative value of that complete configuration and comparing them. So, yes, I'm actually running some calculations based on each array. At the end, I tell the player their best possible option. Pretty straightforward, but my approach had been to run through all the permutations. It's taking far too long, when a player owns more than one Monopoly, so I'm open to any ideas you may have. You may be better off to estimate the outcome of just a couple of the most likely scenarios based on the probability that they might occur - the vast majority of possibilities are irrelevant in the short term. Attempting to estimate the likely outcome of every single possible outcome is brute force approach. You may be better to try an approach where decisions are based on a particular strategy, current circumstance and player positions on the board. [...] -- Rob Nov 1 '05 #22
 RobG wrote: You need quantum leaps in speed, not incremental gains. Quantum leaps are the smallest possible gains or losses (of energy) :) SCNR PointedEars Nov 1 '05 #23
 Thomas 'PointedEars' Lahn wrote: RobG wrote:You need quantum leaps in speed, not incremental gains. Quantum leaps are the smallest possible gains or losses (of energy) :) Ah yes, but we aren't discussing quantum mechanics here (heaven forbid!). It also means (strictly) a leap from one state to another with no intermediary step, hence the smallest possible movement. Colloquially it means to go from one state to another in a (usually large) jump. -- Rob Nov 2 '05 #24
 RobG wrote: Thomas 'PointedEars' Lahn wrote: RobG wrote: You need quantum leaps in speed, not incremental gains. Quantum leaps are the smallest possible gains or losses (of energy) :) Ah yes, but we aren't discussing quantum mechanics here (heaven forbid!). It also means (strictly) a leap from one state to another with no intermediary step, hence the smallest possible movement. Colloquially it means to go from one state to another in a (usually large) jump. You don't say. PointedEars, with working Irony Detector[tm] Nov 2 '05 #25
 "Richard Cornford" wrote in message news:dk*******************@news.demon.co.uk... Thinking about what you are doing I suspect that speed isn't so much an issue as a fatal problem. The speed issue has certainly forced me to focus on building a more targeted approach to solving for best configuration. I've already eliminated most of the unfeasible scenarios. The first thing I did was to move the isFeasible() function before the calculations, rather than after it. This saved considerable time by avoiding unnecessary calculations. Next, before even coming up with the exhaustive list of viable scenarios, I determine if a property is a colored property within a monopoly. If it is, I'll look at the 7 possible states (mortgaged through hotel). If it's not, there are only 2 states (mortgaged/unmortgaged) to evaluate. Given the fact that having more than one or two monopolies is quite rare in the game, those two changes made this whole thing seem more reasonable. So if a player owns one monopoly and six assorted other properties, we're looking at: 7^3*3*2^6*6 = 395,136 permutations. This does takes too long to calculate, but it's far more realistic. Calculating with a single monopoly and a few assorted other properties became completely viable. Specifically, what am I doing? I have an array consisting of probabily*impact for each property in each state. So the probability of landing on Mayfair is 2.4832%, if that property has a hotel (rent = £2000), that gives Mayfair with a Hotel the relative value of 49.664. Once I come up with the various scenarios, I run each through an isFeasible() function, which sees if the properties are "evenly built", and if the player could afford to do it given the resources at their disposal (cash, houses/hotels and unmortgaged properties). Once I've determined the viable scenarios, I simply add the relative values for each property in the state they're in to find a total relative value for the scenario. I completely ignore unowned properties, but mortgaged properties do have an effect (e.g., owning a morgaged railroad increases the rent on other unmortgaged railroads). Then, I compare that value among the scenarios to find the highest value. My next thought is to, somehow, approach this from the top down (i.e., hotels on all monopoly properties, and unmortgaged for all non-monopolies). If the player can afford that, we're done. If not, we can ratchet things down a notch (i.e., all unmortgaged, hotels on all monopoly properties except one. That one with 4 houses) then I'll switch the 4-houses among all the monopoly properties, see if that's feasible, if not, continue ratcheting things down until I find one. That may be more realistic. Or, possibly, I could work from both ends. Meaning, I could do some quick checks on the high end (built to Hotels), working my way down. At the same time looking at the low end (everything mortgaged) and working my way up. Once I find the general vacinity of viability. Then exhaustively check configurations within that smaller band (up or down). In concept, that seems workable, but I'm still trying to figure out how I'd do it. Still another approach might take the middle and work my way outward. Or using random scenarios to find a "band of viability", within which, I could perform an exhaustive search. I did notice that the calculations seem to lean toward building houses/hotels on less expensive properties. So, for example, if one had £400, and owned Old Kent/Whitechapel (Indigo) and Park Lane/Mayfair (Blue)... most players would assume they should build a single house on each of the Blue properties. But, comparing based on long-term probable income, the script now recommends mortgaging Park Lane, and building Kent/Whitechapel to Hotels. As you pointed out, a smart strategy should include knowledge of the other players networth, current board position and probability*impact of landing on your opponents squares (e.g., how much cash should you keep on-hand). Players often don't know how much their opponents are worth. If they did, as you clearly do, there's no sense in over building (e.g., if your opponent's networth is £300 don't build beyond two houses on each of the Blue). But I've not included that aspect in the calculation. I do have probable next roll figures, which includes probability of landing on go-to-gaol/go-to jail, selecting a chance/community chest card, landing in gaol or rolling doubles. I'm not, initially, figuring that in the calculations either, though having the opponents (estimated) net worth could allow me to target bankruptcy goals thereby streamlining my search. Regarding internationalization, that's a simple problem, easily remedied, by offering a dropdown list to select game version (i.e., property names & currency) ala http://kasoft.freeyellow.com/Central...poly/Database/. FYI, there are Canadian and French versions, though I couldn't find one for the Netherlands or Denmark. Nov 2 '05 #26
 4 posts views Thread by David | last post: by 4 posts views Thread by Paul M | last post: by 45 posts views Thread by Trevor Best | last post: by 5 posts views Thread by dam_fool_2003@yahoo.com | last post: by 23 posts views Thread by Russ Chinoy | last post: by 4 posts views Thread by Sjoerd | last post: by 11 posts views Thread by motion musso aka: sathia | last post: by 11 posts views Thread by Bosconian | last post: by 1 post views Thread by javedna | last post: by 6 posts views Thread by Otekpo Emmanuel | last post: by reply views Thread by SwissProgrammer | last post: by 1 post views Thread by SwissProgrammer | last post: by 3 posts views Thread by SwissProgrammer | last post: by 1 post views Thread by RonPar | last post: by 2 posts views Thread by Firas Rihan | last post: by 3 posts views Thread by CD Tom | last post: by reply views Thread by AjayGohil | last post: by 1 post views Thread by AccessUser22 | last post: by