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:
parent
f4446ef177
commit
7f5e30ac82
@ -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",
|
||||
|
@ -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.",
|
||||
|
@ -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'))
|
||||
|
0
skills/games/rochambeau/README.md
Normal file
0
skills/games/rochambeau/README.md
Normal file
0
skills/games/rochambeau/memory/.gitkeep
Normal file
0
skills/games/rochambeau/memory/.gitkeep
Normal file
76
skills/games/rochambeau/nlu/en.json
Normal file
76
skills/games/rochambeau/nlu/en.json
Normal 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?"
|
||||
]
|
||||
}
|
||||
}
|
11
skills/games/rochambeau/skill.json
Normal file
11
skills/games/rochambeau/skill.json
Normal 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"
|
||||
}
|
||||
}
|
52
skills/games/rochambeau/src/actions/play.py
Normal file
52
skills/games/rochambeau/src/actions/play.py
Normal 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()
|
||||
}))
|
24
skills/games/rochambeau/src/actions/rematch.py
Normal file
24
skills/games/rochambeau/src/actions/rematch.py
Normal 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 })
|
13
skills/games/rochambeau/src/actions/setup.py
Normal file
13
skills/games/rochambeau/src/actions/setup.py
Normal 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'))
|
6
skills/games/rochambeau/src/config.sample.json
Normal file
6
skills/games/rochambeau/src/config.sample.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"configurations": {
|
||||
"options": {},
|
||||
"credentials": {}
|
||||
}
|
||||
}
|
0
skills/games/rochambeau/src/lib/.gitkeep
Normal file
0
skills/games/rochambeau/src/lib/.gitkeep
Normal file
0
skills/games/rochambeau/test/.gitkeep
Normal file
0
skills/games/rochambeau/test/.gitkeep
Normal file
Loading…
Reference in New Issue
Block a user