예제 #1
0
def load_sudoku(sudoku):
    """ Create a list of fields with all relevant information based on a sudoku. The sudoku needs to be in the form found in Sudokus.py """
    y = 0
    id_num = 0
    fields = []
    
    for row in sudoku:
        x = 0
        for number in row:
            # Create a field
            field = Field()

            # Set coordinates, 3x3 box and and id
            field.x = x
            field.y = y
            field.box = set_box_number(x, y)
            field.id = id_num
            

            field.number = number

            # If the field has a number, that is the only possibility
            if field.number != 0:
                field.possible = {field.number}

            fields.append(field)

            # Step up all index
            x += 1
            id_num += 1
        y += 1
        
    return fields
예제 #2
0
def confusion_attack(def_poke):

    confusion_move = Move()
    confusion_move.i_pow = 40
    confusion_move.str_type = "confusion"

    i_dmg = attack(def_poke, def_poke, confusion_move, Field())

    return i_dmg
예제 #3
0
def copy_fields(fields):
    """ Create a copy of the fields in the list called "fields" """
    fields_c = []
    for field in fields:
        # copy all values in the fields and append them to copy list
        f = Field()
        f.x = field.x
        f.y = field.y
        f.box = field.box
        f.id = field.id

        f.number = field.number
        f.possible = field.possible

        fields_c.append(f)
    
    return fields_c
예제 #4
0
    def __init__(self, l_new_players=[]):
        self.firstRun = True

        self.field = Field(l_new_players[0], l_new_players[1])

        self.l_players = l_new_players

        self.b_gameover = False

        for player in self.l_players:
            other_player = self.get_other_player(player)

            player.i_turn_readiness = NOT_READY

            player.send_data(FOUND_BATTLE)
            player.send_pokes(other_player.team)
            player.send_data(
                SELECT_POKE +
                json.dumps({"availpoke": player.get_available_pokes()}))
예제 #5
0
poke1.base_stats.i_spd = 236
poke1.base_stats.i_spe = 259
poke1.usable_stats = poke1.base_stats
poke1.type_1 = Type("psychic")
poke1.type_2 = None
poke1.str_ability = "contrary"
#poke1.str_status = 'burn'

poke2 = Pokeman()
poke2.base_stats.i_atk = 212
poke2.base_stats.i_def = 236
poke2.base_stats.i_hp = 341
poke2.base_stats.i_spa = 236
poke2.base_stats.i_spd = 236
poke2.base_stats.i_spe = 259
poke2.usable_stats = poke2.base_stats
poke2.type_1 = Type("psychic")
poke2.type_2 = None
poke2.str_ability = "competitive"
move = Move("feather-dance")

field = Field()
#field.terrain = Terrain.ELECTRIC

print(attack(poke1, poke2, move, field))
print(str_prv_mov)

#move = Move("surf")
#print(attack(poke2, poke1, move, field))
#print(str_prv_mov)
예제 #6
0
        print(np_action)
            #act_value = self.model.predict(np_action)
            #if act_value > max_act_value:
            #    best_actions = [a,]
            #    max_act_value = act_value
            #elif act_value == max_act_value:
            #    best_actions.append(a)
        #return random.choice(best_actions)


size = 10
barriar_rate = 0.1

maze_1 = Maze(size, barriar_rate)
maze, start_point, goal_point = maze_1.generate_maze()
maze_field = Field(maze, start_point, goal_point)

maze_field.display()
print("start end point")
print(start_point, goal_point)

action = maze_field.get_actions(state=start_point)
print("action")
print(action)

#myAgent = AgentClass(2,3)
state = np.array(start_point)

#print(state)
print("state, action 0")
print(np.array( [[state,action[0]]] ) )