This site is updated infrequently. For up-to-date information, please visit the new OCaml website at ocaml.org.

[Caml-list] Problem with Graph module
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
 Date: 2002-06-17 (01:04) From: Nicolas FRANCOIS Subject: [Caml-list] Problem with Graph module
```A strange thing, under Linux : this piece of code :

open Graphics;;
open Random;;

type t_fourmi = {mutable dir : int;
mutable x : int;
mutable y : int};;

let trace_fourmi_deux_etats n =
let mouvement = [|(0, 5); (-5, 0); (0, -5); (5, 0)|] in
let init = open_graph " 800x800+50-50" in
let ma_fourmi = {dir = 0; x = 349; y = 349} in
let onestep () =
if (point_color ma_fourmi.x ma_fourmi.y) = white
then
begin
set_color black;
ma_fourmi.dir <-
if ma_fourmi.dir + 1 > 3 then 0 else ma_fourmi.dir + 1
end
else
begin
set_color white;
ma_fourmi.dir <-
if ma_fourmi.dir - 1 < 0 then 3 else ma_fourmi.dir - 1
end;
fill_rect ma_fourmi.x ma_fourmi.y 5 5;
let (dx, dy) = mouvement.(ma_fourmi.dir) in
ma_fourmi.x <- ma_fourmi.x + dx;
ma_fourmi.y <- ma_fourmi.y + dy;
in
init;
for i = 0 to n do
onestep ();
for j = 1 to 10000 do begin end done
done;;

trace_fourmi_deux_etats 10000;;

works perfectly in camllight (with a few modifications to adapt the code),
but not in Ocaml. The graphic window opens well, but the test

if (point_color ma_fourmi.x ma_fourmi.y) = white

is allways false under Ocaml.

Can you see the problem ?????

Thanks.

--

Nicolas FRANCOIS
http://nicolas.francois.free.fr
A TRUE Klingon programmer does NOT comment his code
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

```