ROFLBot Progress

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

Moderator: Defcon moderators

User avatar
roflamingo
level3
level3
Posts: 404
Joined: Fri Jan 19, 2007 10:25 am

Postby roflamingo » Mon Mar 01, 2010 1:46 am

martin wrote:Use a flood fill algorithm:

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


I tried doing this with the first coroutine setup and it was extremely slow.

Are you doing this? What algorithm and step values do you use? Is it fast enough?
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm

Postby martin » Mon Mar 01, 2010 10:15 am

bert_the_turtle wrote:Welcome to the DEFCON forums, where everything gets turned into an argument :)


Oh god, you're right :O
xander, let's agree to differ one this one ;)

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

xander


I've never heard of PEMDAS, the various ones I have heard through the years are BODMAS and BIDMAS (I can't remember what the O stands for, if I remember correctly that was before we learnt about exponents and it's basically just a placeholder, the I stands for indices, and I always thought BEDMAS would make more sense).

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


In all seriousness, I have no idea if my Lua code is good or not, I'm writing it in a pretty strong OOP style, which is probably not classical Lua style.

roflamingo wrote:
martin wrote:Use a flood fill algorithm:

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


I tried doing this with the first coroutine setup and it was extremely slow.

Are you doing this? What algorithm and step values do you use? Is it fast enough?


I'm not, but I am doing something similar with surveying the land around my cities for find the best place to put silos

I was talking in pseudo code, you can probably do it somewhat better than that in reality

1) Pick a random point in the ocean and add to a set foo
2) Generate all surrounding points, for each point which is _not_ in the set foo do step add to set and do step 2
3) At the end, if foo does not contain all ocean points, then you have a discontinuous ocean.

Determining step 3 is not trivial, but I'm sure some simple solution can be found (it's 9am, I'm not gonna figure out how to do it right now)

Finally, for an implementation of a set in Lua, see the Joshua/Utilities folder :)
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: 16869
Joined: Thu Oct 21, 2004 11:41 pm
Location: Highland, CA, USA
Contact:

Postby xander » Mon Mar 01, 2010 3:18 pm

martin wrote:
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


In all seriousness, I have no idea if my Lua code is good or not, I'm writing it in a pretty strong OOP style, which is probably not classical Lua style.

I have not taken a lot of programming, nor do I program that often, nor do I read other people's code that often. However, was always taught to use the clearest possible variable naming conventions, to ensure that my code is readable to others. The best possible code is that which requires no comments because everything is so self-evidently clear that any idiot could read through it and know what is going on. From that standpoint, using "x" rather than "x1" is confusing. If nothing else, it gives the impression that "x" and "x2" are different kinds of variables. It does not imply that, for instance, one is an int and the other a float, but it does imply that they are holding different pieces of unrelated data. On the other hand, "x1" and "x2" are clearer, and are in line with mathematical convention. Thus a mathhead like myself finds Ace's version more readable.

On the other hand, I suppose that your code is more functional (i.e. it does what it is supposed to do), so a programming junkie would probably prefer yours. When I say that Ace's version is more "correct," I am speaking from my perspective as a math person, not as a programmer. This is a situation where context is probably important. That being said, you are still both wrong. :P

xander
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm

Postby martin » Mon Mar 01, 2010 8:23 pm

Oh I would never use names like x and x2 in code! Have a glance through the Joshua source and you'll see I use pretty verbose names. However, for a little example like that, where I was mostly worried about correcting a bracketing mistake that would cause Lua to throw a wobbly, I didn't really care about naming where it was obvious what I meant ;)
GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
Montyphy
level5
level5
Posts: 6747
Joined: Tue Apr 19, 2005 2:28 pm
Location: Bristol, England

Postby Montyphy » Mon Mar 01, 2010 8:27 pm

martin wrote:Oh I would never use names like x and x2 in code! Have a glance through the Joshua source and you'll see I use pretty verbose names.


svn/trunk/whiteboard.lua

Code: Select all

Whiteboard.DrawLine = function(x, y, x2, y2)
        WhiteboardDraw(x, y, x2, y2)
end



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

Postby martin » Mon Mar 01, 2010 8:31 pm

I inherited that from the old version of Joshua, which iirc is inherited from the old version of the Luabot. Maybe I should change that :oops:

Before anyone points it out, yes I know I call tables in my constructor methods "t" but no, I'm not going to change that, I just can't be arsed :P
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: 16869
Joined: Thu Oct 21, 2004 11:41 pm
Location: Highland, CA, USA
Contact:

Postby xander » Tue Mar 02, 2010 12:40 am

martin wrote:Oh I would never use names like x and x2 in code! Have a glance through the Joshua source and you'll see I use pretty verbose names. However, for a little example like that, where I was mostly worried about correcting a bracketing mistake that would cause Lua to throw a wobbly, I didn't really care about naming where it was obvious what I meant ;)

If you are going to take the time to correct someone take the time to do it right. The only thing more annoying that posts that consist of an edited quote and the word "Fixed" (or some variant thereof) are such posts where the fix is incomplete or inaccurate.

xander

Return to “AI Bots”

Who is online

Users browsing this forum: No registered users and 7 guests