def test_J2_ganador(self):
        juego = Tennis("Alan", "Kenny")
        juego.PuntosJ2()
        juego.PuntosJ2()
        juego.PuntosJ2()
        juego.PuntosJ2()

        self.assertEquals(" Gana", juego.get_Marcador())
    def test_Win_H(self):
        player1 = Player()
        player2 = Player()
        local_Tennis = Tennis()

        for i in range(0, 3):
            local_Tennis.WinTheSet(player1, player2)

        self.assertEqual(local_Tennis.winner, player1)
        self.assertEqual(local_Tennis.looser, player2)
    def test_ShouldSetTieBreakPoint_And_NotSetPoint_After_TieBreak_Activated(
            self):
        player1 = Player()
        player2 = Player()
        local_Tennis = Tennis()

        local_Tennis.ActivateTieBreak()
        local_Tennis.WinThePoint(player1, player2)

        self.assertEqual(player1.tieBreakPoint, 1)
        self.assertEqual(player2.tieBreakPoint, 0)
        self.assertEqual(player1.point, '0')
        self.assertEqual(player2.point, '0')
    def test_ShouldWin_Set_After_7_0_TieBreakPoint(self):
        player1 = Player()
        player2 = Player()
        local_Tennis = Tennis()

        local_Tennis.ActivateTieBreak()

        for i in range(0, 7):
            local_Tennis.WinThePoint(player1, player2)

        self.assertEqual(player1.set, 1)
        self.assertEqual(player2.set, 0)
        self.assertEqual(player1.jeux, 0)
        self.assertEqual(player2.jeux, 0)
        self.assertEqual(local_Tennis.tieBreakActivated, False)
        self.assertEqual(player1.tieBreakPoint, 0)
        self.assertEqual(player2.tieBreakPoint, 0)
    def test_ShouldTieBreak_Activated(self):
        player1 = Player()
        player2 = Player()
        local_Tennis = Tennis()

        for i in range(0, 5):
            local_Tennis.WinTheJeux(player1, player2)

        for i in range(0, 5):
            local_Tennis.WinTheJeux(player2, player1)

        local_Tennis.WinTheJeux(player1, player2)
        local_Tennis.WinTheJeux(player2, player1)

        self.assertEqual(local_Tennis.tieBreakActivated, True)
        self.assertEqual(player1.set, 0)
        self.assertEqual(player2.set, 0)
        self.assertEqual(player1.jeux, 6)
        self.assertEqual(player2.jeux, 6)
    def test_ventaja(self):
        juego = Tennis("Alan", "Kenny")
        juego.PuntosJ1()
        juego.PuntosJ1()
        juego.PuntosJ1()
        juego.PuntosJ1()
        juego.PuntosJ1()
        juego.PuntosJ2()
        juego.PuntosJ2()
        juego.PuntosJ2()
        juego.PuntosJ2()

        self.assertEquals("Tiene ventaja ", juego.get_Marcador())
Beispiel #7
0
class TestTennis(unittest.TestCase):

    def setUp(self):
        self.tenis = Tennis()

    def test_prueba1(self):
        resultado = self.tenis.anoto(15, 0)
        self.assertEqual('Jugador 1 15 Jugador 2 0', resultado)

    def test_prueba2(self):
        resultado = self.tenis.anoto(30, 0)
        self.assertEqual('Jugador 1 30 Jugador 2 0', resultado)

    def test_prueba3(self):
        resultado = self.tenis.anoto(40, 40)
        self.assertEqual('Deuce', resultado)

    def test_prueba4(self):
        resultado = self.tenis.anoto(40, 50)
        self.assertEqual('Advantage Jugador 2', resultado)
    def test_Deuce(self):
        juego = Tennis("Alan", "Kenny")
        juego.PuntosJ1()
        juego.PuntosJ1()
        juego.PuntosJ1()
        juego.PuntosJ2()
        juego.PuntosJ2()
        juego.PuntosJ2()

        self.assertEquals("Deuce", juego.get_Marcador())
