ROFLBot Progress

Come in here to talk about your sky-net style world-destroying super bots!

Moderator: Defcon moderators

User avatar
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm
Location: ::1
Contact:

Postby martin » Sat Feb 27, 2010 4:28 pm

That's exactly what I said, and not what Ace said...
GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
User avatar
roflamingo
level3
level3
Posts: 404
Joined: Fri Jan 19, 2007 10:25 am

Postby roflamingo » Sat Feb 27, 2010 4:55 pm

I used the right formula. Thanks to all 3 of ya :D

However the algorithm doesn't work 100% correctly...the land bulges in SA and Africa make it look like there are multiple oceans.
User avatar
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm
Location: ::1
Contact:

Postby martin » Sat Feb 27, 2010 8:32 pm

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
GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
User avatar
xander
level5
level5
Posts: 16861
Joined: Thu Oct 21, 2004 11:41 pm
Location: Riverside, CA, USA
Contact:

Postby xander » Sun Feb 28, 2010 12:45 am

martin wrote:That's exactly what I said, and not what Ace said...

Ace left out the parentheses, but used space to make it clear what he was doing. You left out the subscripts. ;)

xander
User avatar
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm
Location: ::1
Contact:

Postby martin » Sun Feb 28, 2010 1:06 am

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.
User avatar
xander
level5
level5
Posts: 16861
Joined: Thu Oct 21, 2004 11:41 pm
Location: Riverside, CA, USA
Contact:

Postby xander » Sun Feb 28, 2010 3:03 am

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
User avatar
Montyphy
level5
level5
Posts: 6745
Joined: Tue Apr 19, 2005 2:28 pm
Location: London, England

Postby Montyphy » Sun Feb 28, 2010 3:20 am

You're all wrong. It should be:

Code: Select all

mx := (x1 + x2) * 0.5f;
my := (y1 + y2) * 0.5f;


:P
Uplink help: Check out the Guide or FAQ.
Latest Uplink patch is v1.55.
User avatar
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm
Location: ::1
Contact:

Postby martin » Sun Feb 28, 2010 3:20 pm

I can claim that xander, I just did.

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...
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Sun Feb 28, 2010 3:57 pm

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. :P
Smoke me a kipper, I'll be back for breakfast...
User avatar
shinygerbil
level5
level5
Posts: 4667
Joined: Wed Dec 22, 2004 10:14 pm
Location: Out, finding my own food. Also, doing the shinyBonsai Manoeuvre(tm)
Contact:

Postby shinygerbil » Sun Feb 28, 2010 4:05 pm

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.
Here is my signature. Make of it what you will.
Image
User avatar
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm
Location: ::1
Contact:

Postby martin » Sun Feb 28, 2010 5:53 pm

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.
User avatar
xander
level5
level5
Posts: 16861
Joined: Thu Oct 21, 2004 11:41 pm
Location: Riverside, CA, USA
Contact:

Postby xander » Sun Feb 28, 2010 11:21 pm

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
User avatar
bert_the_turtle
level5
level5
Posts: 4797
Joined: Fri Oct 13, 2006 6:11 pm
Location: Cologne
Contact:

Postby bert_the_turtle » Sun Feb 28, 2010 11:49 pm

Welcome to the DEFCON forums, where everything gets turned into an argument :)
User avatar
Montyphy
level5
level5
Posts: 6745
Joined: Tue Apr 19, 2005 2:28 pm
Location: London, England

Postby Montyphy » Sun Feb 28, 2010 11:57 pm

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


You obviously haven't seen martin's code :P
Uplink help: Check out the Guide or FAQ.

Latest Uplink patch is v1.55.
User avatar
xander
level5
level5
Posts: 16861
Joined: Thu Oct 21, 2004 11:41 pm
Location: Riverside, CA, USA
Contact:

Postby xander » Mon Mar 01, 2010 1:12 am

Montyphy wrote:
xander wrote: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).


You obviously haven't seen martin's code :P

Burn.

xander

Return to “AI Bots”

Who is online

Users browsing this forum: No registered users and 1 guest