|
From: <jom...@us...> - 2008-04-20 20:16:55
|
Revision: 1233
http://jason.svn.sourceforge.net/jason/?rev=1233&view=rev
Author: jomifred
Date: 2008-04-20 13:16:53 -0700 (Sun, 20 Apr 2008)
Log Message:
-----------
update jason team
add massim monitor
Modified Paths:
--------------
trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
trunk/applications/jason-team/massim-agents/demoAgent.jar
trunk/applications/jason-team/src/asl/dummy.asl
trunk/applications/jason-team/src/java/agent/UniqueBelsBB.java
trunk/applications/jason-team/src/java/arch/ACArchitecture.java
trunk/applications/jason-team/src/java/arch/ACProxy.java
trunk/applications/jason-team/src/java/arch/CowboyArch.java
trunk/applications/jason-team/src/java/arch/LocalWorldModel.java
trunk/applications/jason-team/src/java/env/WorldModel.java
trunk/applications/jason-team/src/java/env/WorldView.java
trunk/applications/jason-team/src/java/jia/Search.java
trunk/applications/jason-team/src/java/jia/Vec.java
trunk/applications/jason-team/src/java/jia/herd_position.java
trunk/applications/jason-team/src/java/test/TestBasicHerding.java
Added Paths:
-----------
trunk/applications/jason-team/doc/scenario-r4.pdf
trunk/applications/jason-team/massim-server/massim/rmi/
trunk/applications/jason-team/massim-server/massim/rmi/SimulationStateServer.class
trunk/applications/jason-team/massim-server/massim/rmi/SimulationStateServerObserver$SimulationStateServerImplementation.class
trunk/applications/jason-team/massim-server/massim/rmi/SimulationStateServerObserver.class
trunk/applications/jason-team/massim-server/massim/rmi/StringMapServer.class
trunk/applications/jason-team/massim-server/massim/rmi/XMLDocumentObserver$XMLDocumentServerImplementation.class
trunk/applications/jason-team/massim-server/massim/rmi/XMLDocumentObserver.class
trunk/applications/jason-team/massim-server/massim/rmi/XMLDocumentServer.class
trunk/applications/jason-team/massim-servermonitor/
trunk/applications/jason-team/massim-servermonitor/LICENSE
trunk/applications/jason-team/massim-servermonitor/README
trunk/applications/jason-team/massim-servermonitor/massimServerMonitor.jar
trunk/applications/jason-team/massim-servermonitor/startMonitor.sh
Removed Paths:
-------------
trunk/applications/jason-team/doc/scenario-r3.pdf
Modified: trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
===================================================================
--- trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-04-20 20:13:53 UTC (rev 1232)
+++ trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-04-20 20:16:53 UTC (rev 1233)
@@ -11,7 +11,7 @@
agents:
gaucho1 dummy.asl
- [verbose=1, gui=no, write_status=yes, ac_sim_back_dir="./massim-server/backup",
+ [verbose=1, gui=yes, write_status=yes, ac_sim_back_dir="./massim-server/backup",
host="localhost", port=12300, username=participant1, password="1"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
Deleted: trunk/applications/jason-team/doc/scenario-r3.pdf
===================================================================
(Binary files differ)
Added: trunk/applications/jason-team/doc/scenario-r4.pdf
===================================================================
(Binary files differ)
Property changes on: trunk/applications/jason-team/doc/scenario-r4.pdf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/applications/jason-team/massim-agents/demoAgent.jar
===================================================================
(Binary files differ)
Added: trunk/applications/jason-team/massim-server/massim/rmi/SimulationStateServer.class
===================================================================
(Binary files differ)
Property changes on: trunk/applications/jason-team/massim-server/massim/rmi/SimulationStateServer.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/applications/jason-team/massim-server/massim/rmi/SimulationStateServerObserver$SimulationStateServerImplementation.class
===================================================================
(Binary files differ)
Property changes on: trunk/applications/jason-team/massim-server/massim/rmi/SimulationStateServerObserver$SimulationStateServerImplementation.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/applications/jason-team/massim-server/massim/rmi/SimulationStateServerObserver.class
===================================================================
(Binary files differ)
Property changes on: trunk/applications/jason-team/massim-server/massim/rmi/SimulationStateServerObserver.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/applications/jason-team/massim-server/massim/rmi/StringMapServer.class
===================================================================
(Binary files differ)
Property changes on: trunk/applications/jason-team/massim-server/massim/rmi/StringMapServer.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/applications/jason-team/massim-server/massim/rmi/XMLDocumentObserver$XMLDocumentServerImplementation.class
===================================================================
(Binary files differ)
Property changes on: trunk/applications/jason-team/massim-server/massim/rmi/XMLDocumentObserver$XMLDocumentServerImplementation.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/applications/jason-team/massim-server/massim/rmi/XMLDocumentObserver.class
===================================================================
(Binary files differ)
Property changes on: trunk/applications/jason-team/massim-server/massim/rmi/XMLDocumentObserver.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/applications/jason-team/massim-server/massim/rmi/XMLDocumentServer.class
===================================================================
(Binary files differ)
Property changes on: trunk/applications/jason-team/massim-server/massim/rmi/XMLDocumentServer.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/applications/jason-team/massim-servermonitor/LICENSE
===================================================================
--- trunk/applications/jason-team/massim-servermonitor/LICENSE (rev 0)
+++ trunk/applications/jason-team/massim-servermonitor/LICENSE 2008-04-20 20:16:53 UTC (rev 1233)
@@ -0,0 +1,353 @@
+###############################################################
+# Multi-Agent Programming Contest 2008 #
+# #
+# Support package MASSim servermonitor #
+# LICENSE file for the MASSim servermonitor package #
+# #
+# For the details on the contest, check the Contest website: #
+# http://cig.in.tu-clausthal.de/agentcontest2008/ #
+# #
+# Organizers: #
+# J. Dix, M. Dastani, P. Novak, T.M. Behrens #
+###############################################################
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
Added: trunk/applications/jason-team/massim-servermonitor/README
===================================================================
--- trunk/applications/jason-team/massim-servermonitor/README (rev 0)
+++ trunk/applications/jason-team/massim-servermonitor/README 2008-04-20 20:16:53 UTC (rev 1233)
@@ -0,0 +1,58 @@
+###############################################################
+# Multi-Agent Programming Contest 2008 #
+# #
+# Support package MASSim servermonitor #
+# README file for the MASSim servermonitor package #
+# #
+# For the details on the contest, check the Contest website: #
+# http://cig.in.tu-clausthal.de/agentcontest2008/ #
+# #
+# Organizers: #
+# J. Dix, M. Dastani, P. Novak, T.M. Behrens #
+###############################################################
+
+MASSim servermonitor package.
+
+1. Prerequisites.
+
+You only need the sun-java5 / sun-java6 (jre and jdk) installed to run the server.
+
+2. Installing and running.
+
+·Unpack the file anywhere:
+ tar xzvf massim-ServerMonitor-version.tag.gz -C output_dir
+
+·Switch to the new directory:
+ cd output_dir/massim-ServerMonitor
+
+·Run the script provided in the package:
+ ./startMonitor.sh
+
+3. Options.
+You can pass to startMonitor.sh script any of the following parameters:
+ --help Displays the help
+ --host <RMI hostname> Hostname of the computer where the massim-server is running
+ --port <RMI port> Port of the rmiregistry
+ --service <RMI servicename> See 4 for details
+ --sleeptime <time> Thread sleeptime in ms
+ --disable-stylesheets Disables reading of configfile and stylesheet use
+ --conf <configfile>
+
+If no parameters are given default values will be used.
+Default values:
+ host = localhost
+ port = 1099
+ service = xmlsimulation
+ sleeptime = 10000ms
+ conf = configfile contained in servermonitor.jar
+
+4. RMI servicesnames
+ xmlsimulation Simulation dependend statistics (number of steps, agentscores, ...)
+ statistics Statistics for the tournament (ranking, results of simulations, ...)
+ server2 Statistics of connected agents (name, port, ip)
+
+5. Questions, problems, suggestions, ...
+
+please, ask to the Agent Contest 2008 mail-list agentcontest2008-general [at] in.tu-clausthal.de
+or for more fast communication: jens.dehnert [at] tu-clausthal.de or slawomir.deren [at] tu-clausthal.de
+
Added: trunk/applications/jason-team/massim-servermonitor/massimServerMonitor.jar
===================================================================
(Binary files differ)
Property changes on: trunk/applications/jason-team/massim-servermonitor/massimServerMonitor.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/applications/jason-team/massim-servermonitor/startMonitor.sh
===================================================================
--- trunk/applications/jason-team/massim-servermonitor/startMonitor.sh (rev 0)
+++ trunk/applications/jason-team/massim-servermonitor/startMonitor.sh 2008-04-20 20:16:53 UTC (rev 1233)
@@ -0,0 +1,8 @@
+###################################
+#!/bin/sh #
+###################################
+
+clear
+
+echo "Launching Monitor"
+java -jar massimServerMonitor.jar $*
\ No newline at end of file
Property changes on: trunk/applications/jason-team/massim-servermonitor/startMonitor.sh
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/applications/jason-team/src/asl/dummy.asl
===================================================================
--- trunk/applications/jason-team/src/asl/dummy.asl 2008-04-20 20:13:53 UTC (rev 1232)
+++ trunk/applications/jason-team/src/asl/dummy.asl 2008-04-20 20:16:53 UTC (rev 1233)
@@ -29,44 +29,60 @@
not jia.obstacle(X,Y).
// whether some location X,Y has an agent and I am near that location
+/*
agent_in_target :-
pos(AgX,AgY,_) &
target(TX,TY) &
(cell(TX,TY,ally(_)) | cell(TX,TY,enemy(_)) | cell(TX,TY,cow(_))) &
jia.dist(TX,TY,AgX,AgY,D) &
D <= 2. // this number should be the same used by A* (DIST_FOR_AG_OBSTACLE constant)
+*/
/* -- initial goal */
-!move.
+!decide_target.
-/* -- reaction to cows -- */
+/* -- reaction to some perceptions -- */
+// revise target when see first cow
+pos(_,_,_) // new cycle
- : cell(_,_,cow(_)) // I see cows
+ : goal(search) & cell(_,_,cow(_)) // I see cows and was searching
<- !decide_target.
+
+// revise target each 4 steps
++pos(Step,_,_) // new cycle
+ : Step mod 4 == 0
+ <- !decide_target.
-/* -- what todo when arrive at location */
+/* -- decide a new target -- */
++!decide_target
+ : not pos(_,_,_)
+ <- .print("waiting my location....");
+ .wait("+pos(_,_,_)");
+ !decide_target.
+
+!decide_target
- : jia.herd_position(X,Y) & // compute new location
- (not target(_,_) | (target(TX,TY) & (TX \== X | TY \== Y))) // no target OR new target?
- <- .print("COWS! going to ",X,",",Y," previous target ",TX,",",TY);
+ : jia.herd_position(six,X,Y) //& // compute new location
+ //(not target(_,_) | (target(TX,TY) & (TX \== X | TY \== Y))) // no target OR new target
+ <- .print("COWS! going to ",X,",",Y); //," previous target ",TX,",",TY);
+ -+goal(herd);
-+target(X,Y).
+!decide_target // chose a new random pos
: not cell(_,_,cow(_))
<- ?random_pos(NX,NY);
.print("New random target: ",NX,",",NY);
+ -+goal(search);
-+target(NX,NY).
+
+//+!decide_target
+// <- .print("No need for a new target, consider last herding location.");
+// do(skip). // send an action so that the simulator does not wait for me.
-+!decide_target
- <- .print("No need for a new target, consider last herding location.");
- do(skip). // send an action so that the simulator does not wait for me.
-
/* -- plans to move to a destination represented in the belief target(X,Y)
-- (it is a kind of persistent goal)
*/
@@ -84,8 +100,28 @@
.wait("+pos(_,_,_)");
!move.
++!move
+ : not target(_,_)
+ <- .print("waiting my target....");
+ .wait("+target(_,_)");
+ !move.
+
++!move
+ : pos(X,Y,_) & target(X,Y) // I am at target
+ <- -+at_target;
+ do(skip);
+ !!move.
+
+// does one step towards target
++!move
+ : pos(X,Y,_) &
+ target(BX,BY) &
+ jia.direction(X, Y, BX, BY, D) // jia.direction finds one action D (using A*) towards the target
+ <- do(D); // this action will "block" the intention until it is sent to the simulator (in the end of the cycle)
+ !!move. // continue moving
+
// find a new destination
-+!move
+/*+!move
: pos(X,Y,_) &
(not target(_,_) | // I have no target OR
target(X,Y) | // I am at target OR
@@ -93,26 +129,18 @@
agent_in_target | // there is an agent in the target
(target(BX,BY) & jia.direction(X, Y, BX, BY, skip))) // is impossible to go to target
<- !decide_target.
-
-// does one step towards target
-+!move
- : pos(X,Y,_) &
- target(BX,BY) &
- jia.direction(X, Y, BX, BY, D) // jia.direction finds one action D (using A*) towards the target
- <- do(D); // this action will "block" the intention until it is sent to the simulator (in the end of the cycle)
- !!move. // continue moving
+*/
// in case of failure, move
-!move
<- .current_intention(I); .println("failure in move, intention: ",I);
!move.
-
+restart
<- .print("*** restart ***");
.drop_all_desires;
.abolish(target(_,_));
- !move.
+ !decide_target.
/* -- tests -- */
Modified: trunk/applications/jason-team/src/java/agent/UniqueBelsBB.java
===================================================================
--- trunk/applications/jason-team/src/java/agent/UniqueBelsBB.java 2008-04-20 20:13:53 UTC (rev 1232)
+++ trunk/applications/jason-team/src/java/agent/UniqueBelsBB.java 2008-04-20 20:16:53 UTC (rev 1233)
@@ -45,7 +45,7 @@
Literal linbb = null;
boolean remove = false;
- Iterator<Literal> relevant = getRelevant(bel);
+ Iterator<Literal> relevant = getCandidateBeliefs(bel, null);
if (relevant != null) {
final int kbArity = kb.getArity();
while (relevant.hasNext() && !remove) {
Modified: trunk/applications/jason-team/src/java/arch/ACArchitecture.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/ACArchitecture.java 2008-04-20 20:13:53 UTC (rev 1232)
+++ trunk/applications/jason-team/src/java/arch/ACArchitecture.java 2008-04-20 20:16:53 UTC (rev 1233)
@@ -144,7 +144,10 @@
void newCycle() {
String w = "";
- if (lastActionInCurrentCycle == null) w = "*** ";
+ if (lastActionInCurrentCycle == null) {
+ w = "*** ";
+ addRestart();
+ }
logger.info(w+"Last sent action was "+lastActionInCurrentCycle+" for cycle "+getCycle()+". The following was not sent: "+toExecute);
setLastAct(lastActionInCurrentCycle);
Modified: trunk/applications/jason-team/src/java/arch/ACProxy.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/ACProxy.java 2008-04-20 20:13:53 UTC (rev 1232)
+++ trunk/applications/jason-team/src/java/arch/ACProxy.java 2008-04-20 20:16:53 UTC (rev 1233)
@@ -160,7 +160,7 @@
lpos.addTerm(new NumberTermImpl(step));
percepts.add(lpos);
- arq.getModel().clearCowsList();
+ arq.initKnownCows();
int enemyId = 1;
// add in perception what is around
@@ -211,12 +211,13 @@
}
}
- //if (logger.isLoggable(Level.FINE))
- logger.info("Request action for "+lpos+" / "+rid + " percepts: "+percepts);
arq.perceptionRatioPerceived(maxx);
+ arq.sendCowsToTeam();
arq.startNextStep(step, percepts);
+ //if (logger.isLoggable(Level.FINE))
+ logger.info("Request action for "+lpos+" / percepts: "+percepts);
} catch (Exception e) {
logger.log(Level.SEVERE, "error processing request",e);
}
Modified: trunk/applications/jason-team/src/java/arch/CowboyArch.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-04-20 20:13:53 UTC (rev 1232)
+++ trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-04-20 20:16:53 UTC (rev 1233)
@@ -13,6 +13,7 @@
import jason.mas2j.ClassParameters;
import jason.runtime.Settings;
+import java.util.Collection;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -83,6 +84,10 @@
simId = id;
}
+ public boolean hasGUI() {
+ return gui;
+ }
+
public int getMyId() {
if (myId < 0) {
myId = getAgId(getAgName());
@@ -162,7 +167,8 @@
lo3 = new Location(-1,-1),
lo4 = new Location(-1,-1),
lo5 = new Location(-1,-1),
- lo6 = new Location(-1,-1);
+ lo6 = new Location(-1,-1),
+ lo7 = new Location(-1,-1);
Location oldLoc;
@@ -203,6 +209,7 @@
}
}
+ lo7 = lo6;
lo6 = lo5;
lo5 = lo4;
lo4 = lo3;
@@ -211,23 +218,27 @@
lo1 = new Location(x,y);
if (isRobotFrozen()) {
- try {
- logger.info("** Arch adding restart for "+getAgName());
- getTS().getC().create();
-
- getTS().getAg().getBB().abolish(new Literal("restart").getPredicateIndicator());
- getTS().getAg().addBel(new Literal("restart"));
- lo2 = new Location(-1,-1); // to not restart again in the next cycle
- } catch (Exception e) {
- logger.info("Error in restart!"+ e);
- }
+ addRestart();
}
}
/** returns true if the agent do not move in the last 5 location perception */
public boolean isRobotFrozen() {
- return lo1.equals(lo2) && lo2.equals(lo3) && lo3.equals(lo4) && lo4.equals(lo5) && lo5.equals(lo6);
+ return lo1.equals(lo2) && lo2.equals(lo3) && lo3.equals(lo4) && lo4.equals(lo5) && lo5.equals(lo6) && lo6.equals(lo7);
}
+
+ protected void addRestart() {
+ try {
+ logger.info("** Arch adding restart for "+getAgName());
+ getTS().getC().create();
+
+ getTS().getAg().getBB().abolish(new Literal("restart").getPredicateIndicator());
+ getTS().getAg().addBel(new Literal("restart"));
+ lo2 = new Location(-1,-1); // to not restart again in the next cycle
+ } catch (Exception e) {
+ logger.info("Error in restart!"+ e);
+ }
+ }
public static Literal createCellPerception(int x, int y, Term obj) {
Literal l = new Literal("cell");
@@ -237,9 +248,23 @@
return l;
}
+ private static final Literal cowstoclean = Literal.parseLiteral("cell(_,_,cow(_))");
+ synchronized void initKnownCows() throws RevisionFailedException {
+ model.clearCows();
+ getTS().getAg().abolish(cowstoclean, null);
+ }
void cowPerceived(int x, int y) {
model.addCow(x,y);
}
+
+ void sendCowsToTeam() {
+ try {
+ Message m = new Message("tell-cows", null, null, model.getCows());
+ broadcast(m);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
void enemyPerceived(int x, int y) {
model.add(WorldModel.ENEMY, x, y);
@@ -276,8 +301,9 @@
}
}
+ @SuppressWarnings("unchecked")
@Override
- public void checkMail() {
+ synchronized public void checkMail() {
try {
super.checkMail();
@@ -286,38 +312,45 @@
Iterator<Message> im = getTS().getC().getMailBox().iterator();
while (im.hasNext()) {
Message m = im.next();
- String ms = m.getPropCont().toString();
- if (ms.startsWith("cell") && ms.endsWith("obstacle)") && model != null) {
- Literal p = (Literal)m.getPropCont();
- int x = (int)((NumberTerm)p.getTerm(0)).solve();
- int y = (int)((NumberTerm)p.getTerm(1)).solve();
- if (model.inGrid(x,y)) {
- model.add(WorldModel.OBSTACLE, x, y);
- if (acView != null) acView.addObject(WorldModel.OBSTACLE, x, y);
+ if (m.getIlForce().equals("tell-cows")) {
+ for (Location l: (Collection<Location>)m.getPropCont()) {
+ cowPerceived(l.x, l.y);
}
im.remove();
- //getTS().getAg().getLogger().info("received obs="+p);
-
- } else if (ms.startsWith("my_status") && model != null) {
- // update others location
- Literal p = Literal.parseLiteral(m.getPropCont().toString());
- int x = (int)((NumberTerm)p.getTerm(0)).solve();
- int y = (int)((NumberTerm)p.getTerm(1)).solve();
- if (model.inGrid(x,y)) {
- try {
- int agid = getAgId(m.getSender());
- model.setAgPos(agid, x, y);
- if (acView != null) acView.getModel().setAgPos(agid, x, y);
- model.incVisited(x, y);
- //getTS().getAg().getLogger().info("ag pos "+getMinerId(m.getSender())+" = "+x+","+y);
- Structure tAlly = new Structure("ally");
- tAlly.addTerm(new Atom(m.getSender()));
- getTS().getAg().addBel( createCellPerception(x, y, tAlly));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- im.remove();
+ } else {
+ String ms = m.getPropCont().toString();
+ if (ms.startsWith("cell") && ms.endsWith("obstacle)") && model != null) {
+ Literal p = (Literal)m.getPropCont();
+ int x = (int)((NumberTerm)p.getTerm(0)).solve();
+ int y = (int)((NumberTerm)p.getTerm(1)).solve();
+ if (model.inGrid(x,y)) {
+ model.add(WorldModel.OBSTACLE, x, y);
+ if (acView != null) acView.addObject(WorldModel.OBSTACLE, x, y);
+ }
+ im.remove();
+ //getTS().getAg().getLogger().info("received obs="+p);
+
+ } else if (ms.startsWith("my_status") && model != null) {
+ // update others location
+ Literal p = Literal.parseLiteral(m.getPropCont().toString());
+ int x = (int)((NumberTerm)p.getTerm(0)).solve();
+ int y = (int)((NumberTerm)p.getTerm(1)).solve();
+ if (model.inGrid(x,y)) {
+ try {
+ int agid = getAgId(m.getSender());
+ model.setAgPos(agid, x, y);
+ if (acView != null) acView.getModel().setAgPos(agid, x, y);
+ model.incVisited(x, y);
+ //getTS().getAg().getLogger().info("ag pos "+getMinerId(m.getSender())+" = "+x+","+y);
+ Structure tAlly = new Structure("ally");
+ tAlly.addTerm(new Atom(m.getSender()));
+ getTS().getAg().addBel( createCellPerception(x, y, tAlly));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ im.remove();
+ }
}
}
} catch (Exception e) {
Modified: trunk/applications/jason-team/src/java/arch/LocalWorldModel.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-04-20 20:13:53 UTC (rev 1232)
+++ trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-04-20 20:16:53 UTC (rev 1233)
@@ -3,8 +3,11 @@
import jason.environment.grid.Location;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
import java.util.Random;
+import java.util.Set;
import env.WorldModel;
@@ -21,7 +24,7 @@
private Random random = new Random();
- List<Location> cows = new ArrayList<Location>();
+ Set<Location> cows = new HashSet<Location>();
//private Logger logger = Logger.getLogger("jasonTeamSimLocal.mas2j." + LocalWorldModel.class.getName());
@@ -44,7 +47,8 @@
}
}
- public void clearCowsList() {
+ public void clearCows() {
+ removeAll(WorldModel.COW);
cows.clear();
}
public void addCow(int x, int y) {
@@ -54,7 +58,7 @@
public void addCow(Location l) {
addCow(l.x, l.y);
}
- public List<Location> getCows() {
+ public Collection<Location> getCows() {
return cows;
}
@@ -75,6 +79,18 @@
}
}
+ public int countObjInArea(int obj, Location startPoint, int size) {
+ int c = 0;
+ for (int x = startPoint.x-size; x <= startPoint.x+size; x++) {
+ for (int y = startPoint.y-size; y <= startPoint.y+size; y++) {
+ if (hasObject(obj, x, y)) {
+ c++;
+ }
+ }
+ }
+ return c;
+ }
+
public int getVisited(Location l) {
return visited[l.x][l.y];
}
Modified: trunk/applications/jason-team/src/java/env/WorldModel.java
===================================================================
--- trunk/applications/jason-team/src/java/env/WorldModel.java 2008-04-20 20:13:53 UTC (rev 1232)
+++ trunk/applications/jason-team/src/java/env/WorldModel.java 2008-04-20 20:16:53 UTC (rev 1233)
@@ -17,6 +17,7 @@
public static final int CORRAL = 32;
public static final int ENEMY = 64;
public static final int TARGET = 128; // one agent target location
+ public static final int FORPLACE = 256; // a place in a formation
public static final int nbActions = 8;
@@ -164,6 +165,14 @@
return maxSteps;
}
+ public void removeAll(int obj) {
+ for (int i = 0; i < width; i++) {
+ for (int j = 0; j < height; j++) {
+ if (hasObject(obj, i, j))
+ remove(obj, i, j);
+ }
+ }
+ }
/** Actions **/
Modified: trunk/applications/jason-team/src/java/env/WorldView.java
===================================================================
--- trunk/applications/jason-team/src/java/env/WorldView.java 2008-04-20 20:13:53 UTC (rev 1232)
+++ trunk/applications/jason-team/src/java/env/WorldView.java 2008-04-20 20:16:53 UTC (rev 1233)
@@ -202,6 +202,7 @@
case WorldModel.COW: drawCow(g, x, y); break;
case WorldModel.ENEMY: drawEnemy(g, x, y); break;
case WorldModel.TARGET: drawTarget(g, x, y); break;
+ case WorldModel.FORPLACE: drawFormPlace(g, x, y); break;
}
}
@@ -269,6 +270,15 @@
g.drawRect(x * cellSizeW + 4, y * cellSizeH + 4, cellSizeW - 8, cellSizeH - 8);
}
+ public void drawFormPlace(Graphics g, int x, int y) {
+ g.setColor(Color.green);
+ g.drawRect(x * cellSizeW + 2, y * cellSizeH + 2, cellSizeW - 4, cellSizeH - 4);
+ g.setColor(Color.lightGray);
+ g.drawRect(x * cellSizeW + 3, y * cellSizeH + 3, cellSizeW - 6, cellSizeH - 6);
+ g.setColor(Color.gray);
+ g.drawRect(x * cellSizeW + 4, y * cellSizeH + 4, cellSizeW - 8, cellSizeH - 8);
+ }
+
public void drawCow(Graphics g, int x, int y) {
g.setColor(Color.black);
g.drawRect(x * cellSizeW + 2, y * cellSizeH + 2, cellSizeW - 4, cellSizeH - 4);
Modified: trunk/applications/jason-team/src/java/jia/Search.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/Search.java 2008-04-20 20:13:53 UTC (rev 1232)
+++ trunk/applications/jason-team/src/java/jia/Search.java 2008-04-20 20:16:53 UTC (rev 1233)
@@ -211,36 +211,13 @@
int cost = 1;
if (ia.considerCowsAsObstacles) {
- cost += countCowsBeside(newl,1);
- cost += countCowsBeside(newl,2);
+ cost += ia.model.countObjInArea(WorldModel.CORRAL, newl,1);
+ cost += ia.model.countObjInArea(WorldModel.CORRAL, newl,2);
}
s.add(new GridState(newl,op,ia, cost));
}
-
- private int countCowsBeside(Location l, int d) {
- int c = 0;
- for (int x = l.x-d; x <= l.x+d; x++) {
- for (int y = l.y-d; y <= l.y+d; y++) {
- if (ia.model.hasObject(WorldModel.COW, x, y)) {
- c++;
- }
- }
- }
- return c;
- /*
- if (ia.model.hasObject(WorldModel.COW, l.x, l.y)) c++;
- if (ia.model.hasObject(WorldModel.COW, l.x+1, l.y)) c++;
- if (ia.model.hasObject(WorldModel.COW, l.x-1, l.y)) c++;
- if (ia.model.hasObject(WorldModel.COW, l.x, l.y+1)) c++;
- if (ia.model.hasObject(WorldModel.COW, l.x, l.y-1)) c++;
- if (ia.model.hasObject(WorldModel.COW, l.x+1, l.y+1)) c++;
- if (ia.model.hasObject(WorldModel.COW, l.x-1, l.y+1)) c++;
- if (ia.model.hasObject(WorldModel.COW, l.x+1, l.y-1)) c++;
- if (ia.model.hasObject(WorldModel.COW, l.x-1, l.y-1)) c++;
- */
- }
-
+
public boolean equals(Object o) {
if (o != null && o instanceof GridState) {
GridState m = (GridState)o;
Modified: trunk/applications/jason-team/src/java/jia/Vec.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/Vec.java 2008-04-20 20:13:53 UTC (rev 1232)
+++ trunk/applications/jason-team/src/java/jia/Vec.java 2008-04-20 20:16:53 UTC (rev 1233)
@@ -10,10 +10,12 @@
public class Vec implements Cloneable {
- public final int x,y;
+ public final double x,y;
public final double r,t;
- public Vec(int x, int y) {
+ public static final double PI2 = 2.0 * Math.PI;
+
+ public Vec(double x, double y) {
this.x = x;
this.y = y;
this.r = Math.sqrt(x*x + y*y);
@@ -28,13 +30,13 @@
this.t = Math.atan2(y,x);
}
- public int getX() { return x; }
- public int getY() { return y; }
+ public int getX() { return (int)Math.round(x); }
+ public int getY() { return (int)Math.round(y); }
public double magnitude() { return r; }
public double angle() { return t; }
- public Location getLocation(LocalWorldModel model) {
- return new Location(x, model.getHeight()-y-1);
+ public Location getLocation(LocalWorldModel model) {
+ return new Location(getX(), model.getHeight()-getY()-1);
}
public Vec add(Vec v) {
@@ -46,6 +48,11 @@
public Vec product(double e) {
return new Vec((int)(x * e), (int)(y *e));
}
+ public Vec newAngle(double t) {
+ while (t > PI2) t = t - PI2;
+ while (t < 0) t = t + PI2;
+ return new Vec(r*Math.cos(t), r*Math.sin(t));
+ }
@Override
public boolean equals(Object o) {
@@ -53,7 +60,7 @@
if (o == this) return true;
if (o instanceof Vec) {
Vec v = (Vec)o;
- return (x == v.x) && (y == v.y);
+ return (getX() == v.getX()) && (getY() == v.getY());
}
return false;
}
@@ -151,6 +158,6 @@
@Override
public String toString() {
- return x + "," + y;
+ return getX() + "," + getY();
}
}
Modified: trunk/applications/jason-team/src/java/jia/herd_position.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/herd_position.java 2008-04-20 20:13:53 UTC (rev 1232)
+++ trunk/applications/jason-team/src/java/jia/herd_position.java 2008-04-20 20:16:53 UTC (rev 1233)
@@ -14,6 +14,7 @@
import arch.CowboyArch;
import arch.LocalWorldModel;
import busca.Nodo;
+import env.WorldModel;
/**
* Gives a good location to herd cows
@@ -24,17 +25,31 @@
public static final double maxStdDev = 3;
+ public enum Formation {
+ one { int[] getAngles() { return new int[] { 0 }; } },
+ six { int[] getAngles() { return new int[] { 10, -10, 30, -30, 60, -60 }; } };
+ abstract int[] getAngles();
+ };
+
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] terms) throws Exception {
try {
+ CowboyArch arch = (CowboyArch)ts.getUserAgArch();
+ LocalWorldModel model = arch.getModel();
+ if (model == null)
+ return false;
- LocalWorldModel model = ((CowboyArch)ts.getUserAgArch()).getModel();
-
- Location agTarget = getAgTarget(model);
+ Location agLoc = model.getAgPos(arch.getMyId());
+
+ // update GUI
+ if (arch.hasGUI())
+ setFormationLoc(model, Formation.valueOf(terms[0].toString()));
+
+ Location agTarget = getAgTarget(model,Formation.valueOf(terms[0].toString()), agLoc);
if (agTarget != null) {
- agTarget = model.nearFree(agTarget);
- return un.unifies(terms[0], new NumberTermImpl(agTarget.x)) &&
- un.unifies(terms[1], new NumberTermImpl(agTarget.y));
+ agTarget = nearFreeForAg(model, agLoc, agTarget);
+ return un.unifies(terms[1], new NumberTermImpl(agTarget.x)) &&
+ un.unifies(terms[2], new NumberTermImpl(agTarget.y));
}
} catch (Throwable e) {
ts.getLogger().log(Level.SEVERE, "herd_position error: "+e, e);
@@ -42,7 +57,34 @@
return false;
}
- public Location getAgTarget(LocalWorldModel model) throws Exception {
+ public Location getAgTarget(LocalWorldModel model, Formation formation, Location ag) throws Exception {
+ Location r = null;
+ List<Location> locs = formationPlaces(model, formation);
+ if (locs != null) {
+ for (Location l : locs) {
+ r = l;
+ if (ag.equals(l) || // I am there
+ model.countObjInArea(WorldModel.AGENT, l, 1) == 0) { // someone else is there
+ break;
+ }
+ }
+ }
+ return r;
+ }
+
+ public void setFormationLoc(LocalWorldModel model, Formation formation) throws Exception {
+ model.removeAll(WorldModel.FORPLACE);
+ List<Location> locs = formationPlaces(model, formation);
+ if (locs != null) {
+ for (Location l : locs) {
+ if (model.inGrid(l)) {
+ model.add(WorldModel.FORPLACE, l);
+ }
+ }
+ }
+ }
+
+ private List<Location> formationPlaces(LocalWorldModel model, Formation formation) throws Exception {
List<Vec> cows = new ArrayList<Vec>();
for (Location c: model.getCows()) {
cows.add(new Vec(model, c));
@@ -61,34 +103,48 @@
int stepsFromCenter = (int)Vec.max(cows).sub(mean).magnitude()+1;
int n = Math.min(stepsFromCenter, np.size());
- Vec ctarget = new Vec(model, s.getNodeLocation(np.get(n)));
- Vec agTarget = mean.sub(ctarget).add(mean); // .product(1.5)
- return agTarget.getLocation(model);
+ Vec cowstarget = new Vec(model, s.getNodeLocation(np.get(n)));
+ Vec agsTarget = mean.sub(cowstarget);
+ Vec agTarget = agsTarget;
+ List<Location> r = new ArrayList<Location>();
+ for (int angle: formation.getAngles()) {
+ double nt = angle * (Math.PI / 180);
+ for (double varangle = nt; nt < 180; nt += 5) {
+ agTarget = agsTarget.newAngle(agsTarget.angle() + varangle);
+ Location l = agTarget.add(mean).getLocation(model);
- /*
- List<Vec> cowsTarget = new ArrayList<Vec>();
- for (Location c: model.getCows()) {
- Search s = new Search(model, c, model.getCorralCenter(), null, false, false, false, null);
- Location cowTarget = WorldModel.getNewLocationForAction(c, s.firstAction(s.search()));
- cowsTarget.add(new Vec(model, cowTarget));
+ // if l is in the path of cows, continue with next varangle
+ boolean inpath = false;
+ for (Nodo pn: np) {
+ if (l.equals(s.getNodeLocation(pn))) {
+ inpath = true;
+ break;
+ }
+ }
+ if (!inpath) {
+ r.add(l);
+ break;
+ }
+ }
}
-
- Vec stddev = Vec.stddev(cowsTarget);
-
- // remove max if stddev is too big
- while (stddev.magnitude() > maxStdDev) {
- cowsTarget.remove(Vec.max(cowsTarget));
- stddev = Vec.stddev(cowsTarget);
+ return r;
+ }
+
+ public Location nearFreeForAg(LocalWorldModel model, Location ag, Location t) throws Exception {
+ // run A* to get the path from ag to t
+ Search s = new Search(model, t, ag, null, false, false, true, null);
+ List<Nodo> np = s.normalPath(s.search());
+
+ int i = 0;
+ for (Nodo n: np) {
+ if (model.isFree(s.getNodeLocation(n))) {
+ return s.getNodeLocation(n);
+ }
+ i++;
+ if (i > 3) // do not go to far from target
+ break;
}
-
- Vec mean = Vec.mean(cowsTarget);
- if (mean.magnitude() > 0) {
- double incvalue = (Vec.max(cowsTarget).sub(mean).magnitude()+2) / mean.magnitude();
- return mean.product(incvalue+1).getLocation(model);
- } else {
- return null;
- }
- */
+ return model.nearFree(t);
}
}
Modified: trunk/applications/jason-team/src/java/test/TestBasicHerding.java
===================================================================
--- trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-04-20 20:13:53 UTC (rev 1232)
+++ trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-04-20 20:16:53 UTC (rev 1233)
@@ -7,15 +7,15 @@
import java.util.ArrayList;
import java.util.List;
-import jia.Search;
import jia.Vec;
import jia.herd_position;
+import jia.herd_position.Formation;
import org.junit.Before;
import org.junit.Test;
import arch.LocalWorldModel;
-import busca.Nodo;
+import env.WorldModel;
public class TestBasicHerding {
@@ -72,6 +72,8 @@
assertEquals(new Location(3,44), cowboy.getLocation(model));
assertEquals(new Location(1,49), model.getCorralCenter());
assertEquals(new Vec(3,2), new Vec(6,7).sub(cowboy)); //new Vec(model, cowboy.getLocation(model), cow.add(cowboy).getLocation(model)));
+ Vec v = new Vec(3,2);
+ assertEquals(v, v.newAngle(v.angle()));
}
/*
@@ -144,6 +146,7 @@
}
*/
+ /*
@Test
public void moveCows2() throws Exception {
scenario1();
@@ -179,40 +182,56 @@
Location byIA = new herd_position().getAgTarget(model);
assertEquals(byIA, agTarget.getLocation(model));
}
-
+ */
+
@Test
- public void moveCows3() throws Exception {
- scenario2();
- List<Vec> cowsTarget = new ArrayList<Vec>();
+ public void moveCows2() throws Exception {
+ scenario1();
+
+ List<Vec> cowsl = new ArrayList<Vec>();
for (int i=0; i<cows.length; i++) {
- cowsTarget.add(cows[i]);
+ cowsl.add(cows[i]);
}
// find center/clusterise
- cowsTarget = Vec.cluster(cowsTarget, 2);
+ cowsl = Vec.cluster(cowsl, 2);
+ Vec stddev = Vec.stddev(cowsl);
+ assertTrue(stddev.magnitude() < 3);
- Vec mean = Vec.mean(cowsTarget);
- assertEquals(new Vec(9,1), mean);
+ Vec mean = Vec.mean(cowsl);
+ assertEquals(new Vec(5,8), mean);
- // run A* to see the cluster target in n steps
- Search s = new Search(model, mean.getLocation(model), model.getCorralCenter(), null, false, false, false, null);
- List<Nodo> np = s.normalPath(s.search());
- //System.out.println(np);
+ int stepsFromCenter = (int)Vec.max(cowsl).sub(mean).magnitude()+1;
+ assertEquals(3, stepsFromCenter);
+
+ Location byIA = new herd_position().getAgTarget(model, Formation.one, c...
[truncated message content] |