Beispiel #9
0
def main(args):
    env = Tennis(args.env_path)

    config = {
        'state_size': env.state_size,
        'action_size': env.action_size,
        'reward_accum_steps': 1000,
        'random_seed': 1,
        'gamma': 0.99,
        'update_cycle': 400,
        'update_times': 10,
        'buffer_size': int(1e6),
        'batch_size': 1024,
        'warm_start_size': 1024,
        'n_episode': 1000000,
        'max_t': 1000,
        'window_size': 100,
        'ckpt_prefix': 'checkpoint',
        'reset_cycle': 20000,
    }

    agents = [ddpg_agent.Agent(**config) for _ in range(env.num_agents)]

    if args.train:
        scores = maddpg(agents, env, **config)
        plot(scores, args.png_path)

    if args.show:
        for agent_i, agent in enumerate(agents):
            agent.actor_local.load_state_dict(
                torch.load('checkpoint_actor_{}.pth'.format(agent_i),
                           lambda a, b: a))
            agent.critic_local.load_state_dict(
                torch.load('checkpoint_critic_{}.pth'.format(agent_i),
                           lambda a, b: a))
        show(agents, env)
    def test_ShouldNotWin_Set_IfAvance_Inferior_2(self):
        player1 = Player()
        player2 = Player()
        local_Tennis = Tennis()

        local_Tennis.ActivateTieBreak()

        for i in range(0, 6):
            local_Tennis.WinThePoint(player1, player2)

        for i in range(0, 6):
            local_Tennis.WinThePoint(player2, player1)

        local_Tennis.WinThePoint(player1, player2)

        self.assertEqual(player1.set, 0)
        self.assertEqual(player2.set, 0)
        self.assertEqual(local_Tennis.tieBreakActivated, True)
        self.assertEqual(player1.tieBreakPoint, 7)
        self.assertEqual(player2.tieBreakPoint, 6)
    def test_Love_All(self):
        juego = Tennis("Alan", "Kenny")

        self.assertEquals("love all", juego.get_Marcador())
Beispiel #12
0
 def setUp(self):
     self.tenis = Tennis()
Beispiel #13
0
	def testgana_1(self):
		ten = Tennis()
		self.assertEqual("0 0", ten.show_score())

		ten.add_point(1)
		self.assertEqual("15 0", ten.show_score())

		ten.add_point(2)
		self.assertEqual("15 15", ten.show_score())

		ten.add_point(1)
		self.assertEqual("30 15", ten.show_score())

		ten.add_point(1)
		self.assertEqual("40 15", ten.show_score())

		ten.add_point(1)
		self.assertEqual("GAME Player 1", ten.show_score())
