예제 #1
0
def human_play_mill(state):
    old_state_board = deepcopy(state.board)
    print()
    pp.print_table(state.board)

    br = 0
    possibilities = []
    for i in range(24):
        if not h.pieceInMill(state, i):
            if state.board[i] == 'B':
                possibilities.append(i)
                br += 1
    if br == 0:
        for i in range(24):
            if state.board[i] == 'B':
                possibilities.append(i)

    while True:
        place = input(
            "You just made the mill! Input the field from which you want to remove opponent\'s piece >> "
        )
        try:
            place = int(place)
        except:
            continue
        if place not in possibilities:
            print("You can\'t remove the piece from this field.")
        else:
            break

    g.TABLE[place] = g.EMPTYCELL[place]
    g.BLACKREMOVED += 1
    state.board = old_state_board
    new_state = State(g.TABLE, True, [place], state)
    main.play(new_state)
예제 #2
0
파일: MainMenu.py 프로젝트: Carke/Facemash
def MainMenu():
    MainMenu = pygame.display.set_mode([700,700])
    pygame.init()
    pygame.font.init()
    pygame.display.set_caption("Main Menu")
    pygame.mixer.music.set_volume(1.0)
    state = 0
    x1=0
    y1=0
    MusicVolume = 1
    state = 0
    pygame.mixer.init()
    pygame.mixer.music.load("Show Your Moves.ogg")
    pygame.mixer.music.play(-1)
    while state == 0:
        MainMenu = pygame.display.set_mode([700,700])
        pygame.display.set_caption("Main Menu")
        event = pygame.event.poll()
        MainMenu.fill([41,89,214])
        MouseOver()
        #draws initial images
        MainMenu.blit(Logo.image, Logo)
        MainMenu.blit(InstructionsButton.image, InstructionsButton)
        MainMenu.blit(PlayButton.image, PlayButton)
        MainMenu.blit(SettingButton.image,SettingButton) 
        MainMenu.blit(AboutButton.image, AboutButton)
        #MainMenu.blit(BackButtonText,(50,520))
        MainMenu.blit(Exit.image, Exit)
        # code for button mouseovers and events
        if Buttons.Collision((SettingButton)):
            if event.type == MOUSEBUTTONUP:
                SettingsWindow()
    
        if Buttons.Collision((AboutButton)): 
            if event.type == MOUSEBUTTONUP:
                AboutWindow()
    
        if Buttons.Collision((InstructionsButton)):
            if event.type == MOUSEBUTTONUP:
                main.learn()
                
        if Buttons.Collision((PlayButton)):
            if event.type ==  MOUSEBUTTONUP:
                main.play()    
        
        if Buttons.Resize((Exit), (130,70)):
            if event.type == MOUSEBUTTONUP:
                state = 1
                
        pygame.display.update()
        pygame.event.clear()
        # will be exit button currently escape key to end the game.
        for event in pygame.event.get():
            if event.type == KEYDOWN and event.key == K_ESCAPE:
                state = 1
def main():
    args = get_args()
    if args.mode == "demo":
        print('running best model for demonstration...')
        M.best_demo()
    if args.mode == "train":
        print('training model...')
        M.train(args.pops,args.gens)
    if args.mode == "play":
        print('play model...')
        M.play()
예제 #4
0
def play(screen):
    pygame.init()  # 초기화 하지 않을 경우, 일부 기능 정상 동작하지 않을수도 있음
    start_background = pygame.image.load("./image/start/start_back.png")
    start_background = pygame.transform.scale(start_background, (1024, 670))
    background = start_background

    font = pygame.font.SysFont("comicsansms", 70)
    font2 = pygame.font.SysFont("comicsansms", 30)
    on_button = font.render("ON ", True, (0, 0, 0))
    on_rect = on_button.get_rect(x=200, y=300)
    off_button = font.render("OFF ", True, (0, 0, 0))
    off_rect = off_button.get_rect(x=500, y=300)
    back_button = font2.render(" BACK ", True, (225, 225, 225), (0, 0, 0))
    back_rect = back_button.get_rect(x=370, y=450)

    running = True

    while running:
        screen.blit(background, (0, 0))
        screen.blit(on_button, on_rect)
        screen.blit(off_button, off_rect)
        screen.blit(back_button, back_rect)
        for event in pygame.event.get():
            if on_rect.collidepoint(
                    pygame.mouse.get_pos()):  ##start에 마우스가 올려져 있을 때
                if event.type == MOUSEBUTTONDOWN:  # 마우스를 클릭하면
                    music.play(0.3)
            if off_rect.collidepoint(
                    pygame.mouse.get_pos()):  ##start에 마우스가 올려져 있을 때
                if event.type == MOUSEBUTTONDOWN:  # 마우스를 클릭하면
                    music.play(0)
            if back_rect.collidepoint(
                    pygame.mouse.get_pos()):  ##start에 마우스가 올려져 있을 때
                if event.type == MOUSEBUTTONDOWN:  # 마우스를 클릭하면
                    main.play(screen)  #메인으로 (이전화면으로)
            if event.type == pygame.QUIT:  # 종료 입력시
                pygame.quit()
            if event.type == pygame.KEYDOWN:
                if (event.key == pygame.K_ESCAPE):  # ESE 누르면 종료
                    pygame.quit()
            #####창전환###########
            if keyboard.is_pressed('F12'):  # 화면 키우기
                screen = pygame.display.set_mode(
                    (1024, 670), pygame.FULLSCREEN | HWSURFACE
                    | DOUBLEBUF)  # 해상도 480*320, 전체화면모드, 하드웨어 가속사용, 더블버퍼모드
            if keyboard.is_pressed('F11'):  # 윈도우 모드
                screen = pygame.display.set_mode(
                    (1024, 670), DOUBLEBUF)  # 해상도 480*320, 윈도우모드, 더블버퍼모드
            ######################
        pygame.display.update()  # 화면 업데이트

    pygame.quit()
예제 #5
0
    def clicked(self):


        import main
        try:
            m = int(self.mass.text())
            v0 = int(self.v0.text())
            f1 = int(self.force1.text())
            f2 = int(self.force2.text())
            f = f1 + f2
            main.play(f,m,v0)
            self.invalid.setText("")
        except:
            self.invalid.setText("invalid input")
예제 #6
0
def human_play_move(state):
    old_state_board = deepcopy(state.board)
    possibilities1 = []
    for i in range(24):
        if state.board[i] == 'W':
            possibilities1.append(i)

    while True:
        first = input(
            "Input the field from which you want to move the piece >> ")
        try:
            first = int(first)
        except:
            continue
        if first not in possibilities1:
            print("You can't move the piece from this field.")
        else:
            br = 0
            for index in g.ADJDICT[first]:
                if state.board[index] in g.EMPTYCELL.values():
                    br = 1
                    break
            if br == 1:
                break
            print("This field doesn't have adjacent free fields.")

    possibilities2 = []
    for index in g.ADJDICT[first]:
        if state.board[index] in g.EMPTYCELL.values():
            possibilities2.append(index)

    while True:
        second = input(
            "Input the adjacent field on which you want to move the piece >> ")
        try:
            second = int(second)
        except:
            continue
        if second not in possibilities2:
            print("This field is not adjacent or it's already taken.")
        else:
            break

    g.TABLE[second] = 'W'
    g.TABLE[first] = g.EMPTYCELL[first]
    state.board = old_state_board
    new_state = State(g.TABLE, True, [first, second], state)
    main.play(new_state)
예제 #7
0
 def rps(self,user): #RPS
     string = input(f'|Welcome to Rock, Paper, Scissors!|\n'
           f'|B - Bet Mode|\n'
           f'|P - Practice Mode|\n'
           f'|* - Back to Game Options|\n')
     gametype = 0
     if string == 'B':
         rps.main(gametype,self.username,self.coins,self.score)
         user_functions.rps(self)
     elif string == 'P':
         gametype += 1
         rps.main(gametype,self.username,self.coins,self.score)
         user_functions.rps(self)
     elif string == '*':
         play(user)
     else:
         print(f'You did not select one of the options. Try Again.\n')
         user_functions.rps()
예제 #8
0
def AI_play(state, mill):
	move = next_move_AI(state, mill)
	old_state_table = deepcopy(state.board)
	if mill:
		g.TABLE[move[0]] = g.EMPTYCELL[move[0]]
		pp.print_table(state.board)
		print("Computer just made the MILL and he removed your piece from {}. field.".format(move[0]))
		g.WHITEREMOVED += 1
	elif g.PHASE == 'INIT':
		g.TABLE[move[0]] = 'B'
		pp.print_table(state.board)
		print("Computer has placed his piece at {}. field.".format(move[0]))
	elif g.PHASE == 'MOVE' or g.PHASE == 'FLY':
		g.TABLE[move[1]] = 'B'
		g.TABLE[move[0]] = g.EMPTYCELL[move[0]]
		pp.print_table(state.board)
		print("Computer has moved his piece from {}. field to {}. field.".format(move[0], move[1]))
	state.board = old_state_table
	new_state = State(g.TABLE, False, move, state)
	main.play(new_state)
예제 #9
0
def human_play_fly(state):
    old_state_board = deepcopy(state.board)
    possibilities1 = []
    possibilities_free = []
    for i in range(24):
        if state.board[i] == 'W':
            possibilities1.append(i)
        if state.board[i] in g.EMPTYCELL.values():
            possibilities_free.append(i)

    while True:
        first = input(
            "Input the field from which you want to move the piece (it's FLY phase time!): "
        )
        try:
            first = int(first)
        except:
            continue
        if first not in possibilities1:
            print("You can't move the piece from this field.")
        else:
            break

    while True:
        second = input(
            "Input ANY free field on the table on which you want to move the piece >> "
        )
        try:
            second = int(second)
        except:
            continue
        if second not in possibilities_free:
            print("This field is not free.")
        else:
            break

    g.TABLE[second] = 'W'
    g.TABLE[first] = g.EMPTYCELL[first]
    state.board = old_state_board
    new_state = State(g.TABLE, True, [first, second], state)
    main.play(new_state)
예제 #10
0
 def blackjack(self, user): #Blackjack
     string = input(f'|Welcome to BlackJack!|\n'
                    f'|B - Bet Mode|\n'
                    f'|P - Practice Mode|\n'
                    f'|R - Rules|\n'
                    f'|* - Back to Game Options|\n')
     gametype = 0
     if string == 'B':
         BlackJack.main(gametype, self.username, self.coins, self.score)
         user_functions.blackjack(self,user)
     elif string == 'P':
         gametype += 1
         BlackJack.main(gametype, self.username, self.coins, self.score)
         user_functions.blackjack(self,user)
     elif string == 'R':
         BlackJack.rules()
         user_functions.blackjack(self,user)
     elif string == '*':
         play(user)
     else:
         print(f'You did not select one of the options. Try Again.\n')
         user_functions.blackjack()
예제 #11
0
def human_play_init(state):
    old_state_board = deepcopy(state.board)
    possibilities = []
    for i in range(24):
        if state.board[i] in g.EMPTYCELL.values():
            possibilities.append(i)

    while True:
        place = input(
            "Input the field on which you want to place the piece >> ")
        try:
            place = int(place)
        except:
            continue
        if place not in possibilities:
            print("You can't place the piece on this field.")
        else:
            break

    g.TABLE[place] = 'W'
    state.board = old_state_board
    new_state = State(g.TABLE, True, [place], state)
    main.play(new_state)
예제 #12
0
def test_play_failed_attempt():
    initial_state = {
        ATTEMPT_KEY: 7,
        WORD_KEY: 'potato',
        WORD_VISIBILITY_KEY: [False, True, False, True, False, False],
    }
    player_input = 'x'

    expected_state = {
        ATTEMPT_KEY: 6,
        WORD_KEY: 'potato',
        WORD_VISIBILITY_KEY: [False, True, False, True, False, False],
    }
    expected_right_guess = False

    res_state, res_right_guess = play(initial_state, player_input)

    assert expected_right_guess == res_right_guess
    assert expected_state == res_state
예제 #13
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = 'ipetrash'

if __name__ == '__main__':
    import sys

    if len(sys.argv) > 1:
        from main import play
        play(sys.argv[1])

    else:
        import os
        file_name = os.path.basename(sys.argv[0])
        print('usage: {} [-h] audio_file_name'.format(file_name))
예제 #14
0
 def start(self):
     logging.info("starting NightAction")
     play_klaxon()
     main.play("night")
예제 #15
0
 def start(self):
     logging.info("starting EveningAction")
     play_klaxon()
     main.play("evening")
예제 #16
0
 def start(self):
     logging.info("starting AfternoonAction")
     play_klaxon()
     main.play("afternoon", default_light_mode=arduino.OFF)
예제 #17
0
 def start(self):
     logging.info("starting MorningAction")
     play_klaxon()
     main.play("morning", default_light_mode=arduino.OFF)
예제 #18
0
def check_play_button(play_button, mouse_x, mouse_y):
    #запускает новую игру при нажатии кнопки Play
    button_clicked = play_button.rect.collidepoint(mouse_x, mouse_y)
    if button_clicked:
        #sound of clicking on button
        play()
예제 #19
0
import sys
import os.path

try:
    import main
except ImportError:
    print("Error: Could not start the game. Please make sure you're in the "
          "'terminal-games' directory.")
    sys.exit(1)

PATH = os.path.abspath(os.path.dirname(__file__))
main.WORDS_FILENAME = os.path.join(PATH, 'words.json')
main.INSTRUCTION_FILENAME = os.path.join(PATH, 'instructions.txt')
main.play()
예제 #20
0
파일: menu.py 프로젝트: Nitwon/Turncoat
       | |   | |   | ||     __)| (\ \) || |      | |   | ||  ___  |   | |
       | |   | |   | || (\ (   | | \   || |      | |   | || (   ) |   | |
       | |   | (___) || ) \ \__| )  \  || (____/\| (___) || )   ( |   | |
       )_(   (_______)|/   \__/|/    )_)(_______/(_______)|/     \|   )_(


            Enter a number to choose an option:
                1. Start game
                2. Start game without intro sequence
                3. Exit
"""
    if error == True:
        print "\n                That's not an option!\n"
    else:
        print "\n\n"
    
    error = False
    
    option = raw_input('> ')

    if option == '1':
        main.play(1)
    
    elif option == '2':
        main.play(2)
    
    elif option == '3':
        exit(1)
    
    else:
        error = True
예제 #21
0
from main import play

# RUn play command
play()

break 100

def playLoop(time, def mplayerRunning():
    doc = "The mplayerRunning property."
    def fget(self):
        return self._mplayerRunning
    def fset(self, value):
        self._mplayerRunning = value
    def fdel(self):
        del self._mplayerRunning
    return locals()
mplayerRunning = property(**mplayerRunning())):
    pass

class mainplayerClass(object):
    """docstring for mainplayerClass"""
    def __init__(selfreturn(__init__), arg):
        super(mainplayerClass, self)return(__init__).__init__()
        self.arg = arg
        return(__init__)
예제 #22
0
def testWorld():

    assert main.get_list_neighbors(2, 2) == Set([(1, 1), (1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2), (3, 3)])
    assert main.get_list_neighbors(3, 3) == Set([(2, 2), (2, 3), (2, 4), (3, 2), (3, 4), (4, 2), (4, 3), (4, 4)])

    main.set_alive(2, 2)
    main.set_alive(2, 3)
    main.set_alive(2, 4)
    main.set_alive(3, 2)
    main.set_alive(3, 4)
    assert main.get_num_alive_neighbors(3, 3) == 5

    main.set_dead(3, 4)
    assert main.get_num_alive_neighbors(3, 3) == 4

    assert main.is_underpopulated(3, 3) == False

    main.set_alive(6, 6)
    assert main.is_underpopulated(6, 6) == True

    main.set_alive(6, 7)
    assert main.is_survival(6, 6) == False

    main.set_alive(6, 5)
    assert main.is_survival(6, 6) == True

    main.set_alive(5, 5)
    assert main.is_survival(6, 6) == True

    main.set_alive(5, 6)
    assert main.is_survival(6, 6) == False

    assert main.is_overpopulated(6, 6) == True

    main.set_dead(5, 6)
    assert main.is_overpopulated(6, 6) == False

    main.set_dead(6, 6)
    assert main.is_birth(6, 6) == True

    main.set_dead(5, 5)
    assert main.is_birth(6, 6) == False

    assert main.next_state_is_alive(11, 11) == False

    main.set_alive(11, 11)
    assert main.next_state_is_alive(11, 11) == False

    main.set_alive(10, 10)
    assert main.next_state_is_alive(11, 11) == False

    main.set_alive(10, 11)
    assert main.next_state_is_alive(11, 11) == True

    main.set_alive(11, 12)
    assert main.next_state_is_alive(11, 11) == True

    main.set_dead(11, 11)
    assert main.next_state_is_alive(11, 11) == True

    main.set_alive(11, 11)
    main.set_alive(10, 12)
    assert main.next_state_is_alive(11, 11) == False

    main.reset_game()
    main.play([(1,1), (1,3), (2, 3), (2,4), (4,4)])