Ejemplo n.º 1
0
def start():
    """ initiate game, reset all"""
    global column, row, pin_grid, button_grid
    global this_mind, possibilities, t1, repeat, run_time
    global helpcolor, help_active, had_help, game
    helpcolor = 1
    help_active = 0
    # repeat = False
    had_help = False
    # stores all correction pins (black and white)
    pin_grid = []

    # stores all color guesses
    button_grid = [[None] * 4 for _ in range(10)]

    # starting row and column
    row = 0
    column = 0

    # initiate mastermind session
    this_mind = mastermind.Mastermind(repeat=repeat)
    possibilities = this_mind.remaining_possibilities()

    # start timer
    t1 = time.time()
    t2 = None
    run_time = True
    game += 1
Ejemplo n.º 2
0
import mastermind

mastermind.Mastermind()
Ejemplo n.º 3
0
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 22 18:08:54 2018

@author: francois.sidoroff
"""

import mastermind as mm
import argparse
parser = argparse.ArgumentParser(
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("-a", "--alphabet", action='store', default='ABCDEF',
                        help = 'alphabet: the symbols used for colors')
parser.add_argument("-n", "--number", action='store', default=4,
                        help="number of positions in the code")
parser.add_argument("-z", "--nbgames", action='store', default=10,
                        help="number of games to be played")
args = parser.parse_args()
with open("mm_stats.jnl", "w", encoding='utf-8')as journal:
    jeu = mm.Mastermind(journal, args.alphabet, int(args.number))
    nb_coups = ()
    nct = 0
    for i in range(int(args.nbgames)):
        nc = jeu.partie(1, 1)
        nb_coups += (nc,)
        nct += nc
    mean_nbc = nct/int(args.nbgames)
    bilan = f"------ finalement ------\n{nb_coups}, moy = {mean_nbc}"
    journal.write(bilan)
    print(bilan)
Ejemplo n.º 4
0
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 22 18:08:54 2018

@author: francois.sidoroff
"""

import mastermind as mm

with open("mastermind.jnl", "w", encoding='utf-8') as journal:
    jeu = mm.Mastermind(journal, 'ABCDEFGH', 4)
    jeu.partie(1, 1)
Ejemplo n.º 5
0
###########################################
#
# Main MasterMind
#
# Author : Antoine-Alexis Bourdon
# Link : https://github.com/antoinealexisb/masterMind
# Version : 0.1.0
# Dependency : mastermind, gui_mastermind
#
###########################################

import mastermind
import gui_mastermind

if __name__ == '__main__':
    mm1 = mastermind.Mastermind(8)
    mm1.lancer()
    mm2 = mastermind.Mastermind(8)
    mm2.lancer()
    vue = gui_mastermind.VueMM(mm1, mm2)
    vue.lancer()
Ejemplo n.º 6
0
 def test_prepare_word_positive(self):
     game = mastermind.Mastermind(10, ['a', 'b', 'c'], 10)
     game.prepare_word()
     self.assertEqual(len(game.word), 10)
Ejemplo n.º 7
0
# global variables and their defaults
helpcolor = 1
help_active = 0
repeat = False
had_help = False
# stores all correction pins (black and white)
pin_grid = []

# stores all color guesses
button_grid = [[None] * 4 for _ in range(10)]

# starting row and column
row = 0
column = 0

this_mind = mastermind.Mastermind(repeat=repeat)
possibilities = this_mind.remaining_possibilities()

# start timer
t1 = time.time()
t2 = None
run_time = True

game = 0  # read from sessionlog
name = 'anna'
sessionlogfile = '.mastermind_session.log'

# Define some colors
WHITE = (255, 255, 255)
YELLOW = (255, 255, 0)
ORANGE = (255, 125, 0)
Ejemplo n.º 8
0
import mastermind as game
import game_config as conf

length, symbols, round_count = conf.prepare_game_parameters()

obj = game.Mastermind(length, symbols, round_count, False)

obj.play()

obj.print_log()