Skip to content

Instantly share code, notes, and snippets.

@ferreiro
Created February 7, 2016 23:22
Show Gist options
  • Save ferreiro/4eb89676e464650a1bb9 to your computer and use it in GitHub Desktop.
Save ferreiro/4eb89676e464650a1bb9 to your computer and use it in GitHub Desktop.
Generate a list of games as prolog deffacts using a simple python program.
from random import randint
games = [] # It's a list og games where each element is a dictionary {'name': '', 'type':'', 'used': False|True}
cons_type = ['inteligencia','deporte','aventura','familiar']
cons_numPlayers = ['uno', 'dos', 'MasDeDos']
cons_difficulty = ['facil', 'media', 'dificil']
cons_time = ['poco', 'medio', 'mucho']
cons_age = ['TP', 'Mas13', 'Mas18']
names = {
'inteligencia' : ['Trivial', 'Damas', 'Apalabrados', 'Pasapalabra', 'Memory', 'Sopa de letras', 'Cut and slice', 'Logo Quiz', 'Logic Master', 'Carrera de mente', 'Mastermind', 'Tingly Brain trainer', 'La forma', 'Liquid Measure', '2048', 'Sliding Cubes 2', 'Linx', 'Romper Codigos'],
'deporte' : ['TrivialSport', 'Tennis', 'Basket', 'Volleyball', 'Formula1', 'MotoGP', 'Nautica', 'Paddel', 'Bandminton', 'Boxeo', 'Beisbol', 'Wrestling', 'Bodyboard', 'Golf', 'Karate', 'Lacrosse', 'Karting'],
'aventura' : ['Serpientes en el desierto', 'Planeta calleja', 'Desafio extremo', 'Himalaya', 'Spain', 'Madrid', 'Londres', 'Hamburgo', 'Dunas', 'Desierto Sahara', 'Lagos del mundo', 'World mountains', 'Geografiame', 'Machupichu', 'Amazonas', 'Egipto'],
'familiar' : ['Monopoly', 'Mario Kart', 'Solitario familiar', 'Libro de la jungla', 'El crucero', 'Lobos', 'Panteras', 'El consejo de brujas', 'Mario bros', 'Mario kart', 'Domino', 'Bubble Chamrs', 'Zol the scape','Cake topping', 'Sushi Slider', 'Candy Crash', 'Playmovil']
}
#Recibe una lista con juegos que quieres guardar y el nombre del grupo
def composeGames(gameList, groupName):
i = 0
for name in gameList:
games.append({
'name' : name,
'type' : groupName,
'used' : False
})
i += 1
for _typeName in cons_type:
print _typeName
composeGames(names[_typeName], str(_typeName));
class game:
def __init__(self, name, type, numPlayers=None, difficulty=None, time=None, price=0, age=None):
self.name = name
self.type = type
self.numPlayers = cons_numPlayers[randint(0, len(cons_numPlayers)-1)]
self.difficulty = cons_difficulty[randint(0, len(cons_difficulty)-1)]
self.time = cons_time[randint(0, len(cons_time)-1)]
self.price = randint(5, 35) # Random number greater than 3 to 50
self.age = cons_age[randint(0, len(cons_age)-1)]
def convertToProlog(self):
conversion = ''
conversion += '(juego'
conversion += '(nombre "%s")' % self.name
conversion += '(tipoJuego %s)' % self.type
conversion += '(numeroJugadores %s)' % self.numPlayers
conversion += '(dificultad %s)' % self.difficulty
conversion += '(tiempoJuego %s)' % self.time
conversion += '(precio %d)' % self.price
conversion += '(edadRecomendada %s))' % self.age
return conversion
def genereateGames(games):
for g in games:
g = game(g['name'], g['type'])
print g.convertToProlog()
print len(games)
genereateGames(games)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment