« first day (1525 days earlier)      last day (3312 days later) » 

12:19 AM
Just two more upvotes....
9998
Q: Why is processing a sorted array faster than an unsorted array?

GManNickGHere is a piece of C++ code that seems very peculiar. For some strange reason, sorting the data miraculously makes the code almost six times faster. #include <algorithm> #include <ctime> #include <iostream> int main() { // Generate data const unsigned arraySize = 32768; int data[arr...

 
1 more...
 
The answer has almost 15k... so ridiculous :)
 
Yay!
 
in Lounge<C++> on Stack Overflow Chat, 1 min ago, by Pris
should I bring it back down to 9999
 
 
1 hour later…
1:44 AM
@PhiNotPi See sandbox post. I think we can do this if you plan two moves ahead.
 
Hi
 
@Geobits: I just looked at it and it now has 10002 votes. Did you ask that question or are you otherwise associated with it?
Hi
 
@Sp3000 What bot is in the sandbox right now?
The minion?
 
Yeah
I think we can use one char which alternates between rounds, so that if they're different at any point we know the other bot's gone first
 
I was also looking at a strategy to do it.
The logic of the two bots would be identical, and it would use the shape of the formation itself to determine which bot has the first move.
If the bot is out of formation, it moves into formation. If it is in formation, then it moves in the direction the formation should go.
 
1:56 AM
That could also work, assuming it always stays in formation after the end of the round
 
The would have to be some part of the message that says whether or not the formation has been created yet.
 
Hmm that's true, the first step would require finding each other, wouldn't it
 
At the start of the game, the formation doesn't exist at all and must be formed. Even if the two pixels are very close to each other, the formation hasn't formed until they end their moves in the right spot.
 
Is the formation just directly side-by-side, or...?
 
Pretty much.
Once above the other, so the zones of attack overlap and they protect each other.
If a single bot's zone looks like this:
XXX
.O.
XXX
Then a pair's zone looks like this:
XXX
XOX
XOX
XXX
 
2:03 AM
Makes sense, so let's see, how to get into formation...
 
Which allows us to take advantage of the immortal bot problem we had earlier, before the spec changed.
This formation can even move directly sideways, if both bots move diagonally and swap places.
 
Ahaha nice, that'll make the logic interesting
 
When it comes to getting in formation, it makes sense to have a lead and a follower bot.
Slightly off-topic, but I think it's interesting how a bot can move in the forbidden direction by moving diagonally against a wall.
 
Calvin just patched that
 
Oh. :(
I think we can start to piece together some rules of movement, so the "leader" bot has fewer decisions to make, and the follower bot can think more on its own.
 
2:11 AM
k :)
 
1) Never move into a square where the enemy can capture you next turn.
2) If you can, always capture an enemy.
3) If the target (how do we pick a target?) is directly above or below, then move directly up or down.
4) If the target is displaced horizontally and vertically, but the vertical distance is greater, then you move diagonally towards it, so that you will eventually be vertically aligned.
 
I guess if both bots always try to stick in formation we wouldn't really need that char in the message
Might need to be a bit careful so we're not stuck at the edge and the other bot can't get into place though
 
Edge cases will require a little bit of effort.
Now, the side-to-side travel is interesting to me.
 
Probably need a char for on top/on bottom for that
 
It takes some effort to coordinate, but we would be able to attack in all directions.
 
2:19 AM
k well that's #2 done (updating sandbox as I go)
I'm guessing 1) takes priority of 2)... hmm how to Javascript
 
It probably doesn't have to take priority.
 
It probably should though, right?
 
I guess.
I'm working on a bot that would move like how the formation could move.
I've never really used JavaScript before.
So I'm kinda slow.
 
I don't use it much either :P
 
The basic idea is to determine where the formation is (rather than where the bot is), which ways are safe for the formation to move, and then for the two bots to figure out where they need to go to make that happen.
Since I only have a single bot right now, I can't really work on that yet.
 
2:37 AM
If it helps you can hijack my post
 
I might.
Right now, I'm breaking out the graph paper to figure out how to determine which moves are safe.
 
I just updated the meta controller to match the latest version. The boundary move thing still wasn't fixed there I think.
 
Hm k :)
 
@Calvin'sHobbies Things seem surprisingly different with sticky walls.
 
2:59 AM
@Sp3000 I've made a little bit of progress: meta.codegolf.stackexchange.com/a/4975/2867
 
k checking
 
I think this calculates safe moves, but doesn't do anything with the information.
 
Yeah, just knowing how you were going to approach this is good
So you're indeed treating it as a unit with 9 possible moves
 
At the top, where I put var topx = x; there will be more complex code determining which bot is the top.
 
I'm not sure where the dx * dx == 1 && dy >= -1 && dy <= 2 condition comes from though
I'm assuming it encodes the movement of the enemy somehow, but I'm not sure how
dx * dx == 1 -> dx in {-1, 1} I'm assuming
But dy >= -1 && dy <= 2?
 
3:05 AM
topx/topy contain the old location, while ntopx/ntopy contain the new location, so dx and dy are the relative location of the enemy from the possible future location of the bot.
Here is it more graphically.
 
Oh, it's dy from the top of the two, I see
 
x.x
xOx
xox
x.x
Where xs are places where an enemy could attack from.
So dx is either +/-1, while dy ranges from -1 to +2.
 
k
So how was this working again? Are we having it so that both bots use the same logic, and whichever bot moves first decides where to move and the other one follows?
 
I think so.
Well, that's an option.
 
I'm just seeing which one's easiest to implement :P
Updated my post - maybe that sort of template?
 
3:24 AM
Updated my post as well.
It should now determine which moves are captures, and make a capturing move if one is available. although some captures are not effective because it would be the bottom bot making the capture.
 
k, looks good and makes sense to me
 
By the way, I think I like the style of JavaScript, or at least this JavaScript.
 
:P
 
Maybe it's the single-space indented code I'm writing?
 
Ahaha I dunno, I only single-space indent golfed code, personally
 
3:38 AM
Maybe it's the fact that it's almost midnight?
 
4:00 AM
@Sp3000 Are you still around?
 
Yep
 
><> -v flag is counted as 3 bytes, right?
 
Yeah, apparently :/
One day when I finish Golfish... mumbles
 
I just updated my code.
 
I'm not as efficient that it would matter though :)
 
4:03 AM
Which question is this for?
@PhiNotPi Checking
 
1-sparse bin numbers
1+:>:  4%:3(?v~~
;n~^?-1:,2-%2<
 
The most original idea is that of a "preference" array. Depending on the condition, we can set different preferences, which are checked, in order, and the first safe move is performed.
 
Is pref always a one element array? You're using =, not +=
 
It should be =, because we can expand it to be multiple elements.
As of right now, I only have a first preference for each condition.
It doesn't handle edge cases yet, but is capable of killing some of the other test bots.
 
If you guys are talking about Calvin's red vs. blue pixel KOTH, just fyi, there's a separate chat room for that.
(I'm not trying to say you shouldn't do it here, just trying to be helpful)
 
4:10 AM
I just felt like strategising in here for some reason :P But thanks
 
Nothing wrong with that!
Are the majority of the regulars on PPCG professional programmers and CS students? Does anyone know? Just curious.
 
@randomra Isn't it 31 + 3?
 
@Sp3000 not in windows... corrected
in Golfish will ? be rotate-if-(non)zero, not jump-if-nonzero
it's almost always better
maybe 3-branch based on signum :)
 
Hm... I hadn't thought about that... I had this phase where I tried to have a few instructions to make one-liners easier, e.g. q for be like ? but skips two (e.g. when you want to tack :n afterwards)
Ahaha branch 3 eh... hm...
@PhiNotPi btw is (Math.floor(move / 256)) + 1; just a temporary thing?
 
4:27 AM
@Sp3000 yes
 
k
 
I'm going to be now.
 
k, night :)
 
The bot is reasonably competitive right now. When it looks like it's making a bad move, that's because it thinks it's part of a team.
Tomorrow, we will look a merging what we wrote.
 
Hopefully I'll have a bit of time later so when you wake up there'll be progress :P
 
4:30 AM
maybe a 2-parameter ? helps with 1-liners: x? jumps x step if nonzero (maybe also with x!)
 
Bye!
 
goodnight
 
Q currently pops the top of the stack and jumps that much if the one below that is zero
Having said that even though a lot of instructions are done, I get the feeling I'll change a lot of things around soon so that's why I haven't been posting any answers with it yet :P
I do need to work out how to do one for ! though
 
isn't that the same?
 
0
A: Sandbox for Proposed Challenges

HEGX64Quine Creator quinecode-challenge The program F is in language A. F takes a program in language B as input. Lets call this program G. F outputs a program in language B. Lets call this program O. O Takes some input and for some values it will be a quine and for others it will run G. The exact v...

 
4:36 AM
like J == 0$Q
 
Well I haven't thought about when you might want to do the same with ! yet
So it's sitting in the ideas list until I can figure out a good reason to implement it
 
