Skip to content

Instantly share code, notes, and snippets.

@eladyaniv01
eladyaniv01 / dummybot.py
Created August 1, 2020 18:02
not running :(
class MATester(sc2.BotAI):
def __init__(self):
super().__init__()
self.map_data = MapData(self)
async def on_step(self, iteration: int):
reg1 = self.map_data.regions[1]
reg7 = self.map_data.regions[7]
p0 = reg1.center
D:\Users\elad\.virtualenvs\SC2MapAnalysis\Scripts\python.exe "D:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\pydevconsole.py" --mode=client --port=60982
import sys; print('Python %s on %s' % (sys.version, sys.platform))
sys.path.extend(['D:\\proj\\SC2MapAnalysis', 'D:/proj/SC2MapAnalysis'])
Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.
PyDev console: using IPython 7.16.1
@eladyaniv01
eladyaniv01 / recommended python packages for any project
Last active August 7, 2020 15:52
Code Quality , self reminders, python packages for new projects
from typing import Union, Tuple
import matplotlib.pyplot as plt
import numpy as np
from sc2 import BotAI
from sc2.position import Point2
from scipy.ndimage import binary_fill_holes, generate_binary_structure, label as ndlabel
from scipy.spatial import distance
from MapAnalyzer.constants import MIN_REGION_AREA, BINARY_STRUCTURE, MAX_REGION_AREA
@eladyaniv01
eladyaniv01 / dashboard.py
Created June 24, 2020 16:40
dashboard example
from django.utils.translation import ugettext_lazy as _
from django.urls import reverse
from grappelli.dashboard import modules, Dashboard
from grappelli.dashboard.utils import get_admin_site_name
class CustomIndexDashboard(Dashboard):
"""
Custom index dashboard for www.
from django.contrib import admin
from django_summernote.admin import SummernoteModelAdmin
from recms.models import *
class SupplierCmsObjectAdmin(SummernoteModelAdmin): # instead of ModelAdmin
summernote_fields = "__all__"
@eladyaniv01
eladyaniv01 / edge_points.py
Last active June 20, 2020 17:03
edge points for pythonsc2
def solve_region_grid(self):
grid = binary_fill_holes(self.game_info.placement_grid.data_numpy).astype(int)
# chokes = np.where WORK IN PROGRESS
# compiled_grid = grid * (np.abs(scipy.ndimage.laplace(grid)) > 0)
compiled_grid = grid
s = generate_binary_structure(2, 2)
labeled_array, num_features = label(compiled_grid, structure=s)
from Sc2botAI.BaseBot import BaseBot
import sys, os
sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
import logging
import random
import sc2
from sc2 import Race, Difficulty
from sc2.constants import *
from sc2.player import Bot, Computer
@eladyaniv01
eladyaniv01 / gist:d8521ff577a32efbfc51c59abea5c38a
Created June 12, 2019 14:18
simple RL enviroment where the bot can take steps, and needs to avoid the "enemy" and get the to the " food"
from PIL import Image
import cv2
import numpy as np
import matplotlib.pyplot as plt
import pickle
from matplotlib import style
import time
style.use("ggplot")
SIZE = 10