1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-11-23 20:12:08 +03:00

feat(skill/rochambeau): init

This commit is contained in:
louistiti 2022-05-09 21:47:35 +08:00
parent f4446ef177
commit 7f5e30ac82
No known key found for this signature in database
GPG Key ID: 0A1C3B043E70C77D
13 changed files with 206 additions and 39 deletions

View File

@ -1,10 +1,5 @@
{
"endpoints": [
{
"method": "GET",
"route": "/api/action/games/guess_the_number/start",
"params": []
},
{
"method": "GET",
"route": "/api/action/games/guess_the_number/setup",
@ -20,6 +15,26 @@
"route": "/api/action/games/guess_the_number/replay",
"params": []
},
{
"method": "GET",
"route": "/api/action/games/rochambeau/start",
"params": []
},
{
"method": "GET",
"route": "/api/action/games/rochambeau/setup",
"params": []
},
{
"method": "GET",
"route": "/api/action/games/rochambeau/play",
"params": []
},
{
"method": "GET",
"route": "/api/action/games/rochambeau/rematch",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/birthday/leon_birthday",

View File

@ -1,40 +1,13 @@
{
"actions": {
"start": {
"type": "dialog",
"setup": {
"type": "logic",
"utterance_samples": [
"Let's play guess the number",
"I wanna play guess the number",
"Can we play guess the number?",
"I want to play a game like guess the number"
],
"slots": [
{
"name": "players_nb",
"item": {
"type": "entity",
"name": "number"
},
"questions": [
"How many players should I set?",
"Sure, how many players should I prepare?"
]
},
{
"name": "email_test",
"item": {
"type": "entity",
"name": "email"
},
"questions": [
"How about the email?"
]
}
],
"next_action": "setup"
},
"setup": {
"type": "logic",
"next_action": "guess"
},
"guess": {
@ -63,7 +36,7 @@
},
"answers": {
"ready": [
"Alright, I have set %players_nb% players with the %email_test% email. Go ahead and guess the number between 0 and 100!"
"Alright, I'm ready! Go ahead and guess the number between 0 and 100!"
],
"bigger": [
"The number is bigger.",

View File

@ -14,7 +14,4 @@ def setup(params):
# TODO: save these values in DB
# TODO: add output_context
return utils.output('end', 'ready', utils.translate('ready', {
'players_nb': slots['players_nb']['value']['sourceText'],
'email_test': slots['email_test']['value']['sourceText']
}))
return utils.output('end', 'ready', utils.translate('ready'))

View File

View File

View File

@ -0,0 +1,76 @@
{
"actions": {
"start": {
"type": "dialog",
"utterance_samples": [
"Let's play rochambeau",
"I wanna play rock paper scissors",
"Can we play paper rock scissors?",
"I want to play rochambeau"
],
"slots": [
{
"name": "rounds_nb",
"item": {
"type": "entity",
"name": "number"
},
"questions": [
"How many rounds would you like to play?",
"How many rounds should I set?",
"Sure, how many rounds should I prepare?"
]
}
],
"next_action": "setup"
},
"setup": {
"type": "logic",
"next_action": "play"
},
"play": {
"type": "logic",
"loop": {
"expected_items": [
{
"type": "entity",
"name": "handsign"
}
]
},
"next_action": "rematch"
},
"rematch": {
"type": "logic",
"loop": {
"expected_items": [
{
"type": "resolver",
"name": "number"
}
]
}
}
},
"entities": {
"handsign": "entities/handsigns.json"
},
"answers": {
"ready": [
"Alright, let's get started!"
],
"equal": [
"No point."
],
"point": [
"The %handsign_1% beats the %handsign_2%."
],
"win": [
"I won! Would you like a rematch?"
],
"lose": [
"You're good at it! Can I get a rematch?",
"Congrats! Should we go for a rematch?"
]
}
}

View File

@ -0,0 +1,11 @@
{
"name": "Rochambeau",
"bridge": "python",
"version": "1.0.0",
"description": "Rock paper scissors game.",
"author": {
"name": "Louis Grenard",
"email": "louis.grenard@gmail.com",
"url": "https://github.com/louistiti"
}
}

View File

@ -0,0 +1,52 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import random
import utils
def play(params):
"""This is a test"""
handsigns = {
'ROCK': {
'superior_to': 'scissors',
'inferior_to': 'paper'
},
'PAPER': {
'superior_to': 'rock',
'inferior_to': 'scissors'
},
'SCISSORS': {
'superior_to': 'paper',
'inferior_to': 'rock'
}
}
entities = params['entities']
rounds_nb = 3 # TODO: pickup from memory
player_handsign = None
leon_handsign = random.choice(list(handsigns))
# Find entities
for item in params['entities']:
if item['entity'] == 'handsign':
player_handsign = item['resolution']['value']
# Return no speech if no number has been found
if player_handsign == None:
return utils.output('end', None, None, { 'isInActionLoop': False })
if leon_handsign == player_handsign:
return utils.output('end', 'equal', utils.translate('equal'))
# Point for Leon
if handsigns[leon_handsign]['superior_to'] == player_handsign:
# TODO: increment +1 for Leon
# TODO: remove print
print('...')
# TODO: increment +1 for player
return utils.output('end', 'equal', utils.translate('point', {
'handsign_1': leon_handsign.lower(),
'handsign_2': player_handsign.lower()
}))

View File

@ -0,0 +1,24 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import utils
def rematch(params):
"""This is a test"""
entities, slots = params['entities'], params['slots']
decision = 0
# Find entities
# TODO: replace with confirmation resolver
for item in params['entities']:
if item['entity'] == 'number':
decision = item['resolution']['value']
if decision == 1:
return utils.output('end', 'replay', 'Let\'s goooo', {
'isInActionLoop': False,
'restart': True
})
return utils.output('end', 'quit', 'As you wish', { 'isInActionLoop': False })

View File

@ -0,0 +1,13 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import utils
def setup(params):
"""This is a test"""
entities, slots = params['entities'], params['slots']
# TODO: use rounds_nb slot and save it in DB
return utils.output('end', 'ready', utils.translate('ready'))

View File

@ -0,0 +1,6 @@
{
"configurations": {
"options": {},
"credentials": {}
}
}

View File

View File