with Q you probably rarely need !
 
Yeah, will see :)
 
 
4 hours later…
8:19 AM
is there a nice ascii-art way to draw a region covered by polyominoes?
something like a general version of the first two examples here: ascii.co.uk/art/brickwall
 
8:34 AM
actually, I'd settle for the polyominoes being horizontal 1*n bars
with n=1 possible
 
If they're all horizontal bars you could probably just do 2*n-1 hyphens :P
With spaces in between
 
i guess that works, but it would be nice if the bars looked the right length
so a size 2 bar is twice as long as a size 1 bar
 
Does it have to be printable ASCII? Or can there be unicode?
 
i'd really rather it be ASCII
it's for a code golf challenge, and some languages would have trouble with unicode
so none of those wonderful pipe symbols
 
:P k
Hmm yeah I'm not sure how to make size 2 look twice as long as size 1... maybe if you use a different char for each region (like what Calvin did)
 
8:45 AM
oh, that could work
i'd need to bound the number of regions
 
9:10 AM
@PhiNotPi Well, it's worse for me; today I have my 99th consecutive day on Stack Overflow and tomorrow I cannot visit...
 
9:54 AM
@PeterTaylor That disclaimer was definitely useful after the last three days. ;)
 
@MartinBüttner haha, he knows how worried you were last time he went offline
 
10:10 AM
0
A: Sandbox for Proposed Challenges

xnorBuild a steady brick wall code-golf A brick wall is a rectangle made of horizontal 1*n bricks stacked in rows. Here's a wall of height 4 and width 8: [______][______] [__][____][__][] [][______][____] [____][______][] It's made of bricks of sizes 4 4 2 3 2 1 1 4 3 3 4 1 This wall is u...

 
Nice solution you found there, xnor :P
 
hehe
 
10:24 AM
it can be the best answer to that question
all other good ones are somehow deleted :/
 
@xnor @Sp3000 2x1 blocks look more square in ASCII art anyway :)
 
Need a square font :P
 
backspace being directly above the enter key must be the worst UI fail in modern IT systems
 
its not for me
\
 
Ctrl + W above Ctrl + S is also pretty bad :P
 
10:32 AM
so is fn in place of ctrl
 
@Optimizer yeah that's pretty bad
@Sp3000 that's not so bad, unless you're using software which doesn't prompt before closing unsaved work (which is the real UI fail in that case)
 
True :P
 
11:13 AM
wow the brick one is tough
 
12:00 PM
is there a better way than brute force? (for golfing I mean. in general you could probably preprocess it with subset sum)
 
@ProgramFOX That's pretty bad.
I'm willing to help, if you want.
 
I'm not giving out my credentials :p
 
Or write a script or something.
@Sp3000 I'm looking over the changes.
 
which I cannot run, because I'm away this weekend, and then I turn off my computer and internet connection
 
Well.... I guess that's it.
Maybe take advantage of time zone differences?
 
12:04 PM
I'm still coding, but I think I've got making the formation done
 
I'll be in the same time zone as now, so that's not possible.
So I guess, I'll just try to reach 100 days when I'm back :D
 
Doesn't stack exchange use a single timezone to measure days?
 
Yes, UTC. But I'm in UTC+2, so not enough advantage there.
 
@MartinBüttner not just subset sum, but subset sum with making sure that no subset of subset sum is same
 
"preprocess"
 
12:06 PM
Well, I got nothing. :/
 
@PhiNotPi I got Ask
@MartinBüttner what kind of preprocessing ?
 
well you use subset sum to figure out how you can distribute the bricks across rows of equal length. and then you check the permutations of those partitions for validity.
 
@Sp3000 It looks like they stand on top of each other instead of next to each other.
 
Aren't they supposed to be on top of each other?
 
@Optimizer Not sure what you're referring to.
XXX
XOX
XOX
XXX
That's the arrangement.
 
12:09 PM
So one's on top, and one's on bottom, right? The two Os
 
@PhiNotPi nothing, ask, upvote, downvote, close
@MartinBüttner but it can be that the subsets you chose can never form a solution
 
Yes, but they shouldn't be in the same square. I'm saying it looks like they're in the same square.
 
@Optimizer I mean you check all the solutions of subset sum
 
god
all subset sum's all perms'
 
@PhiNotPi I don't think they are... what makes you think that?
 
12:12 PM
given a partition you can probably also do better than checking all permutations by building a graph of allowed adjacent rows and finding a Hamiltonian path... this problem is definitely NP complete, so it'll be horribly inefficient anyway
 