class TennisTest(unittest.TestCase):
    tennis = Tennis()

    def test_ShouldReturn_0_0(self):
        player1 = Player()
        player2 = Player()

        self.assertEqual(player1.point, '0')
        self.assertEqual(player2.point, '0')

    def test_ShouldReturn_15_0(self):
        player1 = Player()
        player2 = Player()

        self.tennis.WinThePoint(player1, player2)

        self.assertEqual(player1.point, '15')
        self.assertEqual(player2.point, '0')

    def test_ShouldReturn_30_0(self):
        player1 = Player()
        player2 = Player()

        for i in range(0, 2):
            self.tennis.WinThePoint(player1, player2)

        self.assertEqual(player1.point, '30')
        self.assertEqual(player2.point, '0')

    def test_ShouldReturn_40_0(self):
        player1 = Player()
        player2 = Player()

        for i in range(0, 3):
            self.tennis.WinThePoint(player1, player2)

        self.assertEqual(player1.point, '40')
        self.assertEqual(player2.point, '0')

    def test_ShouldReturn_A_40(self):
        player1 = Player()
        player2 = Player()

        for i in range(0, 3):
            self.tennis.WinThePoint(player1, player2)

        for i in range(0, 3):
            self.tennis.WinThePoint(player2, player1)

        self.tennis.WinThePoint(player1, player2)

        self.assertEqual(player1.point, 'A')
        self.assertEqual(player2.point, '40')

    def test_ShouldReturn_40_40_After_A_40(self):
        player1 = Player()
        player2 = Player()

        for i in range(0, 3):
            self.tennis.WinThePoint(player1, player2)

        for i in range(0, 3):
            self.tennis.WinThePoint(player2, player1)

        self.tennis.WinThePoint(player1, player2)
        self.tennis.WinThePoint(player2, player1)

        self.assertEqual(player1.point, '40')
        self.assertEqual(player2.point, '40')

    def test_ShouldWin_Jeux_after_40_0(self):
        player1 = Player()
        player2 = Player()

        for i in range(0, 4):
            self.tennis.WinThePoint(player1, player2)

        self.assertEqual(player1.jeux, 1)
        self.assertEqual(player2.jeux, 0)
        self.assertEqual(player1.point, '0')
        self.assertEqual(player2.point, '0')

    def test_ShouldWin_Jeux_after_A_40(self):
        player1 = Player()
        player2 = Player()

        for i in range(0, 3):
            self.tennis.WinThePoint(player1, player2)

        for i in range(0, 3):
            self.tennis.WinThePoint(player2, player1)

        for i in range(0, 2):
            self.tennis.WinThePoint(player1, player2)

        self.assertEqual(player1.jeux, 1)
        self.assertEqual(player2.jeux, 0)
        self.assertEqual(player1.point, '0')
        self.assertEqual(player2.point, '0')

    def test_ShouldWin_Set_After_6_0(self):
        player1 = Player()
        player2 = Player()

        for i in range(0, 6):
            self.tennis.WinTheJeux(player1, player2)

        self.assertEqual(player1.set, 1)
        self.assertEqual(player2.set, 0)
        self.assertEqual(player1.jeux, 0)
        self.assertEqual(player2.jeux, 0)

    def test_ShouldNotWin_Set_IfAvance_Inferior_2(self):
        player1 = Player()
        player2 = Player()

        for i in range(0, 5):
            self.tennis.WinTheJeux(player1, player2)

        for i in range(0, 5):
            self.tennis.WinTheJeux(player2, player1)

        self.tennis.WinTheJeux(player1, player2)

        self.assertEqual(player1.set, 0)
        self.assertEqual(player2.set, 0)
        self.assertEqual(player1.jeux, 6)
        self.assertEqual(player2.jeux, 5)

    def test_ShouldWin_Set_After_6_0(self):
        player1 = Player()
        player2 = Player()

        for i in range(0, 5):
            self.tennis.WinTheJeux(player1, player2)

        for i in range(0, 5):
            self.tennis.WinTheJeux(player2, player1)

        for i in range(0, 2):
            self.tennis.WinTheJeux(player1, player2)

        self.assertEqual(player1.set, 1)
        self.assertEqual(player2.set, 0)
        self.assertEqual(player1.jeux, 0)
        self.assertEqual(player2.jeux, 0)

    def test_ShouldTieBreak_Activated(self):
        player1 = Player()
        player2 = Player()
        local_Tennis = Tennis()

        for i in range(0, 5):
            local_Tennis.WinTheJeux(player1, player2)

        for i in range(0, 5):
            local_Tennis.WinTheJeux(player2, player1)

        local_Tennis.WinTheJeux(player1, player2)
        local_Tennis.WinTheJeux(player2, player1)

        self.assertEqual(local_Tennis.tieBreakActivated, True)
        self.assertEqual(player1.set, 0)
        self.assertEqual(player2.set, 0)
        self.assertEqual(player1.jeux, 6)
        self.assertEqual(player2.jeux, 6)

    def test_ShouldSetTieBreakPoint_And_NotSetPoint_After_TieBreak_Activated(
            self):
        player1 = Player()
        player2 = Player()
        local_Tennis = Tennis()

        local_Tennis.ActivateTieBreak()
        local_Tennis.WinThePoint(player1, player2)

        self.assertEqual(player1.tieBreakPoint, 1)
        self.assertEqual(player2.tieBreakPoint, 0)
        self.assertEqual(player1.point, '0')
        self.assertEqual(player2.point, '0')

    def test_ShouldWin_Set_After_7_0_TieBreakPoint(self):
        player1 = Player()
        player2 = Player()
        local_Tennis = Tennis()

        local_Tennis.ActivateTieBreak()

        for i in range(0, 7):
            local_Tennis.WinThePoint(player1, player2)

        self.assertEqual(player1.set, 1)
        self.assertEqual(player2.set, 0)
        self.assertEqual(player1.jeux, 0)
        self.assertEqual(player2.jeux, 0)
        self.assertEqual(local_Tennis.tieBreakActivated, False)
        self.assertEqual(player1.tieBreakPoint, 0)
        self.assertEqual(player2.tieBreakPoint, 0)

    def test_ShouldNotWin_Set_IfAvance_Inferior_2(self):
        player1 = Player()
        player2 = Player()
        local_Tennis = Tennis()

        local_Tennis.ActivateTieBreak()

        for i in range(0, 6):
            local_Tennis.WinThePoint(player1, player2)

        for i in range(0, 6):
            local_Tennis.WinThePoint(player2, player1)

        local_Tennis.WinThePoint(player1, player2)

        self.assertEqual(player1.set, 0)
        self.assertEqual(player2.set, 0)
        self.assertEqual(local_Tennis.tieBreakActivated, True)
        self.assertEqual(player1.tieBreakPoint, 7)
        self.assertEqual(player2.tieBreakPoint, 6)

    def test_ShouldWin_Set_IfAvance_Superior_2(self):
        player1 = Player()
        player2 = Player()
        local_Tennis = Tennis()

        local_Tennis.ActivateTieBreak()

        for i in range(0, 6):
            local_Tennis.WinThePoint(player1, player2)

        for i in range(0, 6):
            local_Tennis.WinThePoint(player2, player1)

        local_Tennis.WinThePoint(player1, player2)
        local_Tennis.WinThePoint(player1, player2)

        self.assertEqual(player1.set, 1)
        self.assertEqual(player2.set, 0)
        self.assertEqual(local_Tennis.tieBreakActivated, False)
        self.assertEqual(player1.tieBreakPoint, 0)
        self.assertEqual(player2.tieBreakPoint, 0)

    def test_Win_H(self):
        player1 = Player()
        player2 = Player()
        local_Tennis = Tennis()

        for i in range(0, 3):
            local_Tennis.WinTheSet(player1, player2)

        self.assertEqual(local_Tennis.winner, player1)
        self.assertEqual(local_Tennis.looser, player2)

    def test_Win_F(self):
        player1 = Player()
        player2 = Player()
        local_Tennis = Tennis()
        local_Tennis.sex = 'F'

        for i in range(0, 2):
            local_Tennis.WinTheSet(player1, player2)

        self.assertEqual(local_Tennis.winner, player1)
        self.assertEqual(local_Tennis.looser, player2)
