Exemple #1
0
 def tick_operation(self, op):
     """periodically reassess situation
     
     This method is automatically invoked by the C++ BaseMind code, due to its *_operation name.
     """
     args = op.get_args()
     if len(args) != 0:
         if args[0].name == "think":
             # It's a "thinking" op, which is the base of the AI behaviour.
             # At regular intervals the AI needs to assess its goals; this is done through "thinking" ops.
             op_tick = Operation("tick")
             # just copy the args from the previous tick
             op_tick.set_args(args)
             op_tick.set_future_seconds(const.basic_tick + self.jitter)
             op_tick.set_to(self.id)
             for t in self.pending_things:
                 thing = self.map.get(t)
                 if thing and thing.type[0]:
                     self.add_thing(thing)
             self.pending_things = []
             result = self.think()
             if self.message_queue:
                 result = self.message_queue + result
                 self.message_queue = None
             return op_tick + result
Exemple #2
0
 def tick_operation(self, op):
     """periodically reassess situation
     
     This method is automatically invoked by the C++ BaseMind code, due to its *_operation name.
     """
     args = op.get_args()
     if len(args) != 0:
         if args[0].name == "think":
             # It's a "thinking" op, which is the base of the AI behaviour.
             # At regular intervals the AI needs to assess its goals; this is done through "thinking" ops.
             op_tick = Operation("tick")
             # just copy the args from the previous tick
             op_tick.set_args(args)
             op_tick.set_future_seconds(const.basic_tick + self.jitter)
             op_tick.set_to(self.id)
             for t in self.pending_things:
                 thing = self.map.get(t)
                 if thing and thing.type[0]:
                     self.add_thing(thing)
             self.pending_things = []
             result = self.think()
             if self.message_queue:
                 result = self.message_queue + result
                 self.message_queue = None
             return op_tick + result
Exemple #3
0
    def setup_operation(self, op):
        """called once by world after object has been made
           send first tick operation to object
           
        This method is automatically invoked by the C++ BaseMind code, due to its *_operation name."""

        # Setup a tick operation for thinking
        think_tick_op = Operation("tick")
        think_tick_op.set_to(self.id)
        think_tick_op.set_args([Entity(name="think")])

        # Setup a tick operation for moving
        move_tick_op = Operation("tick")
        move_tick_op.set_to(self.id)
        move_tick_op.set_args([Entity(name="move")])
        move_tick_op.set_future_seconds(0.2)

        return Operation("look") + think_tick_op + move_tick_op
Exemple #4
0
    def setup_operation(self, op):
        """called once by world after object has been made
           send first tick operation to object
           
        This method is automatically invoked by the C++ BaseMind code, due to its *_operation name."""
        # CHEAT!: add memory, etc... initialization (or some of it to __init__)

        # Setup a tick operation for thinking
        think_tick_op = Operation("tick")
        think_tick_op.set_to(self.id)
        think_tick_op.set_args([Entity(name="think")])

        # Setup a tick operation for moving
        move_tick_op = Operation("tick")
        think_tick_op.set_to(self.id)
        move_tick_op.set_args([Entity(name="move")])
        move_tick_op.set_future_seconds(0.2)

        return Operation("look") + think_tick_op + move_tick_op