Ejemplo n.º 1
0
func readHosts() {
	now, _, _ := os.Time()
	hp := hostsPath
	if len(hosts.data) == 0 || hosts.time+cacheMaxAge <= now || hosts.path != hp {
		hs := make(map[string][]string)
		var file *file
		if file, _ = open(hp); file == nil {
			return
		}
		for line, ok := file.readLine(); ok; line, ok = file.readLine() {
			if i := byteIndex(line, '#'); i >= 0 {
				// Discard comments.
				line = line[0:i]
			}
			f := getFields(line)
			if len(f) < 2 || ParseIP(f[0]) == nil {
				continue
			}
			for i := 1; i < len(f); i++ {
				h := f[i]
				hs[h] = append(hs[h], f[0])
			}
		}
		// Update the data cache.
		hosts.time, _, _ = os.Time()
		hosts.path = hp
		hosts.data = hs
		file.close()
	}
}
Ejemplo n.º 2
0
func main() {
	sec, nsec, _ := os.Time()

	ts := bridge.GetValidTables(0, " P P1C P1H P3H P4H P P P", 100, bridge.DefaultConventions())
	fmt.Println("Conventions are:", ts.Conventions)
	fmt.Println(ts)

	ts = bridge.GetValidTables(0, " P 1C1H P2H P3H P4H P P P", 100, bridge.DefaultConventions())
	fmt.Println("Conventions are:", ts.Conventions)
	fmt.Println(ts)

	sec2, nsec2, _ := os.Time()
	name, _ := os.Hostname()
	dt := float64(sec2-sec) + 1e-9*float64(nsec2-nsec)
	timelimits := map[string]float64{"collins": 1.7, "morland": 13, "bennet": 4, "bingley": 3}
	fmt.Println("It took ", dt, "seconds on", name)
	expected, ok := timelimits[name]
	if ok {
		if dt > expected {
			fmt.Println("Exceeded expected time by", dt-expected, "seconds.")
			os.Exit(1)
		}
		fmt.Println("Expected", expected, "seconds on", name)
	} else {
		fmt.Println("You should add statistics for", name)
		os.Exit(1)
	}
}
Ejemplo n.º 3
0
func (fs *FileSystem) MkDir(parent uint64, name string) *Inode {
	if parent != 1 {
		// Let's check that the parent actually exists...
		if _, ok := fs.nodes[parent]; !ok {
			panic("yikes, the parent doesn't exist!")
		}
	}
	var a = new(Inode)
	a.Ino = fs.maxino + 1
	fs.maxino = a.Ino
	a.Mode = fuse.S_IFDIR + 0755
	a.Uid = 1137
	a.Gid = 1137
	a.Nlink = 1
	sec, nsec, _ := os.Time()
	a.Mtime = uint64(sec) - 3600
	a.Mtimensec = uint32(nsec)
	a.Ctime = uint64(sec) - 3600
	a.Ctimensec = uint32(nsec)
	a.DirContents = make(map[string]uint64)
	// Create . and .. entries here
	//a.DirContents["."] = a.Ino
	//a.DirContents[".."] = parent
	fs.nodes[a.Ino] = a
	// Add entry to parent directoory
	if name != "." {
		fs.nodes[parent].DirContents[name] = a.Ino
	}
	return a
}
Ejemplo n.º 4
0
// Nanoseconds reports the number of nanoseconds since the Unix epoch,
// January 1, 1970 00:00:00 UTC.
func Nanoseconds() int64 {
	sec, nsec, err := os.Time()
	if err != nil {
		panic(err)
	}
	return sec*1e9 + nsec
}
Ejemplo n.º 5
0
// Seconds reports the number of seconds since the Unix epoch,
// January 1, 1970 00:00:00 UTC.
func Seconds() int64 {
	sec, _, err := os.Time()
	if err != nil {
		panic(err)
	}
	return sec
}
Ejemplo n.º 6
0
// Nanoseconds reports the number of nanoseconds since the Unix epoch,
// January 1, 1970 00:00:00 UTC.
func Nanoseconds() int64 {
	sec, nsec, err := os.Time()
	if err != nil {
		panic("time: os.Time: ", err.String())
	}
	return sec*1e9 + nsec
}
Ejemplo n.º 7
0
// Seconds reports the number of seconds since the Unix epoch,
// January 1, 1970 00:00:00 UTC.
func Seconds() int64 {
	sec, _, err := os.Time()
	if err != nil {
		panic("time: os.Time: ", err.String())
	}
	return sec
}
Ejemplo n.º 8
0
func newEntry(key string, value interface{}) *entry {
	var t time

	t.Sec, t.Nsec, _ = os.Time()

	return &entry{record{key, value}, t, false, nil}
}
Ejemplo n.º 9
0
func (world *World) lock() (err os.Error) {
	if world.lockfd != nil {
		panic("lock fd already exists... should never happen")
	}
	sessionLockPath := path.Join(world.dir, sessionlock)
	world.lockfd, err = os.Open(sessionLockPath, os.O_RDWR|os.O_ASYNC, 0000)
	if err != nil {
		error.NewError(fmt.Sprint("could not open ", sessionlock), nil)
	}
	// minecraft's locking mechanism is peculiar.
	// It writes the current system time in milliseconds since 1970 to the file.
	// It then watches the file for changes.  If a change is monitored, it aborts.

	// This has strange implications, such as the LAST process to open the world owns it,
	// not the first.

	// but hey, when in rome...
	sec, nsec, err := os.Time()
	if err != nil {
		err = error.NewError("couldn't get the current time..?!", err)
		return
	}

	world.lockmsec = (sec * 1000) + (nsec / 1000000)
	err = nbt.WriteInt64(world.lockfd, world.lockmsec)
	if err != nil {
		err = error.NewError("could not write timestamp to session lock", err)
		return
	}
	return
}
Ejemplo n.º 10
0
func (s *pollServer) Now() int64 {
	sec, nsec, err := os.Time()
	if err != nil {
		panic("net: os.Time: ", err.String())
	}
	nsec += sec * 1e9
	return nsec
}
Ejemplo n.º 11
0
func getTime() float64 {
	sec, nsec, err := os.Time()
	var time float64 = 0
	if err == nil {
		time = float64(sec) + (float64(nsec) * math.Pow10(-9))
	}
	return time
}
Ejemplo n.º 12
0
func expire(minutes int) (expires string) {
	secondsNow, _, _ := os.Time()
	addSeconds := minutes * 60
	secondsNew := int(secondsNow)
	expiresInt := secondsNew + addSeconds
	expires = strconv.Itoa(expiresInt)
	return
}
Ejemplo n.º 13
0
func TilePlane(maxtiles int, tileSymmetry string, showIntermediate bool) (<-chan *quadratic.Map, chan int) {
	finalTilings := make(chan *quadratic.Map, 10000)
	halt := make(chan int, 1)
	go tileDriver(TileMap("adehnrvuwtspjgbc", 0), finalTilings, halt, chooseNextEdgeByLocation, maxtiles, tileSymmetry, showIntermediate)
	initializationTime, _, _ = os.Time()
	fmt.Fprintf(os.Stderr, "intitialized at %v\n", initializationTime)
	return finalTilings, halt
}
Ejemplo n.º 14
0
// returns an equivalent but completlely independent copy of b
func (b *Board) Copy() *Board {
	sec, nsec, _ := os.Time()
	l := b.boardSize * b.boardSize
	cpy := &Board{
		fields:                make([]*Group, l),
		colorOfNextPlay:       b.colorOfNextPlay,
		boardSize:             b.boardSize,
		currentSequence:       b.currentSequence,
		actionOnNextBlackMove: make([]*actionFunc, l),
		actionOnNextWhiteMove: make([]*actionFunc, l),
		fieldSequencesBlack:   make([]uint32, l),
		fieldSequencesWhite:   make([]uint32, l),
		rand:                  rand.New(rand.NewSource(sec + nsec)),
		prisonersBlack:        b.prisonersBlack,
		prisonersWhite:        b.prisonersWhite,
	}
	if b.ko != nil {
		cpy.ko = &koLock{
			Pos:   b.ko.Pos,
			Color: b.ko.Color,
		}
	}
	copy(cpy.fieldSequencesBlack, b.fieldSequencesBlack)
	copy(cpy.fieldSequencesWhite, b.fieldSequencesWhite)

	// Copy .fields in a seperate loop first. The next loop, in which we set .actionOnNext{Black,White}Move
	// depends upon correcty and already completely set .fields. Remember to copy each group only once!
	copiedGroups := make(map[*Group]bool)
	for i := 0; i < l; i++ {
		grp := b.fields[i]
		_, present := copiedGroups[grp]
		if !present && grp != nil {
			gcpy := grp.Copy()
			last := gcpy.Fields.Last()
			for it := gcpy.Fields.First(); it != last; it = it.Next() {
				cpy.fields[it.Value()] = gcpy
			}
			// remember that we already copied grp
			copiedGroups[grp] = true
		}
	}

	for i := 0; i < l; i++ {
		// copy .actionOnNextBlackMove and adjust its context
		if f := b.actionOnNextBlackMove[i]; f != nil {
			cpy.actionOnNextBlackMove[i] = NewActionFunc(cpy, nil, f.f)
			_, cpy.actionOnNextBlackMove[i].context = cpy.getEnvironmentAndContext(i, Black)
		}
		// copy .actionOnNextWhiteMove and adjust its context
		if f := b.actionOnNextWhiteMove[i]; f != nil {
			cpy.actionOnNextWhiteMove[i] = NewActionFunc(cpy, nil, f.f)
			_, cpy.actionOnNextWhiteMove[i].context = cpy.getEnvironmentAndContext(i, White)
		}
	}

	return cpy
}
Ejemplo n.º 15
0
func (m *TksManager) ReadDiploCsvFilesIfNew() error {
	standardDiploFilename := "/home/dys/chrall/Public_Diplomatie.txt"
	trollDiploFilename := "/home/dys/chrall/Diplodotrolls.csv"
	mustRead := false
	if m.lastDiploFileRead > 0 {
		fi, err := os.Stat(standardDiploFilename)
		if err != nil {
			return err
		}
		if !fi.IsRegular() {
			return errors.New("TksManager : Fichier " + standardDiploFilename + " introuvable ou anormal")
		}
		mustRead = fi.Mtime_ns > m.lastDiploFileRead*1000000000
	}
	if !mustRead {
		fi, err := os.Stat(trollDiploFilename)
		if err != nil {
			return err
		}
		if !fi.IsRegular() {
			return errors.New("TksManager : Fichier " + trollDiploFilename + " introuvable ou anormal")
		}
		mustRead = fi.Mtime_ns > m.lastDiploFileRead*1000000000
		fmt.Printf("mustRead trollDiploFile = %v \n", mustRead)
	}
	if !mustRead {
		return nil
	}

	g := NewDiploGraph()
	f, err := os.Open(standardDiploFilename)
	if err != nil {
		return err
	}
	defer f.Close()
	r := bufio.NewReader(f)
	err = g.ReadDiploGraph(r, true, false)
	if err != nil {
		return err
	}

	f, err = os.Open(trollDiploFilename)
	if err != nil {
		return err
	}
	defer f.Close()
	r = bufio.NewReader(f)
	err = g.ReadDiploGraph(r, false, true)
	if err != nil {
		return err
	}

	m.lastDiploFileRead, _, _ = os.Time()
	fmt.Println("TksManager : Fichiers de diplo lus")
	m.Diplo = g
	return nil
}
func main() {
	ps := os.Getpagesize()
	fmt.Println("page size = ", ps)

	sec, nsec, _ := os.Time()
	fmt.Println("time from 1 January 1970 =", sec, " secs.", nsec)

	t := time.LocalTime()
	fmt.Println(t)
}
Ejemplo n.º 17
0
Archivo: main.go Proyecto: Melvar/gorun
func main() {

	err := os.MkdirAll(storedir, dirperms)
	if err != nil {
		log.Fatalln(err)
	}

	if len(os.Args) < 2 { //no filename
		log.Fatalln("No filename given")
	}
	scriptname := os.Args[1]
	scriptfile, err := os.Open(scriptname, os.O_RDONLY, 0)
	if err != nil {
		log.Fatalln(err)
	}
	defer scriptfile.Close()

	hash := hasht.New()
	io.Copy(hash, scriptfile)                //feed data to hash func
	hashstr := fmt.Sprintf("%x", hash.Sum()) //get hash as hex string

	table, err := readTable(dbfilename) //get our data ready
	if err != nil {
		log.Fatalln(err)
	}

	metadata, ok := table[hashstr] //look for record of scriptfile
	if !ok {
		err = compile(scriptfile, hashstr)
		if err != nil {
			log.Fatalln(err)
		}
	} else {
		if _, err = os.Stat(path.Join(storedir, hashstr)); err != nil {
			err = compile(scriptfile, hashstr)
			if err != nil {
				log.Fatalln(err)
			}
		}
	}
	metadata.Hash = hashstr
	metadata.Lastused, _, err = os.Time()
	if err != nil {
		log.Println(err)
		metadata.Lastused = latestTime
	}
	metadata.Filename = scriptname
	table[hashstr] = metadata
	if err := writeTable(table, dbfilename); err != nil {
		log.Println(err)
	}

	os.Exec(path.Join(storedir, hashstr), os.Args[1:], os.Environ())
}
Ejemplo n.º 18
0
func (m *TksManager) CheckDiploLoaded() {
	now, _, _ := os.Time()
	if now-m.lastDiploFileCheck > 100 {
		m.lastDiploFileCheck = now
		err := m.ReadDiploCsvFilesIfNew()
		if err != nil {
			fmt.Println("Unable to load diplo files :")
			fmt.Println(err)
		}
	}
}
Ejemplo n.º 19
0
func (m *TksManager) checkTrollInfosLoaded() {
	now, _, _ := os.Time()
	if now-m.lastTrollFileCheck > 300 {
		m.lastTrollFileCheck = now
		err := m.ReadTrollCsvFileIfNew()
		if err != nil {
			fmt.Println("Unable to load kill stats file :")
			fmt.Println(err)
		}
	}
}
Ejemplo n.º 20
0
func (m *TksManager) ReadGuildCsvFileIfNew() error {
	filename := "/home/dys/chrall/Public_Guildes.txt"
	if m.lastGuildFileRead > 0 {
		fi, err := os.Stat(filename)
		if err != nil {
			return err
		}
		if !fi.IsRegular() {
			return errors.New("TksManager : Fichier " + filename + " introuvable ou anormal")
		}
		if fi.Mtime_ns < m.lastGuildFileRead*1000000000 {
			return nil
		}
	}

	f, err := os.Open(filename)
	if err != nil {
		return err
	}
	defer f.Close()
	r := bufio.NewReader(f)
	line, err := r.ReadString('\n')
	for err == nil {
		tokens := strings.SplitN(line, ";", 4)
		if len(tokens) < 2 {
			fmt.Println("Ligne invalide")
		} else {
			gi := new(GuildInfos)
			id, _ := strconv.Atoi(tokens[0])
			gi.Nom = AsciiToUTF8([]uint8(tokens[1]))
			if id >= len(m.Guildes) {
				if id >= cap(m.Guildes) {
					newSlice := make([]*GuildInfos, ((id+1)*5/4)+100)
					copy(newSlice, m.Guildes)
					m.Guildes = newSlice
				}
				m.Guildes = m.Guildes[0 : id+1]
			}
			m.Guildes[id] = gi
		}
		line, err = r.ReadString('\n')
	}
	if err != io.EOF {
		fmt.Println("Erreur au parsage :")
		fmt.Println(err)
		return err
	}
	m.lastTrollFileRead, _, _ = os.Time()
	fmt.Println("TksManager : Fichier des guildes lu")
	return nil
}
Ejemplo n.º 21
0
func (h *JsonGetHandler) ServeHTTP(w http.ResponseWriter, hr *http.Request) {
	h.hit()
	startSeconds, startNanosecs, _ := os.Time()
	w.Header().Set("Access-Control-Allow-Origin", "*")
	w.Header().Set("Access-Control-Request-Method", "GET")

	fmt.Println("\n=== JsonGetHandler : Requete reçue ====================")
	fmt.Println(" URL : " + hr.RawURL)
	hr.ParseForm()

	actions := hr.Form["action"]
	var action string
	if len(actions) > 0 {
		action = actions[0]
	} else {
		action = ""
	}
	if action == "get_monster_names" {
		h.serveAutocompleteMonsterNames(w, hr)
	} else if action == "get_page_killometre" {
		h.servePageKillometre(w, hr)
	} else if action == "get_extract" {
		h.serveBestiaryExtractHtml(w, hr)
	} else if action == "get_troll_info" {
		h.serveTrollStatsHtmlJsonp(w, hr)
	} else if action == "get_extract_jsonp" {
		h.serveBestiaryExtractHtmlJsonp(w, hr)
	} else if action == "accept_cdm_jsonp" {
		h.serveAcceptCdmJsonp(w, hr)
	} else if action == "check_messages" {
		h.serveMessageJsonp(w, hr)
	} else {
		h.serveAuthenticatedMessage(w, action, GetFormValue(hr, "message")) // par défaut on considère qu'il s'agit d'un message authentifié
	}
	endSeconds, endNanosecs, _ := os.Time()
	durationMillis := 1e3*(endSeconds-startSeconds) + (endNanosecs-startNanosecs)/1e6
	fmt.Printf(" Duration : %d ms\n", durationMillis)
}
Ejemplo n.º 22
0
func TileSkeleton(skeleton, tileSymmetry string, showIntermediate bool) (<-chan *quadratic.Map, chan int) {
	finalTilings := make(chan *quadratic.Map, 10000)
	halt := make(chan int, 1)
	skel, ok := SkeletonMap(skeleton)
	//tileSymmetry = DetectSymmetryGroup(skel)
	fmt.Fprintf(os.Stderr, "tiling with SKELETON SYMMETRY GROUP: %v\n", tileSymmetry)
	if ok != nil {
		panic("Bad skeleton: " + ok.String() + "\n")
	}
	go tileDriver(skel, finalTilings, halt, chooseNextEdgeByLocation, 0, tileSymmetry, showIntermediate)
	initializationTime, _, _ = os.Time()
	fmt.Fprintf(os.Stderr, "intitialized at %v\n", initializationTime)
	return finalTilings, halt
}
Ejemplo n.º 23
0
Archivo: low.go Proyecto: newblue/sql
func (self *pqConnection) pqPrepare(query string, types ...interface{}) *pqStatement {
	res := new(pqStatement)
	// TODO: is the current system time goog enough?
	secs, _, _ := os.Time()
	res.stmtName = strconv.Itoa64(secs)

	nameC := C.CString(res.stmtName)
	queryC := C.CString(query)

	// TODO: error check here :| yikes
	_ = C.PQprepare(self.handle, nameC, queryC, 0, nil)

	C.free(unsafe.Pointer(nameC))
	C.free(unsafe.Pointer(queryC))
	return res
}
Ejemplo n.º 24
0
func main() {
	runtime.GOMAXPROCS(4)
	ts, _, _ := os.Time()
	fmt.Printf("TimeSec: %v\n", ts)
	rand.Seed(ts)
	fmt.Printf("\n\n")

	joinCh := make(chan bool)
	defer close(joinCh)

	var Uint uint64 = 100
	off := -1
	Uint += off
	//<-joinCh
	time.Sleep(2000)
	fmt.Printf("\n\n")
}
Ejemplo n.º 25
0
// Resets the board. The state is the same as after creating a new instance.
func (b *Board) Reset() {
	sec, nsec, _ := os.Time()
	b.rand = rand.New(rand.NewSource(sec + nsec))
	b.ko = nil
	b.colorOfNextPlay = Black
	b.currentSequence = 0
	b.prisonersWhite = 0
	b.prisonersBlack = 0
	for i := 0; i < b.boardSize*b.boardSize; i++ {
		b.fields[i] = nil
		b.actionOnNextBlackMove[i] = b.initialActionGenerator(i, Black)
		b.actionOnNextWhiteMove[i] = b.initialActionGenerator(i, White)
		b.fieldSequencesBlack[i] = 0
		b.fieldSequencesWhite[i] = 0
	}

}
Ejemplo n.º 26
0
func (m *TksManager) getGuildInfos(id int) *GuildInfos {
	if id <= 0 {
		return nil
	}
	now, _, _ := os.Time()
	if now-m.lastGuildFileCheck > 300 {
		m.lastGuildFileCheck = now
		err := m.ReadGuildCsvFileIfNew()
		if err != nil {
			fmt.Println("Unable to load guild file :")
			fmt.Println(err)
		}
	}
	if id < len(m.Guildes) {
		return m.Guildes[id]
	}
	return nil
}
Ejemplo n.º 27
0
func tileDriver(startTiling *quadratic.Map, sink chan<- *quadratic.Map, halt chan int, chooseNextEdge func(*quadratic.Map) *quadratic.Edge, maxtiles int, tileSymmetry string, showIntermediate bool) {
	alternativeStack := make(chan *list.List, 1)
	alternatives := new(list.List)
	alternatives.PushBack(startTiling)
	alternativeStack <- alternatives
	workerCount := make(chan int, 1)
	workerCount <- 0
	for {
		select {
		case workers := <-workerCount:
			alternatives = <-alternativeStack
			if alternatives.Len() == 0 {
				if workers == 0 {
					workerCount <- 0
					halt <- 1
					finishTime, _, _ := os.Time()
					fmt.Fprintf(os.Stderr, "we're done, took %v seconds\n", finishTime-initializationTime)
					close(sink)
					return
				}
				alternativeStack <- alternatives
				workerCount <- workers
				continue
			} else if workers < Workers {
				T := alternatives.Remove(alternatives.Front()).(*quadratic.Map)
				alternativeStack <- alternatives
				localMaps := make([]*quadratic.Map, len(TileMaps))
				for j, r := range TileMaps {
					localMaps[j] = r.Copy()
				}
				workerCount <- workers + 1
				go tileWorker(T, alternativeStack, sink, workerCount, halt, localMaps, chooseNextEdge, maxtiles, tileSymmetry, showIntermediate)
			} else {
				alternativeStack <- alternatives
				workerCount <- workers
			}
		case <-halt:
			halt <- 1
			fmt.Fprintf(os.Stderr, "premature halt\n")
			return
		}
	}
}
Ejemplo n.º 28
0
func BenchmarkRandomGameByListLegalPoints(b *testing.B) {
	b.StopTimer()
	board := NewBoard(boardsize)
	b.StartTimer()
	for i := 0; i < b.N; i++ {
		legalMoves := board.ListLegalPoints(board.ColorOfNextPlay())
		if len(legalMoves) == 0 {
			b.StopTimer()
			board.Reset()
			b.StartTimer()
		} else {
			sec, nsec, _ := os.Time()
			random := rand.New(rand.NewSource(sec + nsec))
			randomMove := legalMoves[random.Intn(len(legalMoves))]
			board.TurnPlayMove(randomMove.X, randomMove.Y)
		}
	}
	DbgHistogram.PrintSorted()
}
Ejemplo n.º 29
0
func tileWorker(T *quadratic.Map, alternativeStack chan *list.List, sink chan<- *quadratic.Map, workerCount chan int, halt chan int, tileMaps []*quadratic.Map, chooseNextEdge func(*quadratic.Map) *quadratic.Edge, maxtiles int, tileSymmetry string, showIntermediate bool) {
	localAlternatives := new(list.List)
Work:
	for {
		select {
		case <-halt:
			halt <- 1
			fmt.Fprintf(os.Stderr, "premature halt\n")
			return
		case L := <-alternativeStack:
			L.PushFrontList(localAlternatives)
			localAlternatives.Init()
			alternativeStack <- L
		default:
			if T.Faces.Len() > maxtiles && maxtiles > 0 {
				sink <- T
				break Work
			} else if noActiveFaces(T) {
				finishTime, _, _ := os.Time()
				fmt.Fprintf(os.Stderr, "new tiling complete, took %v seconds\n", finishTime-initializationTime)
				sink <- T
				break Work
			} else if showIntermediate {
				sink <- T
			}
			alternatives := addTilesByEdge(T, tileMaps, chooseNextEdge, tileSymmetry)
			if alternatives.Len() == 0 {
				break Work
			}
			T = alternatives.Remove(alternatives.Front()).(*quadratic.Map)
			localAlternatives.PushFrontList(alternatives)
			//fmt.Fprintf(os.Stderr,"currently have %v faces\n",T.Faces.Len())
		}
	}
	L := <-alternativeStack
	L.PushFrontList(localAlternatives)
	localAlternatives.Init()
	alternativeStack <- L

	workers := <-workerCount
	workerCount <- workers - 1
}
Ejemplo n.º 30
0
func (km *Killomètre) tagTrolls(trollsByTrollKills []*Troll) (nbTK int, nbATK int) {
	now, _, _ := os.Time()
	oneYearBefore := now - 365*24*60*60
	for _, troll := range trollsByTrollKills {
		troll.NbKillsTK = 0
		troll.NbKillsATK = 0
		troll.NbKilledByATK = 0
		troll.NbKillsTKRécents = 0
		troll.NbKillsRécents = 0
	}
	for _, kill := range km.Kills {
		if kill.TueurEstTroll {
			if kill.Seconds > oneYearBefore {
				km.Trolls[kill.Tueur].NbKillsRécents++
			}
			if kill.Tag == tk {
				km.Trolls[kill.Tueur].NbKillsTK++
				if kill.Seconds > oneYearBefore {
					km.Trolls[kill.Tueur].NbKillsTKRécents++
				}
			} else if kill.Tag == atk {
				km.Trolls[kill.Tueur].NbKillsATK++
				km.Trolls[kill.Tué].NbKilledByATK++
			}
		}
	}
	for _, troll := range trollsByTrollKills {
		if troll.NbKillsTK > 4 && ((troll.NbKillsTK*3 > troll.NbKillsATK+1) || (troll.NbKillsTK > 4 && troll.NbKillsTK*3 > troll.NbKillsTrolls)) {
			troll.Tag = tk
			nbTK++
		} else if troll.NbKillsATK > 3 && (troll.NbKillsATK*15 > 10*troll.NbKillsTrolls) {
			troll.Tag = atk
			nbATK++
		} else if troll.NbKilledByATK > 3 {
			troll.Tag = tk
			nbTK++
		}
		//fmt.Printf("Troll %d ktk=%d katk=%d kt=%d  ---> %s\n", troll.Id, troll.NbKillsTK, troll.NbKillsATK, troll.NbKillsTrolls, troll.Tag.string())
	}
	return nbTK, nbATK

}