def main(): print("\n_________________________________________________") print('\nBienvenu sur le jeu VIDEO POKER') print("\n_________________________________________________") name = input("\nQuel est votre nom ? ") print("\n_________________________________________________") money = int( input("\nBonjour " + name + ". Combien de crédit voulez-vous acheter ? ")) print("\n_________________________________________________") print("\nTrès bien, commençons la partie. Bonne Chance " + name + "!!") print("\n_________________________________________________") player = Player(name, money, []) while player.get_money() > 0: bet_value = int(input("\nCombien Voulez-vous miser ? ")) print("\n_________________________________________________") if bet_value <= player.get_money(): game(bet_value, player) else: print("\nJe suis désolé mais vous n'avez pas assez de crédit ") print("\n_________________________________________________") if player.get_money() < 1: print( "\nJe suis désolé mais vous avez perdu tout vos crédits.\nVous aurez plus de chance la prochaine fois." ) print("\n_________________________________________________") still_playing = input("\nVoulez-vous recommencer la partie ? oui/non ") if still_playing == "oui": main() else: print("\n_________________________________________________") print("Au revoir " + player.get_name())
from functions import game game()
import random from functions import game, read_input_continue_game hidden_number = random.randrange( 0, 100) # имена переменных должны нести логический смысл continue_flag = True # флаги тоже выносим в начало while continue_flag: # несколько вариантов построения игры. Можно закоментить/раскоментить и пробовать разные варианты # game() # это будет просто игрой по-умолчанию # game(counter=5) # это будет игрой с 5-ью попытками вместо трех game(counter=10, hidden_number=hidden_number ) # а это будет игра с числом от 0 до 99 с 10 попытками response = read_input_continue_game() if response == 'n': continue_flag = False print('Спасибо за игру')
# TicTacToe/main.py from functions import printIntro, printMenu, game, resetVariables printIntro(); # prints introduction print "Would You Like To Play The Game?" menu = printMenu(); while (menu == 1): game(); menu = printMenu(); resetVariables();
from functions import play, game, Strategy1, mean def test_strategy(strategy): test_strategy = strategy test_num_games = 10000 results = [] for _ in range(test_num_games): result_score, _ = play(strategy=test_strategy, output=False) results.append(result_score) print("Statistics over %d games" % test_num_games) print("------------------------") print("Mean score : %d" % mean(results)) print("Farkel %% : %d%%" % (sum([x == 0 for x in results]) / test_num_games * 100)) print("Hi-score : %d" % max(results)) players = [Strategy1() for _ in range(4)] result_rounds, results = game(players, output=True) print("\nFinal scores") print("------------") print("In %d rounds" % result_rounds) print("------------") for player, score in results: print("P%d %d" % (player + 1, score))
def main(self): self.convergence_count = 0 #start the evolition for i in range(self.nGenerations): if self.convergence_count<5: if i%10 == 0: print("Generation={}".format(i)) #play the game if self.train == True: print("train") self.Balls,self.xArray,self.yArray = functions.game(self.Balls,self.train,None,self.xArray,self.yArray) elif self.dec_input == True: print("dec_input") self.Balls = functions.game(self.Balls,self.train,self.vae) else: print("normal_Input") self.Balls = functions.game(self.Balls,self.train) #get the scores of the balls scores = np.zeros(self.nPopulation) for i in range(self.nPopulation): scores[i] = self.Balls[i].s #sort the Balls by their score ind = [x for _,x in sorted(zip(scores,np.arange(self.nPopulation)))] newBalls = [] for i in ind: newBalls.append(self.Balls[i]) self.Balls = newBalls #save the essential results of this run self.best_scores_generations.append(max(scores)) self.number_of_best_individuals_generation.append(scores) self.best_individual_generation.append(self.Balls[-1]) #create new poputlation #copy N_best Balls and evolve the copies. Keep the previous best balls. for i in range(self.N_best): self.Balls[-(self.N_best+i)].net = copy.deepcopy(self.Balls[-i]).net self.Balls[-(self.N_best+i)].net.evolve(self.Sigma_mut, self.binomial) #Generate completely new Balls for i in range(self.nPopulation-2*self.N_best): self.Balls[i].net = self.Net_type(self.max_net_depth,self.max_net_width, self.N_input) #reset the parameters to the init variables for i in self.Balls: i.reset() #print some numbers print("Score of best Individual={}".format(self.best_scores_generations[-1])) print("standard-deviation={}".format(self.evolution_statistics()[1][-1])) if max(scores)>=7000: self.convergence_count+=1 else: self.convergence_count=0 #Save the last generation self.last_generation = self.Balls
def hangman(): print("Le jeu du pendu.") functions.game()
def dialog(message): # проверки сообщения data.new(message.from_user.id) check.new(message.from_user.id) us = message.from_user.id m = str(message.text).lower() if ("шутк" in m) or ("шуте" in m) or ("прикол" in m) and ("прикольно" not in m): joke = f.jokes() bot.send_message(us, joke, reply_markup=keyboard) elif 'мем' in m or '2014' in m or 'смеш' in m: mem = f.send_mem() bot.send_photo(us, mem, reply_markup=keyboard) elif 'камень-ножницы-бумаг' in m or 'играть' in m: data.game(us, 1) bot.send_message( us, 'Выбирай! Если больше не хочешь играть, скажи "хватит" ' + e.smile, reply_markup=game_keyboard) elif data.get_game(us) and f.from_e_to_game(m): res = f.game(f.from_e_to_game(m)) bot.send_message(us, res + '\n' + "Сыграем еще?)", reply_markup=game_keyboard) elif data.get_game(us) and m == "да": data.game(us, 1) elif data.get_game(us) and m == "хватит": bot.send_message(us, 'Хорошо, больше не будем играть', reply_markup=keyboard) data.game(us, 0) elif data.get_game(us): bot.send_message( us, "Ты ввел что-то неправильно, повтори пожалуйста. Если надоело, просто напиши 'хватит'", reply_markup=game_keyboard) elif data.get_situation(us): diary.situation(us, m) bot.send_message( us, 'Отлично, ты сделал запись в нашем дневнике! Ты можешь сделать еще одну, написав "/note"', reply_markup=keyboard) elif f.place(m): bot.send_message(us, f.place(m), reply_markup=keyboard) elif not ans.analysis_sentiment(ans.analysis_data([m])): bot.send_message( us, 'Поменьше негатива, пожалуйста. Можешь записать это в дневник, кстати!', reply_markup=keyboard) elif ans.analysis_sentiment(m): callback = f.normal() bot.send_message(us, callback, reply_markup=keyboard) else: bot.send_message(us, "хммммм", reply_markup=keyboard)
users_file = open(os.path.join( cwd, '..', 'users', 'users.txt'), 'r') timing = open(os.path.join( cwd, '..', 'users', user, 'timing.txt'), 'a') # Setup word lists based on user info word_list = open(os.path.join( cwd, '..', 'resources', 'word_list.txt'), 'r') word_list_specific = open(os.path.join( cwd, '..', 'resources', 'word_list_specific.txt'), 'w') # Find user in file and user letters user_info = users_file.readline().split('\t') user_info[1] = user_info[1].rstrip() while user_info[0] != user: user_info = users_file.readline().split('\t') user_info[1] = user_info[1].rstrip() # Search word list file for appropriate words and store in other file fn.letter_check(user_info[1], word_list, word_list_specific) # Write appropriate words to word list words = fn.word_write(user_info[1], cwd, word_list_specific) # Startup stuff fn.startup() # Start game fn.game(words, timing, num_words)