Skip to content

Instantly share code, notes, and snippets.

View jsam's full-sized avatar
🦁

sam jsam

🦁
View GitHub Profile
@jsam
jsam / gist:8712248
Created January 30, 2014 16:17
[DSTG] Zadatak 5.
def alphabeta(igrajer, ploca, alpha, beta, depth, evaluate):
if depth == 0:
return evaluate(igrajer, ploca), None
def value(ploca, alpha, beta):
return -alphabeta(protivnik(igrajer), ploca, -beta, -alpha, depth-1, evaluate)[0]
moves = legalan_potez(igrajer, ploca)
if not moves:
if not bilokoji_lPotez(protivnik(igrajer), ploca):
@jsam
jsam / gist:8712190
Created January 30, 2014 16:14
[DSTG] Zadatak 4.
def minimax(igrajer, ploca, depth, evaluate):
def value(ploca):
return -minimax(protivnik(igrajer), ploca, depth-1, evaluate)[0]
if depth == 0:
return evaluate(igrajer, ploca), None
moves = legalan_potez(igrajer, ploca)
if not moves:
@jsam
jsam / gist:8712162
Created January 30, 2014 16:13
[DSTG] Zadatak 3.
TEZINE_PLOCE = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 120, -20, 20, 5, 5, 20, -20, 120, 0,
0, -20, -40, -5, -5, -5, -5, -40, -20, 0,
0, 20, -5, 15, 3, 3, 15, -5, 20, 0,
0, 5, -5, 3, 3, 3, 3, -5, 5, 0,
0, 5, -5, 3, 3, 3, 3, -5, 5, 0,
0, 20, -5, 15, 3, 3, 15, -5, 20, 0,
0, -20, -40, -5, -5, -5, -5, -40, -20, 0,
0, 120, -20, 20, 5, 5, 20, -20, 120, 0,
@jsam
jsam / gist:8712041
Last active August 29, 2015 13:55
[DSTG] Zadatak 2.
import random
def random_strategija(igrajer, ploca):
return random.choice(legalan_potez(igrajer, ploca))
@jsam
jsam / gist:8711991
Created January 30, 2014 16:06
[DSTG] Zadatak 1.
def pozicije():
"""Funkcija koja vraca sve validne pozicije na ploci"""
return [i for i in xrange(11, 89) if 1 <= (i % 10) <= 8]
def init_ploca():
"""Stvara novu plocu sa inicijalnim potezima za crnog i bijelog igraca ispunjenim"""
ploca = [obrub] * 100
for i in pozicije():
ploca[i] = prazno
ploca[44], ploca[45] = bijeli, crni
~# turnserver -c /usr/local/etc/turnserver.conf -v -a -r 95.85.6.252 --use-auth-secret --userdb /usr/local/etc/turnuserdb.conf
0:
RFC 3489/5389/5766/5780/6062/6156 STUN/TURN Server
Version Citrix-3.2.1.4 'Marshal West'
0:
==== Show him the instruments, Practical Frost: ====
0: TLS supported
0: DTLS supported
@jsam
jsam / gist:8469632
Created January 17, 2014 07:24
speed test
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2013 Matt Martz
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@jsam
jsam / gist:8441392
Created January 15, 2014 18:16
cjeo
import argparse, time, os, uuid
from pwd import getpwnam
from multiprocessing import Process, Queue
def sender(q, message):
_id = uuid.uuid4()
print("[S] sending {}".format(message))
for i, part in enumerate(message):
q.put({ 'data': part, 'sequence_number': i, 'sender_id': str(_id) })
import random, subprocess
def start_game():
operations = ['+', '-', '*', '/']
for i in range(10):
n1 = random.randint(0, 100)
n2 = random.randint(0, 100)
operation = operations[random.randint(0, 3)]
sol = raw_input("{} {} {} = ".format(n1, operation, n2))
@jsam
jsam / gist:8423438
Created January 14, 2014 18:43
flora2
/*
Neka je zadana baza znanja:
zaposlenik::osoba.
kupac::osoba.
menadzer::zaposlenik.
direktor::menadzer.
stefica:kupac.
ivek:zaposlenik.