[Icfp04-discuss] Scheme, Ruby ?
Alejandro Forero Cuervo
bachue at bachue.com
Wed Jun 16 12:39:33 EDT 2004
Hi.
> Why you decided to generate bitmap images instead of using
> vector graphics ? Have not found apropriate vector graphics
> library for Scheme ?
We used PNM format because we thought it would be the solution
that would take us the least time to implement (we had used that
format relatively frequently in the past). It took around 100
lines plus a few definitions for the actual images that the
render is made of.
Another option we considered was generating SWF (Flash) files.
This would probably allow us to control the visualization more
directly (such as interactively changing its speed) but it would
probably have taken more time.
We can generate Flash files with SWFTools from our PNMs.
Animations stored in this format have about 1/10th the size they
have when stored as GIF files (created with ImageMagick). Of
course, this wasn't a concern during the contest. There is a
sample in:
<http://www.crazyrobot.net/anim.swf>
> Have you tried "Scheme Widget Library (SWL)" [
> http://www.scheme.com/contributed.html ] for visualization
> ? It can be used with Petite Chez Scheme [
> http://www.scheme.com/petitecs.html ]
I have not tried it. I don't know about the other members in
our team, but not having free (libre) access to our Scheme
implementation would be a price too big to pay for being
able to use that library. Of course, porting it to another
implementation is always an option.
> > Our simulator took around 30 secs to run a 100.000 rounds
> > match. We didn't spend any time optimizing it.
>
> It would be interesting to profile your simulator to find the
> code consuming most of the time in a single round. What
> structure you used to represent ant world in Scheme ?
It can certainly be optimized.
; markers is a bitmask. The first 6 bits are for the
; red ants, the second 6 bits for the black ones.
(define-record mapinfo terrain food ant markers)
; type is a boolean, with #t for red, #f for black
; food is a boolean (#t means it has food).
; alive is a boolean
(define-record ant x y dir food type state rest alive)
We use a global variable *map* with a vector of vectors of
mapinfo records.
Things that I would optimize:
- Movement and senses. Some (case ...) forms could be
eliminated.
- Parsing tokens directly as they are read. There are some
computations that are done during the execution of the rounds
but could be done as the instructions are read. This would
involve rewriting read-ant-state and the *-exec functions. I
might do that latter and check if it actually improves things.
- Compiling the code with -optimize-level 3 -usual-integrations
-unsafe -block -fixnum-arithmetic -lambda-lift and other
similar arguments.
I might apply some of these changes and see if they actually
improve things. I know, I should use a profiler first.
The reason we didn't optimize our simulator is mostly because we
were not very interested in doing genetic programming. We
decided time spent writing ants was better than time spent
optimizing our simulator (given that 30 secs was a decent time
for it to take).
> (I couldn't access your repository at:
> http://anonymous:@svn.afc.no-ip.info:8000/svn/home/src/icfp/)
Sorry, it probably means my machine was offline (as it gets every
night (GMT-5)).
Alejo.
http://bachue.com/alejo
---=( Comunidad de Usuarios de Software Libre en Colombia )=---
---=( http://bachue.com/colibri )=--=( colibri at bachue.com )=---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.seas.upenn.edu/pipermail/icfp04-discuss/attachments/20040616/44a830c3/attachment.bin
More information about the Icfp04-discuss
mailing list