Exemplo n.º 1
0
import random as rd
from snake_env import Render, Map
from IA import IA_rl, IA_random, IA_minimax

n_agents = 2
n_candies = 10
gridsize = 30
n_total_iter = 2000
sliding_window = 100
step = 10

IA_learning = IA_rl.IA(0)
adversary = IA_random.IA(1)
#adversary = IA_minimax.IA(1)

M = Map(nagents=n_agents, ncandies=n_candies, gridsize=gridsize)
e = Render(M, spacing=20)
q = None

current_result = 0
all_results = []
result = []

for match in range(1, n_total_iter + 1):

    while True:

        #e.render()

        if len(M.activeAgents) < n_agents:
            if 0 in M.activeAgents:
Exemplo n.º 2
0
import numpy as np
from pygame.locals import *
import pygame
import random as rd

from snake_env import Render, Map
import time

nagents = 3
M = Map(nagents=nagents, ncandies=3, gridsize=40)
e = Render(M, spacing=20)

step = 0
while True:
    index = 0
    print(step)
    e.render()

    next_move = rd.randint(0, 3)
    print(next_move)
    M.agents[index].nextAction(next_move)

    step += 1

    r, done = M.step()

    time.sleep(0.5)

#    if done:
#        e.reset()
Exemplo n.º 3
0
from snake_env import Map, Render

M = Map(nagents=2, ncandies=3, gridsize=40)
e = Render(M, spacing=20)
e.render()

M.update(0, 1)
e.render()
M.revertLastUpdate()
e.render()
M.update(1, 1)
e.render()
M.update(1, 0)
M.update(1, 3)
e.render()
M.revertLastUpdate()
M.possibilities(1)
#s=M.agents[0]