Exemplo n.º 1
0
 def __init__(self, *, sloth_bits, sloth_iterations, **kwargs):
     super().__init__(**kwargs)
     self._sloth_bits = sloth_bits
     self._sloth_iterations = sloth_iterations
     self.sloth = Sloth(data=None,
                        bits=sloth_bits,
                        iterations=sloth_iterations)
Exemplo n.º 2
0
def run_game():
    pygame.init()
    ai_settings = Settings()
    screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height))
    pygame.display.set_caption("Invasion")

    sloth = Sloth(screen)

    while True:
        gf.check_events()
        
        gf.update_screen(ai_settings, screen, sloth)
Exemplo n.º 3
0
 def bot_paste(self, update, context):
     regex = r"/paste\s+((.|\n)+)"
     try:
         matcher = re.match(regex, update.message.text, re.MULTILINE)
         if matcher:
             paste_content = matcher.group(1)
             last_message: Message = self.BOT.send_message(
                 text="paste.ubuntu.com 'a bağlanıyorum...",
                 chat_id=update.message.chat_id
             )
             sloth = Sloth()
             paste_link = sloth.run(
                 paste_content,
                 poster=update.message.from_user.username
             )
             self.BOT.edit_message_text(
                 f"Gönderen: @{update.message.from_user.username}\nLink: {paste_link}",
                 chat_id=update.message.chat_id,
                 message_id=last_message.message_id,
                 parse_mode=telegram.ParseMode.MARKDOWN
             )
             self.BOT.delete_message(
                 chat_id=update.message.chat_id,
                 message_id=update.message.message_id
             )
         else:
             update.message.reply_text("Hani kod?")
     except PasteException:
         response_text = f"paste.ubuntu.com aşağıdaki hataları listeledi:\n```"
         for error in sloth.errors:
             response_text += f"- {error}\n"
         response_text += "```\n"
         response_text += f"Ilgili kişi: @{update.message.from_user.username}\n"
         self.BOT.send_message(
             text=response_text,
             chat_id=update.message.chat_id,
             message_id=last_message.message_id,
             parse_mode=telegram.ParseMode.MARKDOWN
         )
Exemplo n.º 4
0
class SlothComputation(BaseComputation):
    def __init__(self, *, sloth_bits, sloth_iterations, **kwargs):
        super().__init__(**kwargs)
        self._sloth_bits = sloth_bits
        self._sloth_iterations = sloth_iterations
        self.sloth = Sloth(data=None,
                           bits=sloth_bits,
                           iterations=sloth_iterations)

    def start_computation(self, inp_data):
        self.sloth.final_hash = None
        self.sloth.witness = None
        self.sloth.data = inp_data
        log.info(
            "Starting Sloth computation - bits: {}, iterations: {}",
            self.sloth.bits,
            self.sloth.iterations,
        )
        self.sloth.compute()

    def finish_computation(self):
        self.sloth.wait()
        self.output = self.sloth.final_hash
        log.info(" === OUTPUT --v\n{}\n === ", self.sloth.final_hash)
        log.info(" === WITNESS --v\n{}\n === ", self.sloth.witness)

    @property
    def proof(self):
        return msgpack.packb({
            "witness": self.sloth.witness,
            "bits": self.sloth.bits,
            "iterations": self.sloth.iterations,
        })

    @proof.setter
    def proof(self, value):
        return None
Exemplo n.º 5
0
#!/usr/bin/python3
from sloth import Sloth
sloth = Sloth([1, 2, 3, 4])

sloth.set_offset([0, 0, 0, 0])


def forever():
    sloth.do_action('moon walk left', 2, 100)
    sloth.do_action('moon walk right', 2, 100)
    sloth.do_action('turn right', 1, 100)
    sloth.do_action('shake left', 1, 100)
    sloth.do_action('turn left', 1, 100)
    sloth.do_action('shake right', 1, 100)
    sloth.do_action('go up and down', 1, 100)
    sloth.do_action('swing', 1, 100)
    sloth.do_action('big swing', 1, 100)
    sloth.do_action('stop', 1, 50)


if __name__ == "__main__":
    while True:
        forever()
Exemplo n.º 6
0
#!/usr/bin/python3
import sys
sys.path.append(r'/opt/ezblock')
from sloth import Sloth
__SLOTH__ = Sloth([1, 2, 3, 4])

servoAngle = None
"""Describe this function...

"""


def forever():
    global servoAngle
    servoAngle = [
        0, 0, 0, 0
    ]  #You can change the STEP of PiSloth by modifying the value of this list.
    __SLOTH__.servo_write_all([(servoAngle[0]), (servoAngle[1]),
                               (servoAngle[2]), (servoAngle[3])])


if __name__ == "__main__":
    while True:
        forever()
Exemplo n.º 7
0
 def test_for_sloth_class(self):
     self.assertTrue(Sloth())
Exemplo n.º 8
0
#!/usr/bin/python3
from sloth import Sloth
sloth = Sloth([1, 2, 3, 4])
from ezblock import delay

AtEase = None
Attention = None

sloth.set_offset([0, 0, 0, 0])
sloth.add_action("AtEase", [[(-45), 0, (-20), 0]])
AtEase = "AtEase"
sloth.add_action("Attention", [[(-10), 0, 10, 0]])
Attention = "Attention"


def forever():
    global AtEase, Attention
    sloth.do_action(Attention, 1, 100)
    delay(5000)
    sloth.do_action(AtEase, 1, 100)
    delay(3000)


if __name__ == "__main__":
    while True:
        forever()
Exemplo n.º 9
0
#!/usr/bin/python3
import sys
sys.path.append(r'/opt/ezblock')
from sloth import Sloth
__SLOTH__ = Sloth([1, 2, 3, 4])
from ezblock import delay

diyAction = None

__SLOTH__.add_action("diyAction",
                     [[0, (-50), 0, 50], [0, 0, 0, 0], [0, 50, 0,
                                                        (-50)], [0, 0, 0, 0]])
diyAction = "diyAction"


def forever():
    global diyAction
    __SLOTH__.do_action(diyAction, 1, 80)
    delay(1000)


if __name__ == "__main__":
    while True:
        forever()
Exemplo n.º 10
0
#!/usr/bin/python3
import sys

sys.path.append(r'/opt/ezblock')
from sloth import Sloth

__SLOTH__ = Sloth([1, 2, 3, 4])

__SLOTH__.set_offset([0, 0, 0, 0])


def forever():
    __SLOTH__.do_action('turn left', 7, 100)
    __SLOTH__.do_action('forward', 5, 100)
    __SLOTH__.do_action('turn right', 7, 100)
    __SLOTH__.do_action('forward', 5, 100)


if __name__ == "__main__":
    while True:
        forever()