## ROFLBot Progress

**Moderator:** Defcon moderators

- roflamingo
- level3
**Posts:**404**Joined:**Fri Jan 19, 2007 10:25 am

Use a flood fill algorithm:

1) Generate all points in the ocean and add them to a set

2) pick an arbitrary point (call it foo)

3) remove foo from the set

4) for each neighbour of foo, remove them from the set, and so on with each of their neighbours

If, once you run out of points (ie. all new points are either not in your territory, or are not land), you still have something in the set, then you have a disjoint ocean

1) Generate all points in the ocean and add them to a set

2) pick an arbitrary point (call it foo)

3) remove foo from the set

4) for each neighbour of foo, remove them from the set, and so on with each of their neighbours

If, once you run out of points (ie. all new points are either not in your territory, or are not land), you still have something in the set, then you have a disjoint ocean

GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.

Ace left out parentheses, which makes what he said mathematically wrong, spaces aren't part of maths. I left out the subscripts because I'm a programmer and that means I can attach meaning to whatever arbitrary token I like.

GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.

martin wrote:Ace left out parentheses, which makes what he said mathematically wrong, spaces aren't part of maths. I left out the subscripts because I'm a programmer and that means I can attach meaning to whatever arbitrary token I like.

You cannot simultaneously claim that something is mathematically incorrect, then claim that your abuse of notation is mathematically correct on the grounds that you are a programmer. The parentheses do help to clarify what is happening, but I hardly ever use them when actually writing out my mathematics. Instead, I use space, and the location of symbols, to create meaning. Neither of you was entirely correct---the correct formula is $(x_m,y_m) = \left({x_1+x_2\over 2},{y_1+y_2\over 2\right)$---but Ace's version was closer to being correct than yours. Those subscripts have meaning, and are important. :P

xander

Don't forget, we're talking Lua here, if someone were to use my formula in Lua, they'd get the right answer, if someone were to use Aces they'd get the wrong answer because the grammar doesn't attach any meaning to spaces.

Maybe it doesn't attach any meaning to spaces because there *is* no meaning to spaces

As an aside, although it's wrong to use spaces in programming (since they have no strict mathematical meaning in any (non esoteric) programming language that I know of), is it correct to use spaces in mathematical notation, and if so is that just an American thing? I have never seen any maths teacher, or computer science papers (some of which are quite maths heavy) using spaces to indicate operator ordering...

- Ace Rimmer
- level5
**Posts:**10803**Joined:**Thu Dec 07, 2006 9:46 pm**Location:**The Multiverse

Hehe, I wasn't trying to be correct, technically. I figured you lot were smart enough to know what I was doing. xander got it anyway.

In fact, I thought about putting parenthesis in there a few times before this discussion started cause I knew somebody would point it out.

In fact, I thought about putting parenthesis in there a few times before this discussion started cause I knew somebody would point it out.

Smoke me a kipper, I'll be back for breakfast...

- shinygerbil
- level5
**Posts:**4667**Joined:**Wed Dec 22, 2004 10:14 pm**Location:**Out, finding my own food. Also, doing the shinyBonsai Manoeuvre(tm)-
**Contact:**

shinygerbil wrote:My maths teacher once told me it should really be BOMDAS, but that doesn't sound quite as snappy.

Edit: Wikipedia to the rescue. Either is correct.

Link the bit which says either is correct?I'm interested because I have never seen spaces used like that in mathematical notation.

Also, important aside, they might be mathematically correct but only one will work properly in Lua

GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.

martin wrote:shinygerbil wrote:My maths teacher once told me it should really be BOMDAS, but that doesn't sound quite as snappy.

Edit: Wikipedia to the rescue. Either is correct.

Link the bit which says either is correct?I'm interested because I have never seen spaces used like that in mathematical notation.

Also, important aside, they might be mathematically correct but only one will work properly in Lua

Again, the distribution of symbols on the page is important. Normally, you would write the "x1+x2" on the page, then put a line under it, then put the "2" under the line. There would be a clear division between the two symbols, using space and the location of symbols. Hence, Ace's version was perfectly clear (if not usable in code). Your version was a bit ambiguous, as "x" is a variable, not a constant. Moreover, it is even bad code, as I highly doubt that you would be using x in that situation (it is likely that "x" would already be used for something else). Thus, as I said above, neither of you is really right, but Ace was more right.

Let me put it this way: x1+x2 / 2 is perfectly clear. It is clear that x1+x2 is one unit, that 2 is another, and that x1+x2 is being divided by 2. x1+x2/2 is less clear. (x+x2)/2 is perhaps more clear, but treats x like a constant, which is contrary to convention. (x1+x2)/2 is more clear, and would actually work as code, thus would be the best choice.

Finally, the acronym is PEMDAS: parentheses (or brackets, as you silly Europeans call them), exponents, multiplication and division, and addition and subtraction. :P

xander

- bert_the_turtle
- level5
**Posts:**4795**Joined:**Fri Oct 13, 2006 6:11 pm**Location:**Cologne-
**Contact:**

### Who is online

Users browsing this forum: No registered users and 0 guests