Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Feb 27 2018 15:51
    flashpixx closed #7
  • Feb 27 2018 15:47
    michalsustr opened #7
  • Nov 15 2017 07:19
    Ehsanta83 removed as member
  • Oct 05 2017 13:02
    sdennisen removed as member
  • Jul 05 2017 11:00
    Ehsanta83 added as member
  • Jun 13 2017 11:28
    flashpixx closed #36
  • Jun 13 2017 10:18
    Fatema080136 opened #36
  • May 30 2017 06:17
    flashpixx closed #35
  • May 29 2017 14:35
    Fatema080136 opened #35
  • May 29 2017 13:44
    flashpixx closed #34
  • May 29 2017 12:55
    Fatema080136 opened #34
  • May 24 2017 17:37
    flashpixx closed #33
  • May 24 2017 17:30
    flashpixx closed #32
  • May 23 2017 20:26
    Fatema080136 opened #33
  • May 23 2017 19:18
    Fatema080136 opened #32
  • May 23 2017 08:30
    flashpixx closed #24
  • May 23 2017 08:05
    flashpixx closed #20
  • May 22 2017 22:14
    flashpixx closed #27
  • May 22 2017 16:02
    flashpixx closed #30
  • May 22 2017 15:57
    flashpixx closed #31
michalsustr
@michalsustr
  private static InputStream getAgentAslFile(Class<?> p_agentclass) {
    log.info("Loading agent definition from /" + p_agentclass.getSimpleName() + ".asl");
    InputStream stream = p_agentclass.getResourceAsStream("/" + p_agentclass.getSimpleName() + ".asl");

    // fail early!
    try {
      if (stream.available() > 0) {
        return stream;
      }
    } catch (IOException e) { e.printStackTrace(); }

    throw new RuntimeException("Cannot read agent ASL resource files!");
  }
michalsustr
@michalsustr
I can read from the stream, and I do not close it anywhere. Hmm.
michalsustr
@michalsustr
Ok, it seems like it was some weird bug with resource loading, but not sure why. Loading from files works fine.
Philipp Kraus
@flashpixx
You can use a stream object once
it is like an iterator
if you do it like:
final Stream<Number> l_data = Stream.of(1,2,3,4);
l_data.foreach( i ->  System.out.println(i)  );
l_data.foreach( i ->  System.out.println(i)  );
This will break at the second call
but the stream object is closed on the second line
change it like:
michalsustr
@michalsustr
Uhm what are you referring to?
Philipp Kraus
@flashpixx
final List<Number> l_data = Stream.of(1,2,3,4,5).collect(Collectors.toList());
l_data.stream()..foreach( i ->  System.out.println(i)  );
l_data.stream().foreach( i ->  System.out.println(i)  );
With the stream()call a new stream object is created, the second foreachcall uses a new stream object, but this is not a problem on LightJason, it is the general definition of the stream structure in Java|
michalsustr
@michalsustr

Uhm what are you referring to?

That is InputStream I had problem with

Philipp Kraus
@flashpixx
it is equal to the InputStream it is the AutoCloseable interface that defines this behaviour
michalsustr
@michalsustr
ok, makes sense, thanks.
What about those ^ 3 points please?
Philipp Kraus
@flashpixx
Stream inherits from ÀutoCloseable`
  1. Yes
  2. You cannot clear current plans, the method runningplans() returns only information which plans will be executed / are running, but you cannt clear it
  3. interaction with any other inside the software is a little bit difficult to answer, on my scenarios I use a on-demand beliefbase to get all information without caring of updating the data, and pass data immediatly with actions to the outside code
but you need to think in this case about parallel execution and some caches
my software developing just work in "realtime", if there is data, the agent can use it, so I dealing with lagging, because in real world we have got delay too
michalsustr
@michalsustr

If I have:

+!go(Position) <-
    generic/print(AgentID, " - go ", Position);
    unit/this_action_fails(Position).
-!go(Position) <-
    !go(Position).

then go is printed only once

+!go(Position) <-
    generic/print(AgentID, " - go ", Position);
    unit/this_action_fails(Position).
-!go(Position) <-
    generic/print("Failed");
    !go(Position).
With this case it properly loops around ( go - failed - go - failed - ... )
Philipp Kraus
@flashpixx
That's correct, because the +!go executes in circle 0 and it fails, so in cycle 1 it will execute -!go with equal data for Position, but on the -!go you pass the data back to +!go so it fails again, so the loop is correct
e.g. +!go(3) fails, it calls -!go(3) after that +!go(3)....
michalsustr
@michalsustr
What I'm saying is the first case does not have expected output: go - go - go - ...
I'm expecting the sequence of calls: +go -go +go -go +go -go +go -go ... in both cases
in the consecutive timesteps
(1) +go (2) -go (3) +go (4) -go ...
Philipp Kraus
@flashpixx
but the print returns "go", "failed", "go", "failed"...
this is correct
michalsustr
@michalsustr
Case 1) behaves incorrectly:
+!go(Position) <-
    generic/print("go");
    unit/this_action_fails(Position).
-!go(Position) <-
    !go(Position).

prints go
instead of go - go - go ...

Case 2) behaves correctly:
 +!go(Position) <-
    generic/print("go");
    unit/this_action_fails(Position).
-!go(Position) <-
    generic/print("fail");
    !go(Position).

prints go - fail - go -fail ...
Philipp Kraus
@flashpixx
I have build this script myself:
!main.

+!main <-
    !go(3).

+!go(Position) <-
    generic/print("go", Position);
    fail
.

-!go(Position) <-
    //generic/print("fail");
    !go(Position)
.
with uncomment line:
go   3.0
fail
go   3.0
fail
go   3.0
fail
go   3.0
fail
go   3.0
with comment line:
go   3.0
go   3.0
go   3.0
go   3.0
go   3.0
with 5 iterations
fail is equal to failing action
it is a good strategy if you can not ensure, that Position is a strict numerical type e.g. like int or double to use the genric type Number, so your action should use Numberas parameter type
michalsustr
@michalsustr
hmm strange, maybe it was some silent failure... it's part of larger code
thanks for trying it out!
michalsustr
@michalsustr
Is there some way to get rid of serialVersionUID?
or at least have an automatic check that it was not set?
Philipp Kraus
@flashpixx
i'm using Checkstyle for automatic code style checking
and for IntelliJ there is a plugin, I think Eclipse can do it similar, but you can also suppress the warning
ahmedsyed1
@ahmedsyed1
Hello
I am actually new and i dont know how to use the lightjson
so can anyne help me in this ?
Thanks in advance
Philipp Kraus
@flashpixx
Within the tutorial and knowledge base you can find a lot of information about LightJason