[Icfp04-discuss] Unofficial Tournament
Eijiro Sumii
sumii at saul.cis.upenn.edu
Mon Jun 21 13:37:05 EDT 2004
From: "Rares Ispas" <rares at raisoftware.ro>
> Vox populi, vox Dei. If 10 people express their desire to work on
> next-generation ants, we will revive the tournament. Open only for ants
> not submitted to ICFP.
As Benjamin mentioned, even we organizers may submit some of our own
ants if people don't mind!
By the way, I remember the tournament web page used to mention it does
_not_ implement the same random number generation as described in the
task description. For reference, here is an implementation in C
(dependent on >= 31-bit int):
/**********************************************************************/
static int seed = 0;
void mysrand(int s) {
printf("random seed: %d\n", s);
seed = s;
(void) myrand();
(void) myrand();
(void) myrand();
}
int myrand() {
int r;
seed = seed * 22695477 + 1;
r = (seed >> 16) & 0x3fff;
/* printf("random number: %d\n", r); */
return r;
}
/**********************************************************************/
And in OCaml (also dependent on >= 31-bit int):
(**********************************************************************)
let seed = ref 0
let int p =
seed := !seed * 22695477 + 1;
let r = (!seed asr 16) land 0x3fff in
(* Format.eprintf "random number: %d at ." r; *)
r mod p
let init s =
Format.eprintf "random seed: %d at ." s;
seed := s;
ignore(int 1);
ignore(int 1);
ignore(int 1)
(**********************************************************************)
Have fun,
--
Eijiro Sumii (http://www.cis.upenn.edu/~sumii/)
Department of Computer and Information Science, University of Pennsylvania
More information about the Icfp04-discuss
mailing list