Beispiel #15
0
	def testgana_2(self):
		ten = Tennis()
		self.assertEqual("0 0", ten.show_score())

		ten.add_point(2)
		self.assertEqual("0 15", ten.show_score())

		ten.add_point(2)
		self.assertEqual("0 30", ten.show_score())

		ten.add_point(2)
		self.assertEqual("0 40", ten.show_score())

		ten.add_point(2)
		self.assertEqual("GAME Player 2", ten.show_score())
Beispiel #16
0
	def testgana_22(self):
		ten = Tennis()
		self.assertEqual("0 0", ten.show_score())

		ten.add_point(2)
		self.assertEqual("0 15", ten.show_score())

		ten.add_point(2)
		self.assertEqual("0 30", ten.show_score())

		ten.add_point(1)
		self.assertEqual("15 30", ten.show_score())

		ten.add_point(2)
		self.assertEqual("15 40", ten.show_score())

		ten.add_point(1)
		self.assertEqual("30 40", ten.show_score())

		ten.add_point(1)
		self.assertEqual("DEUCE", ten.show_score())

		ten.add_point(2)
		self.assertEqual("40 ADV", ten.show_score())

		ten.add_point(2)
		self.assertEqual("GAME Player 2", ten.show_score())
Beispiel #17
0
 def test_uno(self):
     tennis = Tennis()
     tennis.juego()
    def test_primer_punto_j1(self):
        juego = Tennis("Alan", "Kenny")

        juego.PuntosJ1()

        self.assertEquals("Quince,love", juego.get_Marcador())
    def test_quince_all(self):
        juego = Tennis("Alan", "Kenny")
        juego.PuntosJ1()
        juego.PuntosJ2()

        self.assertEquals("Quince all", juego.get_Marcador())
Beispiel #20
0
from Tennis import Player
from Tennis import Tennis
import time
from random import randint
import os

tennis = Tennis()
player1 = Player()
player2 = Player()


def ShowScore():
    print("joueur 1 :     set    jeux    point")
    print("               " + str(player1.set) + "      " + str(player1.jeux) +
          "       " + player1.point + "")

    print("joueur 2 :     set    jeux    point")
    print("               " + str(player2.set) + "      " + str(player2.jeux) +
          "       " + player2.point + "")
    print("-----------------------------------")


z = 0
j = 1

while tennis.winner == None:
    os.system('cls')  # For Windows

    if (tennis.sex == 'H'):
        print("-----------------------------------")
        print("Tennis Masculin")
Beispiel #21
0
 def test_uno(self):
     tennis = Tennis()
     tennis.juego()