I think it is the fact that my bot heads to the bottom edge of the board, and yours follows. I just need to change that filler code.
 
It should be fine once your bot has the same code
In fact, can I edit your post and test now?
 
I just edited, but you can edit it.
 
Edited. Looks like they join up okay
Why it doesn't do anything after that I'm not sure though, it should...
 
They join together great.
It seems like the block only moves when they spot an enemy.
I just saw them take an enemy out.
 
12:19 PM
Seems like it. And it has a bit of trouble if it's a stationary enemy.
They join fine even if one started on the edge, so that's good
But yeah the idea with the code is that they're exactly the same except for the first three non-comment lines
 
If the enemy is stationary against a wall, I think they would try to move sideways towards it, but they need to move above/below it to attack.
 
Why it's getting stuck so many squares away from the enemy I'm not sure though, I'd expect it to be closer
 
Yeah, I noticed that just now.
 
The bottommost part of the code is basically a direct copy-paste of what you had, minus the filler line
 
I think what happens is that sometimes the second block doesn't move when the first does.
Maybe that happens when an enemy enters the range of one block but not the other.
 
12:26 PM
The second block should always just follow the first block. I'm assuming that when the first block makes the decision, the resulting square is always safe for the second block.
 
Actually, I don't think I've seen the formation move any long distance at all.
 
Theoretically if they ever do get out of formation (e.g. after first block moves or by some weird bug) then the blocks should just do what they do at the start, i.e. try to match up again
I'll take a look and see though
Maybe I'll try putting the filer back in
 
Here's a bug: the safe move calculations use x and y directly, but they need to use the x and y of the top bot.
 
Ok blue team, what's up?
I'm going to build a pixel today if I have time, should I get in on the strategy or third-wheel myself onto your formation after you post?
 
If the lead bot is every the bottom bot, then it needs to subtract 1 from its y.
 
12:32 PM
Which safe move? There's two of those. One uses x/y when they're not in formation, and the other depends on if it's top or bottom
 
lol, sorry
 
@Geobits Ehehe we'll see once we try to get this going :D Our x/y should be in the message at all times, so you can make use of that if you want
 
Yea, I was thinking to follow you guys around, maybe try to guard whichever direction you aren't moving in.
 
Oh I see, you default bestmove to 0 and if there's no enemy safe[bestmove] is 1 as is all other entries of safe
So it just chooses 0
That's half the mystery :P
 
I got a new bug on our hands. In the battle currently running. the formation is aligned directly above an enemy, but moves up-right instead of straight down.
 
12:41 PM
Gonna try and change a bit of the decision-making and see how that goes :)
 
New idea: put the coordinates of the center of the formation into Msg, so the follower knows exactly where to go, into the open spot of the formation.
 
There shouldn't be a need for that with the current code though...
I'll see what happens once I do a bit of a rewrite?
 
It looks like, wherever the opponent is, that it moves back and forth.
 
12:57 PM
Ignore the edits, just testing :P
 
Maybe... a problem occurs because when moving sideways, the bottom cell doesn't know to move upwards.
I think that's something.
The Right now the code is
            if (pref[k] > 6){
                setMsg(otherpos + strpos);
                return 13 - pref[k];
            }
 
Yeah, that should work with
if (twinformpos == formpos) {
    formpos = formpos == "T" ? "B" : "T";
}
 
The "13 -" gives the move of the top bot, but what happens when the bottom bot makes the decision?
Are you currently editing?
 
The bottom bot switches position (the lines in the last message) and since it's out of formation it tries to get back into position, using the updated position as its target square
Not currently, but will edit soon
 
Okay
 
1:12 PM
Oh, I am RED not BLUE. Was in a misconception about who are friends and who are foes
 
Be gone, red foe.
3
 
Jakube alone is enough for all of you BLUE B****RDS
 
Well... they seem to move together okay... now to figure out what's wrong with enemies...
 
blue... birds?
 
@Optimizer bluebirds?
Ninja'd
 
1:14 PM
there are more * :/
 
Bluebeards! He's calling us pirates!
 
that's (White|Black)Beard
 
Maybe it's BLUE BI&zwj;&zwj;&zwj;RDS and he's just fooling us around?
 
Maybe we're all just an interactive storybook
 
Ah, I was mixing it up with this Bluebeard.
 
1:19 PM
haha
 
@PhiNotPi I think I know where one of major bugs is, fixing.
 
good
I'm also working on a major re-write.
If you can get the current version working, that's good, but if you can't, we can try out what I'm working on right now.
 
> Display name may only be changed once every 30 days; you may change again in 5 hours
sigh
 
hahahaha
 
