caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Problem with Graph module
@ 2002-06-17  1:12 Nicolas FRANCOIS
  2002-06-17 13:23 ` Jun P.FURUSE
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas FRANCOIS @ 2002-06-17  1:12 UTC (permalink / raw)
  To: Caml List

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-06-18 23:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-17  1:12 [Caml-list] Problem with Graph module Nicolas FRANCOIS
2002-06-17 13:23 ` Jun P.FURUSE
2002-06-17 17:47   ` [Caml-list] Nicolas FRANCOIS
2002-06-18  9:48     ` [Caml-list] Re: Problem with Graph module Jun P.FURUSE
2002-06-18 17:01       ` Nicolas FRANCOIS
2002-06-18 23:21         ` Nicolas FRANCOIS

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).