swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: scripting support for swarm ?


From: J. McKenzie Alexander
Subject: RE: scripting support for swarm ?
Date: Tue, 11 Dec 2001 18:43:17 -0800

Hi Daniel,

I don't know what, exactly, you have in mind by a scripting language, but if
you are using the Objective C interface to Swarm, you can use tcl/tk as a
scripting language to send messages to objects.

It works like this: every object derived from SwarmObject is made accessible
by the global tcl/tk interpreter by (1) having a unique "tag" assigned to it
(of the form "address@hidden") and, (2) using that tag to define a
new tcl/tk function, which accepts as arguments names of the object's
methods.

For example, suppose you have

#import <objectbase/SwarmObject.h>
@interface Foo: SwarmObject
{
  int oneValue;
  int twoValue;
  int threeValue;
}
- (void) setValuesOne: (int) one Two: (int) two Three: (int) three;
- createEnd;
- (int) getOneValue;
- (int) getTwoValue;
- (int) getThreeValue;
@end

with the methods defined as you'd expect.  You can access those from the
tcl/tk interface as follows:

{
  // Create the object Foo
  id aFoo = [Foo create: scratchZone];
  [aFoo setValuesOne: 10 Two: 25 Three: 30];

  // Get aFoo's tcl/tk name
  char *fooName = [aFoo getObjectName];

  // Access the object through tcl/tk
  char cmd[256];
  sprintf( cmd, "puts [%s getOneValue]", fooName);

  [globalTkInterp eval: cmd];
}

This should work.  Of course, you can do much more interesting things then
this, but this gets the basic idea across.  I've posted a more complete
example showing how to create a custom control panel (along with a
interactive canvas) at
http://evolve.lse.ac.uk/jalex/misc/replicator-0.9.tar.gz.  That model
implements an interactive simplex for the three-strategy discrete replicator
dynamics for an arbitrary game.  Left-click on the simplex to add a path,
middle-click to delete it, and right-click to open up a dialog box.
(Currently the model crashes if you try to interact with the pop-up dialog
box... haven't fixed that yet.)

So, at least in some minimal sense, you already have a scripting language,
of a sort...

Cheers,

Jason

--
J. McKenzie Alexander
Co-ordinator, MSc Philosophy of the Social Sciences
Department of Philosophy, Logic and Scientific Method
London School of Economics and Political Science
Houghton Street
London WC2A 2AE


-----Original Message-----
From: address@hidden
[mailto:address@hidden Behalf Of daniel kottow
Sent: 11 December 2001 09:57
To: address@hidden
Subject: scripting support for swarm ?



hello everybody,

and specially to marcus since this question mainly adresses an issue
mentioned in the swarm tech report 2000. i am very interesting in making my
swarm-objects (written in objective C) accessible through a scripting
language. i saw that there are plans/code to support scheme in
future/present releases, although i couldn't find any looking superficially
through the latest tar-file swarm-2001-12-07.tar.gz :-(

my idea is basically to run my simulations from a command line of an
interpreter, invoking (at least) the methods bound currently to the control
panel plus adding object/parameter inspection/manipulation for the most
important simulation elements. i thought about using python for this (since
i believe python to have nice numeric capabilities), but it seems like
SWIG, a wrapper library for exposing "low-level" libraries to scripting
languages doesnt support objective C at the moment (and maybe never will
anymore, because of lack of interest, they claim).

my question is: is my approach similar (or compatible) with the scripting
capabilites planned for swarm ? is there any (realtively straightforward)
way to make a swarm simulation run from a guile command line ? otherwise, i
still could think of wrapping some methods in C and then calling them from
python... or are there any other people who have used or thought of similar
approaches ?

greetings, daniel

--
Daniel Kottow                                    address@hidden
Security and Testing Technology
http://vision.fhg.de/~daniel
Production Technology Centre                     Pascalstr. 8 - 9
Fraunhofer-Institut IPK Berlin                   D - 10587 Berlin



                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]