:)
 
1:37 PM
@PhiNotPi No worries, you can edit if you want
I'm just going to double check before I try again :)
 
0
Q: Can I answer a challenge twice?

ASCIIThenANSISometimes, I play code-golf or quine, and I find an answer more than once, for two different languages. (I know popularity-contest dosen't count.) Can I post another answer, assuming that the rules of the contest don't say otherwise?

 
1:57 PM
+4 reputation (user was removed) :)
What is a gallery chat room for?
 
@TheBestOne It's read-only, and only approved users (and moderators) can talk.
 
@MartinBüttner Would it be okay if I created a chat room for the Red Team?
 
@TheBestOne Would it be okay if I hung out there? :P
 
Does this mean that the Blue Team successfully conquered the Nineteenth Byte?
 
in Red vs. Blue - Pixel Team Battlebots, 5 mins ago, by TheBestOne
@AdamDavis Just so conversations don't get mixed up.
 
2:06 PM
Merging was going so well before - what did I do to break it :(
 
@Geobits Just as long as you don't hijack it :)
 
Who, me? Why, I'm shocked you would even suggest such as thing...
 
Yes, You :P
 
@Sp3000 May I test out my revisions?
 
Yeah go for it
btw one of the bugs was selfsafe[j] += ((Math.abs(newx - x) + Math.abs(newy - y)) -(Math.abs(newx - targetx) + Math.abs(newy - targety))) + 2;, which should have been more like x - targetx and y - targety for the first two
(basically I was trying to pick the move which would get the block closest to its target)
Actually... I probably don't even need the first bit...
 
2:16 PM
let me fix it
 

 Red Team Chat for Pixel Team Battlebots

Chat for the Red Team to Discuss Strategies for Calvin's Pixel...
 
@Sp3000 I'm using debug messages, and it seems like our bots are going over the time limit of 15ms.
 
!?
That was fast
 
What do we do?
 
You're using chrome, right?
 
2:27 PM
Yes
 
@TheBestOne Why do you need my permission for that? :D
 
@MartinBüttner Just making sure it won't be deleted immediately :)
 
@PhiNotPi One saving would be to use else if for the last block of ifs
But 15ms already? Makes me wonder if it's something else
 
@TheBestOne I don't even have powers to do that (nor do I have any reason to do so... everyone is free to create chatrooms as they see fit)
 
Oh.
 
2:30 PM
Yeah, this really shouldn't be timing out.
Do string equality checks take a lot of time?
 
Not when they're single chars, I hope...
If you want, you can also move the initial selfsafe check to where it's actually needed
i.e. first move/twin dead or out of formation
 
what does |= do in python?
is it var = var | a
 
Like *= but or
For nums, bitwise or. For sets, union.
 
or var = var || a
ok
 
|| is a syntax error, surely?
 
2:34 PM
yes, it is
I meant var or a
 
Yeah it's var = var | a, although a = a + 5 and a += 5 tend to have slightly different meanings
 
depending on if they implement the right functions
aware of that fact :P
 
:P
 
can I implement the | function?
 
For a custom class?
 
2:36 PM
yes
 
I'm doing some optimizations.
But the main concern is that the code, which is timing out, doesn't even reach the part there the formation is moving.
 
@NathanMerrill
class MyNum():
    def __init__(self, n):
        self.n = n

    def __or__(self, other):
        return self.n + other.n

print(MyNum(5) | MyNum(3))
 
wait, is | identical to or?
 
Not the keyword or as in a or b, no
@PhiNotPi If in doubt, remove bits at a time to see what's taking so long?
 
oh, for some reason I thought __or__ would implement or
is it possible for me to implement or?
or is that only boolean
 
2:41 PM
will do
 
huh, read the operator page
apparently all boolean logic is offlimits
 
Yeah I was trying to find it and I don't think or is overridable
The best you can do is reimplement __bool__
 
I think getMsg is really slow.
 
:/ I guess getMsg once and store it is then?
Didn't think that would be a problem
 
Actually, debugging itself is causing stuff to got over the time limit.
 
2:52 PM
... ah
That makes a bit more sense
 
lol
hey, I'm unable to update chrome
 
Whenever getMsg is called, a debug message is created.
 
I've tried restarting it quite a few times, and it never works
...have you guys run into that?
 
Don't think so...
 
I'm creating a new variable "inbox" that'l contain the twin's message.
 
2:56 PM
k
 
It works!
But I think it times out when the follower tries to determine where to move.
(Once they are a unit with a target in sight)
 

« first day (1525 days earlier)      last day (3312 days later) »