The Sheep in Wolf's Clothing
Runs away.
It prioritizes running away from Wolves the most, since they're going to be the most dangerous. Next are Lions, since they're nondeterministic. Bears and Stones are both not at all a problem, but we still run away from them if we have nothing better to do...
One problem with my bot: I'm not sure if it's within the rules for someone to change what letter represents their wolf, but if that happens I'll crash and end up Move.HOLDing if one gets within a space of me.
we discussed this at length last night, heh -- that's one of the challenges. Your bot won't know if it's seeing a friendly wolf or enemy wolf. It's a dog eat dog war!
Sigh. @Geobits that's what I was thinking. Hopefully Rusher wakes up and corrects his spec. I'm trying to build a wrapper and these sorts of things are very important :)
I was hoping to have each of my wolves remember roughly where the animals they've seen last were and prefer the way with the least last-known positions, but the best way to do that seemed like trying to chart out a map which is much easier with a known size.
@undergroundmonorail yeah. As the map size grows, though, algorithms of that sort will get less and less effective. If ROCKS were truly indestructible, you could anchor against them, but sadly, they are not (or happily?)
At the moment, my wolves exclusively throw paper against other wolves. I could, in theory, make a new set that spreads out, seeks wolves and repeatedly throws rock to thin their numbers :P
@JasonC The people over on stats.stackexchange.com are not very impressed with Evan Fisher's approach, as I found out when I asked how to adapt it: stats.stackexchange.com/q/15979/6458
@Rusher @ProgrammerDan I literally never did anything in java before so I'm blocking a bit on the instructions to test my "wolf pack" (that I wrote in R thanks to ProgrammerDan wrapper!). In particular the part where i m supposed to "rebuild" after I added my (compiled?) class to the folder animal. Concretely how am i supposed to do that? is it doable using javac only?
@plannapus If you wrote to spec, I'll whip up a compatible wrapper, no worries. You only have to compile if you want to test locally, and frankly that's going to be hard for people with no Java experience, I haven't thought of a way around that yet :/
@plannapus -- I've got a wrapper for you Rscript program, but currently you aren't flushing your buffers
Consequently your wolves never initialize.
One last issue -- I do not invoke your process on every communication
your process is left running
@plannapus So you need to wait while reading from standard input, and every time you get a new line of input, reply with a new line of output. My Process Wrapper will end your process when the simulation is done.
if your language supports IO blocking on a channel, it will play well with all the others b/c that block frees up CPU as it's handled via interrupt requests (or equiv)
I've added some clarifications, thanks so much for being my guinea pig, @plannapus!
@ProgrammerDan I added the while loop and something to flush the stdout (hope it works: I'm sorry for the "trial-and-error" but, professionally, I'm a paleontologist not a programmer :) so I do lack a formal training in some really basic thing, like typically connections issues)
@plannapus -- I've got to run for now. It's still not flushing right (it seems to be looking for an EOF terminator instead of newline for reading). Basically, you should be able to run it using Rscript and type in the input that my wrapper would send it, and have it return the correct responses to STDOUT
The Problem
I have a bunch of regular expressions that I need to use in some code, but I'm using a programming language that doesn't support regex! Luckily, I know that the test string will have a maximum length and will be composed of printable ASCII only.
The Challenge
You must input a regex...
I did Doorknob's challenge, but I didn't notice the whole "no builtin libraries" requirement.
`import re,itertools,string a=[""];d=raw_input();b=int(raw_input()) while len(a[0])<=b:print[c for c in a if re.match(d,c)];a=["".join(x)for x in itertools.product(a,string.printable)]`
So there's my code, if anyone's interested
It's just rediculously slow, and runs out of memory after about 3 chars ;)
I wonder if I should edit the challenge I just posted then to seed the generator. I don't think it would make much of a difference, because half of the submissions are using their own UNseeded RNG
Nah, because that would be unfair to the answers already posted. I'm just going to suggest an edit to the tag so that obvious to people in the future.
@Quincunx Yes I agree with the PRNG seeds 100%. In particular, I'm wondering why codegolf.stackexchange.com/questions/25226/… is still open; to me it seems invalid. The issues were brought up to the OP a few days ago, but the challenge was never improved.
H9+ : 1 char
9
That's right. One character. Outputs the lyrics to 99 bottles of beer, which is a valid program. All the extraneous data does not count, but there are plenty of 9s in there.
The output of the outputted program is the lyrics to 99 bottles of beer 59 times.
This function gives t...
@Synthetica Maybe? The thing is, and this is just my opinion of course, I feel like a chess competition is sort of as played out as "Is C++ faster than Java?". A PCG championship would be kinda weak compared to the WCCC. That said, who knows? It would definitely attract interesting and good answers. A character limit would put a unique and interesting twist on it.
Why don't you put a short time limit on moves instead? Then it's about the algorithm instead of choosing the least verbose language.
@Quincunx @JasonC Out of curiosity, why do you feel KotH has to be deterministic? Any real life parallels aren't. Take chess/go AIs for example; some of the best in the world use Monte Carlo simulation, and won't play the same against each other every time. In general, it seems that most times serious AI doesn't use some elements of randomness are when the game played has been thoroughly solved and the best strategy is known.
If we force them all to be deterministic, then we might as well do away with any "average of multiple runs" or similar, since that wont matter. In addition, it makes it easier to game for later entrants, since they know exactly what will happen on every single run.
@Geobits It's not that the results have to be deterministic (e.g. if the answers use randomness), it's that I feel the challenge shouldn't implicitly prevent deterministic results. In your example, Chess and Go have specific deterministic rules.
The rules are deterministic, yes. But take the survival challenge. If the scoring program is initially seeded with a known seed, then wolves can all know exactly where they start, so they have the map in hand.
@Geobits An extreme counter example would be, say, a game where a random sequence of numbers was generated and the challenge was to predict the results.
That's true too.
In that case, I'd say, the challenge could be run multiple times, with different seeds, and the winner could be determined by the majority winner over all the runs. It's not perfect, but at least it gives every answer the same ground to start on.
The key there being not letting competitors know the seeds ahead of time.
@Rusher You'd have to make a judgment call depending on the nature of the challenge I suppose. E.g. if you ran it 100 times with different seeds each time and one of the algorithms won 95 times, you could define that as the winner for the purposes of that contest. You could also declare multiple winners if there was a tie, I suppose, if that makes sense.
@Geobits Well, in the 2048 challenge example, each competitor would have a different seed if the clock time was used. It's an odd case because the programs in that challenge don't directly interact.
@Rusher MAP_SIZE not yet implemented, but plannapus' R program is now ready to go. Ran my local test suite and it works quite nicely. Installing R is super easy, too.
@JasonC I would argue that. If the seeds are chosen randomly and the results are significantly different than unseeded, there is a problem with the implementation.
@Geobits It's still a seed. The thing is, that's actually a bit of a counter argument. If you assert that a difference between results with "a randomly chosen seed" vs. "a default seed" implies an implementation error, then you also assert that any difference between any two seeds implies an implementation error. Which goes back to support my original point of "differing results between different seeds = invalid".
@Rusher That's a great idea. What about pick a seed, run the trial, repeat, say, 100 times. If there's no consistent winner(s), keep repeating until some winning threshold is exceeded?
But that still falls back to "different winners for different seeds" if you're using the same seed 100 times.
I think a better idea would be to separately generate 100 'random' seeds. If there's no clear winner, repeat. At least then you have a known list of seeds you can publish.
@Geobits Different seed each time is what I meant. Run the entire competition with one seed, then choose a new seed and rerun the entire competition, 100 times.
@ProgrammerDan I added MAP_SIZE this morning. I don't know how I missed that. And suprisingly, only a couple of people missed it (or the rest weren't too vocal). I hope that knowing the size of the map won't confer much of an advantage anyway.
Just to be clear I'm referring to competitions where a random starting point is given, the "seed" I'm speaking of is a global seed used to generate the starting point for each competitor, so that each competitor has the same starting point on a given run of the competition.
@Geobits I also feel that answers should be deterministic. Yes, others may wish to run results many many times, but I think that it should be easy to order the programs in order of best performance to worst performance. If we allow non-deterministic behavior, it would vary depending on the number of times the tests are run.
@Rusher Nice. Yeah, I actually had it as part of the spec initially, if you look through my git log. Then realized you hadn't implemented it, and removed it.
BTW, do any you think a new version of the 2048 question would be a valid new question, if: 1. It allowed multiple languages, and 2. was seeded/deterministic?
@Synthetica I would have no qualms about posting one. That is completely independent of whether or not it's actually "valid" and how it would be received, heh. For what it's worth, though, you'd have my vote.
@Rusher Do you object to Scala submissions for your Survival game? I could provide a link to the compiled class and the scala-library.jar to include in the class path with my answer if you don't have Scala installed.
He made it pretty easy to communicate with just about any language. If you opt not to use it, just include some instructions for how I can add your submission.
I didn't think I'd need it because Scala runs on the JVM. I've got it working with your Game on my machine by compiling my Wolf and putting it in with the Java wolves. Then I just added the scala-library.jar to the class path when running the game. I'll include this in my answer and if it causes you problems, I'll look at the wrapper class.