text stringlengths 11 6.3k | embedding listlengths 768 768 |
|---|---|
func LoadPrivateKey(keystorePath string) (bccsp.Key, crypto.Signer, error) {
var err error
var priv bccsp.Key
var s crypto.Signer
opts := &factory.FactoryOpts{
ProviderName: "GMSW",
SwOpts: &factory.SwOpts{
HashFamily: "SM3",
SecLevel: 256,
FileKeystore: &factory.FileKeystoreOpts{
KeyStorePath:... | [
-0.20665964484214783,
-0.1703900545835495,
0.9656441807746887,
0.31779053807258606,
-0.8583389520645142,
-0.26472386717796326,
0.05510740727186203,
-0.3165053129196167,
0.29261064529418945,
0.8354331254959106,
-1.0668312311172485,
-0.005672364495694637,
-1.1813139915466309,
0.5884637236595... |
func GeneratePrivateKey(keystorePath string) (bccsp.Key,
crypto.Signer, error) {
var err error
var priv bccsp.Key
var s crypto.Signer
opts := &factory.FactoryOpts{
ProviderName: "GMSW",
SwOpts: &factory.SwOpts{
HashFamily: "SM3",
SecLevel: 256,
FileKeystore: &factory.FileKeystoreOpts{
KeyStor... | [
-0.20596222579479218,
0.01885497197508812,
0.8410080671310425,
0.48827728629112244,
-0.18295873701572418,
-0.12952272593975067,
-0.2567008137702942,
0.16017426550388336,
0.644382894039154,
0.6662593483924866,
-1.271437644958496,
0.22528259456157684,
-0.5681073665618896,
0.3799625337123871,... |
func (ce *CompilationError) Pprint(indent string) string {
var buf bytes.Buffer
fmt.Fprintf(&buf, "Compilation error: \033[31;1m%s\033[m\n", ce.Message)
buf.WriteString(ce.Context.PprintCompact(indent + " "))
return buf.String()
} | [
1.093178391456604,
-0.03100135549902916,
0.6446437239646912,
-0.9649277925491333,
-0.5923713445663452,
0.5652450919151306,
0.10452116280794144,
-0.8146504163742065,
-0.44819337129592896,
-0.58643639087677,
1.0754008293151855,
0.5887079834938049,
-1.0432484149932861,
-0.3348671495914459,
... |
func (a *Assembler) symbol(s string) (Word, error) {
if len(s) == 0 || 10 < len(s) {
return 0, ErrSymLen
}
for _, c := range s {
if !isDigit(c) && !isLetter(c) {
return 0, ErrSymSyntax
}
}
v, known := a.knownSyms[s]
if !known {
return v, ErrFutureRef
}
return v, nil
} | [
-1.0821529626846313,
0.4519077241420746,
0.25842541456222534,
-0.2569730281829834,
-0.06519687175750732,
-0.7652716636657715,
1.445446491241455,
0.37253955006599426,
0.8447538614273071,
0.2248157560825348,
-0.27653852105140686,
1.068922758102417,
0.5839418172836304,
0.5967671871185303,
0... |
func NewFinder(conf Config) *Finder {
return &Finder{config: conf }
} | [
0.0754685178399086,
-1.1240592002868652,
-0.0656769722700119,
0.5335811376571655,
-0.8964495658874512,
0.49596846103668213,
0.13964605331420898,
-0.4090692102909088,
-0.101542167365551,
0.1846940964460373,
-0.2696283757686615,
-0.33886024355888367,
0.4717057943344116,
1.169918417930603,
... |
func (f *Finder) NeedToExclude(file os.FileInfo) bool {
if file.Name() == "." {
return false
}
if file.IsDir() {
i := sort.SearchStrings(f.config.ExcludeFiles, file.Name())
return (len(f.config.ExcludeFiles) != i)
}
return false
} | [
-0.38342511653900146,
0.6647028923034668,
0.8685773611068726,
0.26261356472969055,
-1.1880419254302979,
0.9523905515670776,
0.5336188673973083,
-0.3810751438140869,
-0.4858872592449188,
0.47559595108032227,
-0.21201829612255096,
-0.654221773147583,
-1.044145107269287,
1.2138960361480713,
... |
func (f *Finder) IsValidName(path string) bool {
return strings.Contains(path, f.config.FilterFile)
} | [
-0.6661006808280945,
-0.02620238997042179,
0.4430612325668335,
0.3724654018878937,
-0.7575271129608154,
0.38800734281539917,
0.0743061825633049,
-0.5095427632331848,
0.46433165669441223,
0.3044128715991974,
-0.20493116974830627,
-0.25662168860435486,
-0.3702472150325775,
0.3421492874622345... |
func (f *Finder) FindFiles(searchDir string) []Element {
filepath.Walk(searchDir, func(path string, file os.FileInfo, _ error) error {
if f.NeedToExclude(file) {
return filepath.SkipDir
}
if !f.IsValidName(path) {
return nil
}
// if is a file valid add in list
f.list = append(f.list, *NewElement(pa... | [
-0.24655365943908691,
0.1422390341758728,
0.5756092667579651,
0.8276293277740479,
-0.2011481076478958,
0.7523735761642456,
0.0013048956170678139,
0.3611327111721039,
0.5163918733596802,
-0.09866227954626083,
0.0705690085887909,
-0.679104208946228,
-1.3306869268417358,
1.4221709966659546,
... |
func (f *Finder) searchByText(elem *Element, numLine int, line string) {
if f.config.Regex != nil {
return
}
if strings.Contains(line, f.config.Text) {
// Check if has the text in line
elem.WriteComment(numLine, f.config.Text, line) // write comment
}
} | [
0.7922397255897522,
0.008630112744867802,
0.5273173451423645,
0.37027010321617126,
0.5702371597290039,
-0.07288986444473267,
0.2147168219089508,
-0.14061486721038818,
-0.5818819999694824,
0.3909561336040497,
-0.5729938745498657,
-0.6315650939941406,
-0.5946443676948547,
0.13758452236652374... |
func (f *Finder) searchByRegex(elem *Element, numLine int, line string) {
if f.config.Regex == nil {
return
}
words := f.config.Regex.FindAllString(line, -1)
if len(words) > 0 {
for _, v := range words {
elem.WriteComment(numLine, v, line)
}
}
} | [
0.2719343304634094,
0.07310644537210464,
0.7043432593345642,
0.3446274399757385,
1.483487606048584,
-0.6722448468208313,
0.5272222757339478,
0.16041725873947144,
-0.7362033128738403,
-0.04376307874917984,
-0.04440753161907196,
-0.10547097027301788,
-0.5334848761558533,
0.4224388897418976,
... |
func (f *Finder) readAndFind(e *Element) {
e.Enabled = false
file, err := os.Open(e.Path)
if err != nil {
e.Error = err
return
}
defer file.Close()
if f.config.CaseInsensitive {
f.config.Text = strings.ToLower(f.config.Text)
}
numLine := 0
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line... | [
0.10703233629465103,
-0.9847211241722107,
0.8159955739974976,
-0.05494198575615883,
-0.30319809913635254,
0.9195411801338196,
0.5323017835617065,
0.6658297181129456,
-0.44347715377807617,
0.047672927379608154,
0.9308030605316162,
-0.2773969769477844,
0.2680226266384125,
1.2063689231872559,... |
func (f *Finder) FindText(text string) []Element {
if len(f.config.Text) == 0 && f.config.Regex == nil {
return f.list
}
f.config.Text = text
for i, element := range f.list {
f.readAndFind(&element)
f.list[i] = element
}
return f.list
} | [
-1.0137841701507568,
0.043971702456474304,
0.4953452944755554,
0.6311075687408447,
0.07513673603534698,
-0.06141876429319382,
-0.22102926671504974,
0.04811857268214226,
0.9236277341842651,
0.6105297207832336,
-0.6589732766151428,
-0.8521218299865723,
-1.1439452171325684,
1.0002388954162598... |
func ReadMsgAPI(ServerVars *Variables, c string, k string, w *http.ResponseWriter, t time.Time) {
ServerVars.ChannelListMu.Lock()
defer ServerVars.ChannelListMu.Unlock()
_, exists := ServerVars.ChannelList[c] //Checking if the channel exists or not
if !exists {
_, err := (*w).Write([]byte(fmt.Sprintf("No channel... | [
-0.6212292909622192,
-0.051778022199869156,
1.1010754108428955,
-0.4316983222961426,
0.43507251143455505,
-0.02346269227564335,
0.26448169350624084,
-0.27008309960365295,
-0.9975181818008423,
0.9873480796813965,
0.838381290435791,
1.0302172899246216,
-0.6016767024993896,
0.95548415184021,
... |
func Info(c *common.Context, message string) {
log.WithFields(log.Fields{
"eventID": c.EventID,
"correlationID": c.CorrelationID,
"name": c.Name,
"timestamp": time.Now(),
}).Info(message)
} | [
1.2598762512207031,
-0.26628607511520386,
0.7070173621177673,
-0.7444007396697998,
0.08484358340501785,
0.151454359292984,
0.3476446568965912,
-0.17437121272087097,
-1.2955875396728516,
0.3601110279560089,
0.07363614439964294,
0.28322508931159973,
0.3012987971305847,
0.5035518407821655,
... |
func InfoWithFields(c *common.Context, message string, fields map[string]interface{}) {
log.WithFields(log.Fields{
"eventID": c.EventID,
"correlationID": c.CorrelationID,
"name": c.Name,
"timestamp": time.Now(),
}).WithFields(fields).Info(message)
} | [
1.21248459815979,
-0.11888458579778671,
0.702968955039978,
-0.7872822880744934,
-0.23789450526237488,
0.12002427130937576,
-0.2758540213108063,
-0.6027968525886536,
-1.2965528964996338,
0.043840739876031876,
-0.4209389388561249,
-0.16724181175231934,
0.38312140107154846,
0.0832547917962074... |
func Debug(c *common.Context, message string) {
log.WithFields(log.Fields{
"eventID": c.EventID,
"correlationID": c.CorrelationID,
"name": c.Name,
"timestamp": time.Now(),
}).Debug(message)
} | [
1.0846861600875854,
-0.10915001481771469,
0.6203418970108032,
-0.952968180179596,
0.5325338244438171,
0.5734643936157227,
0.15001849830150604,
-0.021686628460884094,
-0.4200197458267212,
0.008902673609554768,
0.13824301958084106,
0.3102554976940155,
-0.20432527363300323,
0.3222520053386688... |
func DebugWithFields(c *common.Context, message string, fields map[string]interface{}) {
log.WithFields(log.Fields{
"eventID": c.EventID,
"correlationID": c.CorrelationID,
"name": c.Name,
"timestamp": time.Now(),
}).WithFields(fields).Debug(message)
} | [
1.0247853994369507,
0.24910135567188263,
0.5183950066566467,
-0.931995153427124,
-0.0038304899353533983,
0.2283560186624527,
-0.6184961795806885,
-0.6987579464912415,
-0.5827534794807434,
-0.28270527720451355,
-0.4341448247432709,
-0.37134039402008057,
-0.14254774153232574,
0.3875930309295... |
func RunBuildSteps(cfg conf.Conf) {
previousCWD, err := os.Getwd()
util.Check(err)
os.Chdir(cfg.WorkingDirectory)
for _, step := range cfg.Steps {
log.Println("About to run command: ", step)
args := strings.Split(step, " ")
if len(args) == 0 {
continue
}
cmd := exec.Command(args[0], args[1:]...)
out... | [
-0.1859433352947235,
-0.6996926665306091,
0.7386035919189453,
0.9321287274360657,
0.4156996011734009,
0.6390892267227173,
1.0996712446212769,
-0.2732221782207489,
-0.6741785407066345,
-0.8465269804000854,
-0.2197204828262329,
0.31397688388824463,
-0.17223452031612396,
1.3471232652664185,
... |
func GetLastHead() string {
contents, err := ioutil.ReadFile(conf.LastHeadMarker)
if err != nil {
return ""
}
lines := strings.Split(string(contents), "\n")
if len(lines) == 0 {
return ""
}
return lines[0]
} | [
0.4990260601043701,
-0.9207558035850525,
1.0329183340072632,
-0.09420384466648102,
0.40568938851356506,
0.21356821060180664,
0.1441737860441208,
-0.3633817732334137,
0.299349844455719,
0.2731160521507263,
1.2629727125167847,
-0.1482584923505783,
-0.8806701898574829,
-0.5466632843017578,
... |
func SaveLastHead(hash string) {
f, err := os.OpenFile(conf.LastHeadMarker, os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
log.Fatal("Could not save last status!")
}
f.WriteString(hash)
f.Close()
} | [
0.6124202013015747,
-0.9890257716178894,
0.5809260606765747,
-0.847805380821228,
1.029247522354126,
0.7643223404884338,
0.30298715829849243,
-0.01192913856357336,
0.3968988358974457,
0.04598691314458847,
-0.8765033483505249,
-0.5493921041488647,
-0.7314895987510681,
0.31215807795524597,
... |
func (p *PipelineProvisioner) Init(opts ...grpc.DialOption) error {
return nil
} | [
-0.17438718676567078,
0.1581622213125229,
0.4626505970954895,
-0.01491750031709671,
-0.3974027931690216,
0.6750892996788025,
-0.6090061664581299,
0.7623101472854614,
-0.17164915800094604,
-0.1099717989563942,
0.4480077028274536,
-0.08482621610164642,
-1.0921419858932495,
0.0569739490747451... |
func (p *PipelineProvisioner) Provision(d *device.Device, cfg *admin.DeviceRoleConfig) error {
attrs := d.GetAttributes()
ctl := cfg.GetPipeline()
cfgString := fmt.Sprintf(template, d.GetID(), d.GetAddress(), ctl.GetDriver(), ctl.GetPipeconf(), attrs["x"], attrs["y"])
url := fmt.Sprintf("http://%s/onos/v1/network/c... | [
-0.7096266150474548,
0.3475598692893982,
0.5237510800361633,
-0.8860786557197571,
-0.8744364380836487,
-0.3379758596420288,
-0.5946722030639648,
-0.14659257233142853,
-0.08392922580242157,
0.7463536858558655,
0.05293601378798485,
0.06393761187791824,
0.037114277482032776,
0.742017924785614... |
func (s *Session) QueryUser(ID int, args ...string) (user *User, err error) {
var userID string
if ID != 0 {
userID = strconv.Itoa(ID)
}
var selections string
for _, arg := range args {
selections += arg + ","
}
selections = strings.TrimSuffix(selections, ",")
data, err := s.callAPI(apiUser+endpoint(userI... | [
-1.1263068914413452,
-0.2234131395816803,
0.3906952142715454,
0.2291024625301361,
0.27454227209091187,
-0.34553030133247375,
-0.40106090903282166,
-0.9946206212043762,
-0.13861888647079468,
-0.5305564403533936,
-0.3213786780834198,
0.022788148373365402,
-0.4463716447353363,
-0.328028857707... |
func IsSpan(name string) bool {
return strings.Contains(name, ".span-")
} | [
-0.0227022934705019,
0.38470450043678284,
0.4230141043663025,
1.0711029767990112,
-0.7583308815956116,
0.4753594994544983,
0.4559252858161926,
0.051241979002952576,
1.1537623405456543,
-0.16222882270812988,
-0.6120145320892334,
0.07719139754772186,
0.4389355778694153,
0.5788170695304871,
... |
func mulInt64WithOverflow(a, b int64) (c int64, ok bool) {
const mostPositive = 1<<63 - 1
const mostNegative = -(mostPositive + 1)
c = a * b
if a == 0 || b == 0 || a == 1 || b == 1 {
return c, true
}
if a == mostNegative || b == mostNegative {
return c, false
}
return c, c/b == a
} | [
-0.5012703537940979,
-0.5382736325263977,
0.6313605308532715,
0.8279696702957153,
-0.6449233293533325,
0.4948630630970001,
-0.5856955647468567,
-0.8837130069732666,
0.788887083530426,
-0.23769129812717438,
0.44307655096054077,
-0.25927576422691345,
-0.595582127571106,
-0.21928922832012177,... |
func NewIntArray(ints []int32) (*Obj) {
return &Obj{nil, ints, nil}
} | [
-0.5648425817489624,
-1.3100377321243286,
0.4623510539531708,
-0.20681588351726532,
-0.5886886715888977,
-0.1108156368136406,
0.01110696978867054,
-0.9755190014839172,
0.6367200613021851,
0.16612082719802856,
-1.2559199333190918,
0.32100409269332886,
-1.004998803138733,
0.48362046480178833... |
func NewBootstrapMethod(code []byte, classLoader Any) (*Method) {
method := &Method{}
method.class = &Class{name:"~jvmgo", classLoader:classLoader.(*ClassLoader)}
method.name = "<bootstrap>"
method.accessFlags = ACC_STATIC
method.maxStack = 8
method.maxLocals = 8
method.code = code
retur... | [
-0.6137984991073608,
-0.06730256229639053,
0.5696260929107666,
0.5137019157409668,
-0.7529497146606445,
-1.375864028930664,
0.14364337921142578,
-0.4423907399177551,
-0.126193568110466,
1.0096200704574585,
-0.5525540709495544,
-0.06742414832115173,
0.7916929125785828,
1.0369336605072021,
... |
func WithLimitReachedHandler(handler LimitReachedHandler) Option {
return option(func(middleware *Middleware) {
middleware.OnLimitReached = handler
})
} | [
0.3982580602169037,
-0.6685610413551331,
0.34940728545188904,
0.2911825180053711,
-1.1539794206619263,
1.0278390645980835,
0.0008157306583598256,
-0.15866927802562714,
0.42622631788253784,
-0.24900756776332855,
-0.8071277141571045,
-0.6720495820045471,
0.30997902154922485,
0.15178723633289... |
func DefaultLimitReachedHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Limit exceeded", http.StatusTooManyRequests)
} | [
-0.012164856307208538,
-0.19429683685302734,
0.251711905002594,
-0.122129887342453,
-0.2656790316104889,
0.7324818968772888,
-0.7092572450637817,
0.008478201925754547,
-0.16802792251110077,
0.2704055905342102,
-0.27361732721328735,
-0.5210879445075989,
-0.1426863968372345,
-0.4077636599540... |
func WithExcludedKey(handler func(string) bool) Option {
return option(func(middleware *Middleware) {
middleware.ExcludedKey = handler
})
} | [
0.13021348416805267,
0.3677341639995575,
0.16304580867290497,
0.29071229696273804,
-1.6795467138290405,
0.621949315071106,
-0.1131427064538002,
0.23282864689826965,
0.6470757722854614,
0.1947292685508728,
-0.2677026093006134,
-0.06634752452373505,
-0.621059000492096,
1.3209428787231445,
... |
func WithKeyGetter(handler KeyGetter) Option {
return option(func(middleware *Middleware) {
middleware.KeyGetter = handler
})
} | [
-0.1010424941778183,
-0.33430129289627075,
0.44270792603492737,
0.4868015944957733,
-1.3987547159194946,
0.17138348519802094,
-0.8983108401298523,
-0.13753291964530945,
0.27597755193710327,
-0.20098276436328888,
-0.5414628386497498,
-0.7161310315132141,
0.3672642111778259,
1.31894147396087... |
func (o *KeyOptions) GetIPKey(r *http.Request) string {
return GetIPWithMask(r, o).String()
} | [
-1.4023250341415405,
0.07815706729888916,
0.37944820523262024,
0.4962981045246124,
0.351185142993927,
-0.2948235869407654,
-0.08999866247177124,
-1.4027810096740723,
-0.28159740567207336,
1.199699878692627,
0.6039674282073975,
-0.5614756345748901,
0.286177396774292,
-0.2791348993778229,
... |
func GetIP(r *http.Request, options ...*KeyOptions) net.IP {
if len(options) >= 1 && options[0].TrustForwardHeader {
ip := r.Header.Get("X-Forwarded-For")
if ip != "" {
parts := strings.SplitN(ip, ",", 2)
part := strings.TrimSpace(parts[0])
return net.ParseIP(part)
}
ip = strings.TrimSpace(r.Header.G... | [
-0.2874528765678406,
0.2597928047180176,
0.7998710870742798,
0.3057222366333008,
-0.6957552433013916,
-0.014105085283517838,
-0.11987486481666565,
0.21298295259475708,
-0.4914471507072449,
0.29810136556625366,
0.6557742953300476,
-0.6221346855163574,
-0.10230952501296997,
-1.15029788017272... |
func GetIPWithMask(r *http.Request, options ...*KeyOptions) net.IP {
if len(options) == 0 {
return GetIP(r)
}
ip := GetIP(r, options[0])
if ip.To4() != nil {
return ip.Mask(options[0].IPv4Mask)
}
if ip.To16() != nil {
return ip.Mask(options[0].IPv6Mask)
}
return ip
} | [
-0.7606306076049805,
0.184860497713089,
0.6474265456199646,
1.629082441329956,
0.07258670777082443,
-1.0769424438476562,
-0.18592698872089386,
-1.2345815896987915,
0.43722230195999146,
0.08398208022117615,
0.5196214318275452,
-0.9375820755958557,
0.35753393173217773,
-0.8243034482002258,
... |
func (r *attributeRange) randomFloat() float64 {
return rand.Float64()*r.Max + r.Min
} | [
0.024250252172350883,
0.07259448617696762,
0.31514766812324524,
-0.3744247555732727,
-0.009778106585144997,
0.023001408204436302,
0.21064753830432892,
0.23509101569652557,
0.04316909983754158,
-1.4257620573043823,
-0.027096932753920555,
0.17906668782234192,
-0.3961336016654968,
0.589706420... |
func (r *attributeRange) randomInt() int {
return int(rand.Float64()*r.Max + r.Min)
} | [
-0.3685305118560791,
-0.19794374704360962,
0.24674513936042786,
-0.687326192855835,
-0.5833674669265747,
0.7990685105323792,
-0.27093803882598877,
-0.5860839486122131,
-0.6892731785774231,
-0.4259257912635803,
0.263754665851593,
-0.08897628635168076,
-0.35965394973754883,
-0.20933531224727... |
func randomGender() string {
rand.Seed(time.Now().UnixNano())
coinFlip := rand.Intn(2)
if coinFlip > 0 {
return "female"
}
return "male"
} | [
-1.4407228231430054,
0.23590314388275146,
0.6179145574569702,
-0.2755170464515686,
-0.8231001496315002,
0.9414534568786621,
-0.051511000841856,
0.045341815799474716,
-0.5673554539680481,
-0.4915580749511719,
-0.6276748180389404,
0.3472785949707031,
-0.23801541328430176,
1.4412660598754883,... |
func (w *RandomWorld) PlantsToJSON(fileName string) {
fi, _ := os.Create(fileName)
defer fi.Close()
fz := NewWriter(fi)
e := NewEncoder(fz)
if err := e.Encode(w.FoodList); err != nil {
panic(err)
}
} | [
-1.0833333730697632,
-1.171708345413208,
0.6525105237960815,
0.06284445524215698,
0.07804471254348755,
-0.01939184032380581,
0.6489393711090088,
0.2898039221763611,
-0.2676778733730316,
0.7316581606864929,
-1.4877017736434937,
0.5532740950584412,
0.2657472789287567,
0.035961322486400604,
... |
func (w *RandomWorld) BeingsToJSON(fileName string) {
fi, _ := os.Create(fileName)
defer fi.Close()
fz := NewWriter(fi)
e := NewEncoder(fz)
if err := e.Encode(w.BeingList); err != nil {
panic(err)
}
} | [
-1.744783639907837,
-1.0631201267242432,
0.5593864321708679,
-0.6079356670379639,
-0.02340221032500267,
0.36711639165878296,
0.2385549694299698,
0.05571119114756584,
-0.540984034538269,
0.8026415705680847,
-0.7654001712799072,
0.9413478374481201,
0.06509092450141907,
0.7835886478424072,
... |
func (w *RandomWorld) IsOutOfBounds(location GoWorld.Location) bool {
if location.X < 0 || location.X >= w.Width || location.Y < 0 || location.Y >= w.Height {
return true
}
return false
} | [
-0.7264553904533386,
-0.7361263036727905,
0.6759613752365112,
-0.35604992508888245,
-0.34496966004371643,
0.6241875886917114,
0.6327657699584961,
-1.1222914457321167,
0.6985369324684143,
0.46929484605789185,
-0.22168844938278198,
-0.17974480986595154,
-0.7543569207191467,
0.827617049217224... |
func ParseHexColorFast(s string) (c color.RGBA, err error) {
c.A = 0xff
if s[0] != '#' {
return c, errInvalidFormat
}
hexToByte := func(b byte) byte {
switch {
case b >= '0' && b <= '9':
return b - '0'
case b >= 'a' && b <= 'f':
return b - 'a' + 10
case b >= 'A' && b <= 'F':
return b - 'A' + 10
... | [
0.7801075577735901,
-0.5943590998649597,
0.804031491279602,
-0.4081062078475952,
-0.14812403917312622,
-0.9913501143455505,
-0.014843042008578777,
0.3318118751049042,
-0.16269975900650024,
-0.9019050598144531,
-0.006187191233038902,
-0.3426646590232849,
0.19639632105827332,
0.8739158511161... |
func (w *RandomWorld) CalculateZoneLimits(hist []int, ratios ...float64) []uint8 {
// Check if ratios add up to ~1 (otherwise parts of the terrain / zones will be left untouched)
var binSum float64
for _, r := range ratios {
binSum += r
}
// Check if larger than 1.00..001 (added a delta of 1e-14 because of preci... | [
-0.10930299013853073,
0.11969765275716782,
0.7245576977729797,
0.626542329788208,
-0.815955638885498,
0.028858378529548645,
1.4871922731399536,
-0.9513189196586609,
0.15661045908927917,
0.726311445236206,
0.25897425413131714,
-0.18135440349578857,
-0.4198320508003235,
0.8235456943511963,
... |
func (w *RandomWorld) CreateCarnivores(quantity int) {
// Initialize each being to a random one
for i := 0; i < quantity; i++ {
// Create random being and place it into the map
b := w.CreateRandomCarnivore()
w.BeingList[b.ID.String()] = b
}
} | [
-1.3013628721237183,
-0.8131923079490662,
0.34313082695007324,
-0.20113033056259155,
1.0841460227966309,
0.3350479304790497,
-0.8211503028869629,
-0.48844796419143677,
-0.2592417895793915,
-0.17975634336471558,
-0.9835817217826843,
0.21669353544712067,
-0.8288624286651611,
0.68140822649002... |
func (w *RandomWorld) CreateFishies(quantity int) {
// Initialize each being to a random one
for i := 0; i < quantity; i++ {
// Create random being and place it into the map
b := w.CreateRandomFish()
w.BeingList[b.ID.String()] = b
}
} | [
-1.637643575668335,
0.091968834400177,
0.6194772720336914,
-0.6472184062004089,
0.719275176525116,
0.3745841681957245,
0.7005773782730103,
-0.5565993189811707,
0.7312392592430115,
0.006060693878680468,
-1.0820679664611816,
0.383689284324646,
-0.7538200616836548,
1.2894809246063232,
-1.85... |
func (w *RandomWorld) CreateFlyers(quantity int) {
// Initialize each being to a random one
for i := 0; i < quantity; i++ {
// Create random being and place it into the map
b := w.CreateRandomFlyer()
w.BeingList[b.ID.String()] = b
}
} | [
-1.4824169874191284,
-0.07924205809831619,
0.3987794518470764,
-0.28173428773880005,
0.5646098852157593,
0.8223173022270203,
-0.05144582316279411,
-0.7821805477142334,
0.3081563413143158,
-0.32898232340812683,
-0.6825944185256958,
-0.28836649656295776,
-1.1750634908676147,
1.67994868755340... |
func (w *RandomWorld) CreateRandomCarnivore() *GoWorld.Being {
// Create an empty being
being := &GoWorld.Being{ID: uuid.New()}
being.Type = "Carnivore"
// Give the being the basic necessities
being.Hunger = hungerRange.randomFloat()
being.Thirst = thirstRange.randomFloat()
being.WantsChild = wantsChildRange.ra... | [
-0.2991310656070709,
-0.8571608066558838,
0.4686836004257202,
-0.41557809710502625,
-0.17306271195411682,
0.16510601341724396,
-0.9128742814064026,
-0.7540110945701599,
-0.29349544644355774,
-0.46455591917037964,
-0.5593180060386658,
0.16562749445438385,
-0.49169859290122986,
0.26541522145... |
func (w *RandomWorld) CreateRandomFlyer() *GoWorld.Being {
// Create an empty being
being := &GoWorld.Being{ID: uuid.New()}
being.Type = "Flying"
// Give the being the basic necessities
being.Hunger = hungerRange.randomFloat()
being.Thirst = thirstRange.randomFloat()
being.WantsChild = wantsChildRange.randomFlo... | [
-0.3952766954898834,
-0.3154057264328003,
0.7019625306129456,
-0.3512214720249176,
-0.42987942695617676,
0.8490267395973206,
-0.12474241107702255,
-0.95180743932724,
0.3078745901584625,
-0.05754008889198303,
0.15182234346866608,
-0.4061848223209381,
-0.5327958464622498,
0.9707489013671875,... |
func (w *RandomWorld) CreateRandomFish() *GoWorld.Being {
// Create an empty being
being := &GoWorld.Being{ID: uuid.New()}
being.Type = "Water"
// Give the being the basic necessities
being.Hunger = hungerRange.randomFloat()
being.Thirst = thirstRange.randomFloat()
being.WantsChild = wantsChildRange.randomFloat... | [
-0.3846861720085144,
-0.2933422327041626,
0.6648361682891846,
-0.8091766238212585,
-0.17312569916248322,
0.8324769139289856,
0.5249390006065369,
-0.8877812027931213,
0.6135792136192322,
-0.18006320297718048,
0.19139593839645386,
0.402940958738327,
-0.29683107137680054,
0.8362844586372375,
... |
func (w *RandomWorld) ThrowBeing(b *GoWorld.Being) {
// Check if the terrain to place the being exists
if w.TerrainSpots == nil {
panic(fmt.Errorf("error while creating being: no terrain to place being on"))
}
// Create some random coordinates within the world limits
randomSpot := GoWorld.Location{}
randomSpot... | [
0.0796319842338562,
-0.12780873477458954,
0.6930594444274902,
-0.7706647515296936,
0.12809239327907562,
1.2894878387451172,
0.2678984999656677,
-0.20312874019145966,
0.21240806579589844,
0.5085201263427734,
0.01722695492208004,
0.1577392816543579,
-0.5099344849586487,
1.2358169555664062,
... |
func (w *RandomWorld) ThrowPlant(p *GoWorld.Food) {
// Check if the terrain to place the plant exists
if w.TerrainSpots == nil {
panic(fmt.Errorf("error while throwing plant: no terrain"))
}
// Create some random coordinates within the world limits
rX := rand.Intn(w.Width)
rY := rand.Intn(w.Height)
for !w.ca... | [
0.7267494797706604,
0.37478214502334595,
0.49914175271987915,
-1.1793665885925293,
-1.008739709854126,
1.2221704721450806,
0.5874441862106323,
-0.3104817569255829,
0.6659778356552124,
0.5622354745864868,
-0.06324830651283264,
-0.15402935445308685,
-0.513377845287323,
0.4980889856815338,
... |
func (w *RandomWorld) LaunchPlant(p *GoWorld.Food) {
// Check if the terrain to place the being exists
if w.TerrainSpots == nil {
panic(fmt.Errorf("error while launching water plant: no terrain"))
}
// Create some random coordinates within the world limits
rX := rand.Intn(w.Width)
rY := rand.Intn(w.Height)
fo... | [
0.24422003328800201,
-0.015987081453204155,
0.4396779537200928,
-1.031620740890503,
-1.1878235340118408,
1.0383925437927246,
0.360944539308548,
0.025043677538633347,
1.2383509874343872,
0.1044289693236351,
0.17476342618465424,
0.45451417565345764,
-0.5315920114517212,
0.4209771454334259,
... |
func (w *RandomWorld) UpdateBeing(b *GoWorld.Being) (string, []uuid.UUID) {
// Check if it is time for the being to die
if b.LifeExpectancy <= 0 || b.Thirst >= 255 || b.Hunger >= 255 {
// Being has reached EOL
fmt.Printf("Being (%v) %v ", b.Type, b.ID)
if b.LifeExpectancy <= 0 {
fmt.Println("... died of old ... | [
-1.215215802192688,
-1.0653332471847534,
0.8345348238945007,
-0.04452085122466087,
0.04645406827330589,
0.11184069514274597,
-0.17244431376457214,
-0.1824406087398529,
-0.15032067894935608,
1.385120153427124,
0.12379708886146545,
0.23053963482379913,
-0.3709293007850647,
0.9162320494651794... |
func (w *RandomWorld) Wander(b *GoWorld.Being) error {
dX := math.Sqrt(b.Speed) * (rand.NormFloat64() * 5)
dY := math.Sqrt(b.Speed) * (rand.NormFloat64() * 5)
wanderSpot := GoWorld.Location{}
wanderSpot.X = b.Position.X + int(dX)
wanderSpot.Y = b.Position.Y + int(dY)
if wanderSpot.X < 0 {
wanderSpot.X = 0
} e... | [
-1.2568275928497314,
-0.3808618485927582,
0.8712873458862305,
-0.6376046538352966,
0.17040616273880005,
0.26147645711898804,
1.0249608755111694,
-0.2895289957523346,
0.32041236758232117,
0.4539150893688202,
0.07020256668329239,
0.17167863249778748,
-0.47923922538757324,
0.2373531609773636,... |
func (w *RandomWorld) canPlaceBeing(spot GoWorld.Location, beingType string) bool {
// Is there perhaps another being present?
if w.TerrainSpots[spot.X][spot.Y].Being == uuid.Nil {
// Can being move anywhere (Flying)
if beingType == "Flying" {
return true
} else if beingType == "Water" {
// Water beings c... | [
-0.30468499660491943,
-0.6529564261436462,
0.6255332231521606,
-0.5150909423828125,
0.10583572834730148,
0.575980007648468,
-0.29713404178619385,
0.23394925892353058,
-0.5646893382072449,
1.1758424043655396,
0.9356954097747803,
0.020181020721793175,
-0.29252198338508606,
0.8960789442062378... |
func (w *RandomWorld) UpdatePlant(p *GoWorld.Food) (string, []uuid.UUID) {
// Simulation runs at around 60FPS, so wither 15x per second
p.Wither -= 1. / 4
if p.Wither <= 0 {
// Kill the plant :(
delete(w.FoodList, p.ID.String())
w.updatePlantSpot(p.Position.X, p.Position.Y, p.Area, uuid.Nil)
return "withered... | [
-0.6823084354400635,
-0.38042739033699036,
0.7230820059776306,
-0.3779895305633545,
-0.8740764856338501,
0.310354620218277,
0.8856996297836304,
-0.18539106845855713,
0.4484863579273224,
0.8314633369445801,
0.17174971103668213,
-0.629005491733551,
-0.5475528836250305,
-0.0604897178709507,
... |
func (w *RandomWorld) DisperseSeeds(p *GoWorld.Food, seeds int) []uuid.UUID {
var producedIDs []uuid.UUID
spots := w.MidpointCircleAt(p.Position, p.Area+p.SeedDisperse)
for i := 0; i < seeds; i++ {
// Create mutated plant, but only the required attributes to check if we can place this plant
seedling := &GoWorld.... | [
-0.08671290427446365,
0.013981655240058899,
0.6768092513084412,
-0.36137938499450684,
-0.386173814535141,
0.48741987347602844,
0.9806749224662781,
0.13911689817905426,
0.36722174286842346,
0.6603356599807739,
1.3085373640060425,
-0.32067590951919556,
-0.3425963222980499,
0.8226528167724609... |
func (w *RandomWorld) updatePlantSpot(x, y int, plantDiameter float64, id uuid.UUID) {
// Set the center of the plant
w.TerrainSpots[x][y].Object = id
// Get the circular spots
circleSpots := w.MidpointCircleAt(GoWorld.Location{X: x, Y: y}, plantDiameter/2)
// Update the occupying ID of those spots
for _, spot ... | [
-0.18466071784496307,
-1.2424051761627197,
0.34745433926582336,
-1.2577857971191406,
-0.8558089137077332,
0.013342875055968761,
0.1854119598865509,
-0.25927600264549255,
0.16417376697063446,
1.5592197179794312,
0.5730441808700562,
-0.06242600455880165,
0.10138396918773651,
-1.4352893829345... |
func MutateValue(parentAttribute, mutationRate float64, valueRange attributeRange) float64 {
modifier := rand.NormFloat64() * mutationRate
parentAttribute += modifier
// Check if produced value still in specified range
if parentAttribute < valueRange.Min {
parentAttribute = valueRange.Min
} else if parentAttribu... | [
-0.22301505506038666,
-0.1390034705400467,
0.5201091170310974,
-0.012641928158700466,
-0.6051520705223083,
0.052517328411340714,
0.12534010410308838,
-0.5466734170913696,
0.17354659736156464,
-0.11989422142505646,
1.191469669342041,
0.574368953704834,
0.28852787613868713,
0.059032134711742... |
func MutateValues(value1, value2, mutationRate float64, valueRange attributeRange) float64 {
// Find out which values are lower bound and which is higher
low, high := value1, value2
if value1 > value2 {
low, high = value2, value1
}
// Calculate mutation multiplier
multiplier := rand.NormFloat64() * mutationRate... | [
0.018711669370532036,
-0.5243104696273804,
0.6557573676109314,
0.3571722209453583,
-0.3633517920970917,
0.1301162987947464,
-0.9464742541313171,
-0.4047815501689911,
0.03341056779026985,
-0.1485132873058319,
0.5496603846549988,
0.6183823943138123,
-0.2173132449388504,
0.07327986508607864,
... |
func (w *RandomWorld) MidpointCircleAt(center GoWorld.Location, radius float64) []GoWorld.Location {
// The final spots
var circleSpots []GoWorld.Location
// Round the radius to closest int and initialize x with it
x := int(math.Round(radius))
y := 0
// The midpoint circle algorithm calculates the arc values fo... | [
-0.1840435415506363,
-0.4075404107570648,
0.898752748966217,
-0.8348448872566223,
-0.210202157497406,
0.4669651985168457,
-0.1254844218492508,
-0.07080008089542389,
0.33976078033447266,
1.2535994052886963,
0.4469928443431854,
0.15237928926944733,
-0.6170210838317871,
-0.09142414480447769,
... |
func (w *RandomWorld) canPlacePlant(x, y int, plantArea float64) bool {
// Check if surface allows plants to grow
if w.TerrainSpots[x][y].Surface.Habitable {
// Spot can be planted on, is it occupied by a plant?
if w.TerrainSpots[x][y].OccupyingPlant == uuid.Nil {
// Current spot is free, check the circle with... | [
-0.08199195563793182,
-0.34105637669563293,
0.6558714509010315,
-0.43565893173217773,
-0.6730931401252747,
0.32791614532470703,
1.2024648189544678,
-0.12010695785284042,
-0.1433132141828537,
0.8039436340332031,
0.5740488767623901,
-0.3053368031978607,
-0.2276104986667633,
0.196476906538009... |
func (w *RandomWorld) canPlaceWaterPlant(x, y int, plantArea float64, plantID uuid.UUID) bool {
if w.TerrainSpots[x][y].Surface.CommonName != "Water" {
// Non water surface provided
return false
}
if w.TerrainSpots[x][y].OccupyingPlant == uuid.Nil || w.TerrainSpots[x][y].OccupyingPlant == plantID {
// Get a c... | [
-0.1502304971218109,
-0.7231413722038269,
0.6165525317192078,
-0.9759297370910645,
-1.2543525695800781,
0.9830222129821777,
1.2302671670913696,
-0.32718661427497864,
-0.07538795471191406,
0.6261394619941711,
0.8276416063308716,
0.026082314550876617,
-0.7248756885528564,
0.3791678249835968,... |
func (w *RandomWorld) New() error {
// Check if the world was initialized with valid terrain sizes
if w.Height <= 0 || w.Width <= 0 {
return fmt.Errorf("the terrain size can't be less than or equal to zero (given WxH: %dx%d)", w.Width,
w.Height)
}
// Initialize the food and being map
w.BeingList = make(map[st... | [
0.10697747766971588,
0.027297288179397583,
0.6871008276939392,
-0.819169282913208,
-0.7719420194625854,
0.6190288662910461,
0.43716493248939514,
-0.48694249987602234,
-0.5245658159255981,
0.5004182457923889,
0.3534674048423767,
0.3369096517562866,
0.16015101969242096,
1.5077787637710571,
... |
func (w *RandomWorld) ProvideFood(landPlants, waterPlants int) {
// Initialize each food with random values
for i := 0; i < landPlants; i++ {
p := w.RandomPlant(false)
w.FoodList[p.ID.String()] = p
}
for i := 0; i < waterPlants; i++ {
p := w.RandomPlant(true)
w.FoodList[p.ID.String()] = p
}
} | [
-0.22503535449504852,
0.027137383818626404,
0.2799658477306366,
-0.24528780579566956,
-0.31031134724617004,
0.7636035084724426,
0.043948303908109665,
0.04743247851729393,
0.0017531812191009521,
0.1698417365550995,
-0.7325072288513184,
0.2316579669713974,
-1.0437854528427124,
1.013168573379... |
func (w *RandomWorld) RandomPlant(inWater bool) *GoWorld.Food {
f := &GoWorld.Food{ID: uuid.New()}
// Randomly select attributes
f.GrowthSpeed = growthRange.randomFloat()
f.NutritionalValue = nutritionRange.randomFloat()
f.Taste = tasteRange.randomFloat()
f.GrowthStage = float64(stageRange.randomInt()) // keep a... | [
0.2382977306842804,
-0.5437433123588562,
0.318981796503067,
-0.7248232960700989,
-1.2441074848175049,
0.22927451133728027,
0.13235285878181458,
-0.05459161847829819,
0.5166209936141968,
-0.4839475750923157,
0.2153971791267395,
0.17138679325580597,
-1.2471117973327637,
0.05716003105044365,
... |
func (w *RandomWorld) GetTerrainImage() *image.RGBA {
return w.TerrainZones
} | [
0.1008288562297821,
0.07591656595468521,
0.31242528557777405,
0.09415091574192047,
0.019133124500513077,
0.47583550214767456,
0.8091738820075989,
-0.7813446521759033,
-0.43445494771003723,
0.09130165725946426,
0.028223548084497452,
0.09062068909406662,
-0.6935703158378601,
0.26818692684173... |
func (w *RandomWorld) GetBeings() map[string]*GoWorld.Being {
return w.BeingList
} | [
-1.3710891008377075,
0.411100834608078,
0.4575224816799164,
-0.18004834651947021,
-0.03936254605650902,
0.05966672673821449,
-0.9483685493469238,
-0.42597702145576477,
0.2828601598739624,
0.2995837926864624,
-0.6480277180671692,
0.9234554171562195,
-1.1083686351776123,
1.2995364665985107,
... |
func (w *RandomWorld) GetFood() map[string]*GoWorld.Food {
return w.FoodList
} | [
-0.36800986528396606,
-0.3612835705280304,
0.3247810900211334,
0.7037201523780823,
-0.2718604803085327,
0.3213387131690979,
-0.2512046992778778,
-0.07514873892068863,
0.27846553921699524,
-0.3020630180835724,
-0.9789900779724121,
0.8372229933738708,
-0.07524023205041885,
1.4015781879425049... |
func (w *RandomWorld) GetSize() (int, int) {
return w.Width, w.Height
} | [
-0.7459700703620911,
0.16378991305828094,
0.8409996032714844,
-0.26747626066207886,
-0.22577759623527527,
0.24667388200759888,
0.94183349609375,
-0.7637248635292053,
0.08960097283124924,
-0.1302303820848465,
-0.1862701028585434,
-0.10559219866991043,
-1.1428048610687256,
1.4898511171340942... |
func (w *RandomWorld) GetSurfaceColorAtSpot(spot GoWorld.Location) color.RGBA {
return w.TerrainSpots[spot.X][spot.Y].Surface.Color
} | [
-0.46259498596191406,
-0.7768685817718506,
0.34082362055778503,
-1.2498688697814941,
-0.2705031931400299,
0.4457060694694519,
1.0037665367126465,
-1.1879123449325562,
-0.21618245542049408,
0.5881410241127014,
0.6491395235061646,
0.03383274003863335,
0.443585604429245,
0.9403560161590576,
... |
func (w *RandomWorld) GetSurfaceNameAt(location GoWorld.Location) (string, error) {
if w.IsOutOfBounds(location) {
return "", fmt.Errorf(
"error providing color at spot: the location (%d, %d) is out of bounds. WorldSize (%v, %v)",
location.X, location.Y, w.Width, w.Height)
}
return w.TerrainSpots[location.X]... | [
-0.23905648291110992,
-0.43669894337654114,
0.8830776214599609,
-1.0336639881134033,
-0.670475423336029,
0.38192635774612427,
0.8313511610031128,
-1.2127368450164795,
0.33178815245628357,
1.011070966720581,
0.4075840711593628,
-0.1510516256093979,
0.25798842310905457,
0.8205723762512207,
... |
func (w *RandomWorld) GetBeingAt(location GoWorld.Location) (uuid.UUID, error) {
if w.IsOutOfBounds(location) {
return uuid.Nil, fmt.Errorf(
"error providing being at spot: the location (%d, %d) is out of bounds. WorldSize (%v, %v)",
location.X, location.Y, w.Width, w.Height)
}
return w.TerrainSpots[location... | [
-0.472482830286026,
-0.16711512207984924,
0.6937946081161499,
-0.9716679453849792,
0.38987401127815247,
0.19862094521522522,
0.1774851232767105,
-0.3517870604991913,
-0.008949648588895798,
0.6728597283363342,
0.5701306462287903,
0.636156439781189,
-0.6045174598693848,
-0.006268116179853678... |
func (w *RandomWorld) GetFoodWithID(id uuid.UUID) *GoWorld.Food {
if f, ok := w.FoodList[id.String()]; ok {
return f
}
return nil
} | [
0.12245836853981018,
-0.4299562871456146,
0.31850171089172363,
0.9049912691116333,
-0.6184977889060974,
-1.2661341428756714,
-0.9848074913024902,
-0.7597510814666748,
0.3100254535675049,
0.06916842609643936,
-0.4977746605873108,
0.33970823884010315,
-0.4497413635253906,
0.9903278946876526,... |
func (w *RandomWorld) IsHabitable(location GoWorld.Location) (bool, error) {
if w.IsOutOfBounds(location) {
return false, fmt.Errorf(
"error checking inhabitable spot: the location (%d, %d) is out of bounds. WorldSize (%v, %v)",
location.X, location.Y, w.Width, w.Height)
}
return w.TerrainSpots[location.X][l... | [
-0.5488255023956299,
-0.2190956324338913,
0.6123036742210388,
0.37567073106765747,
-0.2978118360042572,
0.6425969004631042,
0.7004280686378479,
-0.5671061277389526,
-0.17369665205478668,
1.3765748739242554,
0.4354272782802582,
-0.097820945084095,
-0.41539692878723145,
0.07637675851583481,
... |
func (w *RandomWorld) SenseActionFor(b *GoWorld.Being) (string, GoWorld.Location) {
// Get the spots that are visible to the being
// Vision range is influenced by stress:
// a stress value of 0 represents the beings natural senses, stress of maxStress represents sense range * 2
stressShare := 1 + b.Stress/stressR... | [
-0.32884013652801514,
-1.0235251188278198,
0.8414855003356934,
-0.4953324496746063,
-0.11957808583974838,
0.13434754312038422,
0.7096502184867859,
-0.8041278123855591,
0.2196749895811081,
0.4030665159225464,
0.4287349283695221,
0.45220109820365906,
0.09745495766401291,
0.6617774367332458,
... |
func (w *RandomWorld) Distance(from, to GoWorld.Location) float64 {
return math.Sqrt(math.Pow(float64(from.X-to.X), 2) + math.Pow(float64(from.Y-to.Y), 2))
} | [
-0.31893065571784973,
-0.5563669800758362,
0.31666603684425354,
-0.16168446838855743,
-0.3880480229854584,
1.3963897228240967,
-0.4957740902900696,
0.19532077014446259,
0.20649509131908417,
0.7609041929244995,
0.20125915110111237,
0.09606601297855377,
-0.15024584531784058,
-0.1298985481262... |
func (w *RandomWorld) MoveBeingToLocation(b *GoWorld.Being, to GoWorld.Location) error {
// Check if location is valid for being to move to
//if ok, err := w.IsHabitable(to); !ok {
// panic(err.Error())
// return err
//}
// Update the terrain spots with the new being
w.TerrainSpots[b.Position.X][b.Position.Y].Be... | [
-1.041609287261963,
-0.5761017799377441,
0.49350422620773315,
-0.5520924925804138,
0.5704134702682495,
0.45426976680755615,
-0.3165026307106018,
0.06418968737125397,
-0.5571792125701904,
1.5171757936477661,
0.054374683648347855,
0.6593065857887268,
0.17492133378982544,
-0.2222481071949005,... |
func (w *RandomWorld) QuenchThirst(b *GoWorld.Being) bool {
// Set true if water found
drank := false
for _, d := range directions8 {
// Check if out of bounds
if b.Position.X+d.X < 0 || b.Position.X+d.X >= w.Width ||
b.Position.Y+d.Y < 0 || b.Position.Y+d.Y >= w.Height {
// Not on map, simply continue
... | [
0.023562148213386536,
-0.8991890549659729,
0.7017998099327087,
-1.3078625202178955,
-0.016643701121211052,
0.6531069278717041,
-0.256753146648407,
-0.9891712069511414,
0.3648301661014557,
0.37509778141975403,
0.2757479250431061,
0.3195623457431793,
-0.8428805470466614,
0.43075403571128845,... |
func (w *RandomWorld) QuenchHunger(b *GoWorld.Being, foodSpot GoWorld.Location) bool {
// Adjacent fields and the center point (9 locations)
// Usually the character moves on top of food when eating it so check 0,0 first
// Has the Being eaten?
ate := false
// Check the distance from food to being
distanceToFood... | [
0.3268592655658722,
-0.6878446340560913,
0.8901951909065247,
-0.17980417609214783,
0.0449022501707077,
0.4509666860103607,
-0.36750683188438416,
0.011651895008981228,
-0.5765384435653687,
0.4788779616355896,
0.33319705724716187,
0.10340214520692825,
-0.35179463028907776,
0.3699442148208618... |
func (w *RandomWorld) AdjustStressFor(b *GoWorld.Being) {
// Does the being feel safe? 1 for yes, 2 for no (e.g. outside natural habitat)
feelsSafe := 1.0
if w.TerrainSpots[b.Position.X][b.Position.Y].Surface.ID != b.Habitat {
feelsSafe = 2.0
}
// How much every necessity contributes
// (2 * len(basicNecessitie... | [
-0.18601758778095245,
-0.32692426443099976,
0.5024917721748352,
-0.9262658953666687,
-0.5305690169334412,
0.14894625544548035,
0.46446049213409424,
-0.3521808683872223,
0.28021562099456787,
-0.040994782000780106,
-0.11971799284219742,
0.2838993966579437,
-0.261961966753006,
0.5869033932685... |
func (w *RandomWorld) AdjustNeeds(b *GoWorld.Being) {
// Most durable beings (compared to least) need only ~30% food
// 0.3 = 1 - x / (x*1.43) for any x
durableC := 1 - b.Durability/(durabilityRange.Max*1.43)
// Increase other values proportional to attribute shares
speedC := 1 + b.Speed/(speedRange.Max)
stressC... | [
-0.6798598766326904,
-0.209919735789299,
0.7799985408782959,
-0.08866062760353088,
-0.580822765827179,
0.7377192378044128,
-0.010279673151671886,
-0.37532752752304077,
-0.5740553736686707,
-0.43149298429489136,
0.6580478549003601,
0.5610778331756592,
0.08372725546360016,
1.0969023704528809... |
func (w *RandomWorld) MateBeing(b *GoWorld.Being) []uuid.UUID {
// Find a partner of opposite gender on adjacent fields
var otherBeing *GoWorld.Being
for _, direction := range directions8 {
adjacentSpot := GoWorld.Location{X: b.Position.X + direction.X, Y: b.Position.Y + direction.Y}
if !w.IsOutOfBounds(adjacent... | [
-0.598154604434967,
-0.2446201592683792,
1.0079317092895508,
-0.2803418040275574,
0.2361321747303009,
0.7292694449424744,
-0.36155447363853455,
-0.2868459224700928,
-0.11665649712085724,
0.9882810115814209,
0.014852510765194893,
-0.283302366733551,
-0.31413280963897705,
1.45133638381958,
... |
func init() {
manufacturerMixin := schema.Manufacturer{}.Mixin()
manufacturerMixinFields0 := manufacturerMixin[0].Fields()
_ = manufacturerMixinFields0
manufacturerMixinFields1 := manufacturerMixin[1].Fields()
_ = manufacturerMixinFields1
manufacturerFields := schema.Manufacturer{}.Fields()
_ = manufacturerField... | [
-0.864643931388855,
-0.164815291762352,
0.70611572265625,
0.5737437605857849,
0.523894190788269,
-0.4921334683895111,
0.1629302203655243,
0.6072289943695068,
0.2058108150959015,
-0.5331205725669861,
-1.198915719985962,
0.11081398278474808,
0.3224465548992157,
0.5178449749946594,
0.605394... |
func (system *System) gen_class_x_endpoint(req web.RequestInterface) *web.ResponseStatus {
x := req.Param("x").(string)
class := system.DB.ClassNameIndex(req.Param("$class").(string))
ok, vtx := system.DBClient.QueryVertexByX(x, class); if !ok { return req.Respond(404, "VERTEX NOT FOUND") }
return req.Respond(v... | [
-1.4874070882797241,
0.2350529283285141,
0.9196560978889465,
0.5876779556274414,
-0.22315017879009247,
0.3531879186630249,
-0.1621685028076172,
-0.4356352388858795,
0.2381134033203125,
0.8001992702484131,
-0.34514790773391724,
0.3169326186180115,
-0.20987962186336517,
-0.4391581118106842,
... |
func (system *System) gen_class_count_endpoint(req web.RequestInterface) *web.ResponseStatus {
class := system.DB.ClassNameIndex(req.Param("$class").(string))
return req.Respond(system.DBClient.QueryClassCount(class))
} | [
-2.0619261264801025,
-0.2756624221801758,
0.6809075474739075,
0.18215849995613098,
0.4739740788936615,
0.034354984760284424,
0.5319498181343079,
0.14701059460639954,
-0.13953350484371185,
0.24202808737754822,
-0.2710665166378021,
-0.13540136814117432,
-0.11734171211719513,
0.27937257289886... |
func (system *System) gen_class_list_endpoint(req web.RequestInterface) *web.ResponseStatus {
class := system.DB.ClassNameIndex(req.Param("$class").(string))
var limit int64 = -1
var page int64 = -1
if req.Param("limit") != nil { limit = req.Param("limit").(int64) }
if req.Param("page") != nil { page = req.Para... | [
-1.544530987739563,
0.24208427965641022,
1.2660571336746216,
0.7182518839836121,
0.13102905452251434,
0.00805856753140688,
0.438255250453949,
-0.20978835225105286,
0.6446841955184937,
1.045866847038269,
-0.09276308864355087,
-0.11261814087629318,
-0.2992105185985565,
0.5761654376983643,
... |
func hourglassSum(arr [][]int32) int32 {
max := math.MinInt32
for i := 0; i < 4; i++ {
for j := 0; j < 4; j++ {
hv := calcHourglass(i, j, arr)
if max < hv {
max = hv
}
}
}
return int32(max)
} | [
-0.3155720829963684,
0.16681714355945587,
0.7554572224617004,
0.7064056396484375,
-0.44243407249450684,
0.1428622454404831,
0.5474602580070496,
-0.9406301379203796,
0.33444929122924805,
0.14329327642917633,
-0.20779001712799072,
-0.8207237720489502,
-0.6342014074325562,
-0.0591183044016361... |
func (s Secret) ID() string {
return s.Namespace
} | [
0.7222099304199219,
-1.1859334707260132,
0.004411241505295038,
1.2247684001922607,
-0.20405997335910797,
1.3785791397094727,
-0.7539610266685486,
-0.5626351237297058,
2.0594780445098877,
-0.5837541818618774,
-0.8194538354873657,
0.7555335760116577,
-0.24883660674095154,
0.9281049370765686,... |
func (s Secret) Hash() uint64 {
return s.hash
} | [
0.4744419455528259,
0.29795587062835693,
0.2693895399570465,
1.3383454084396362,
-0.2831176817417145,
0.44809892773628235,
-0.024188674986362457,
1.0212676525115967,
0.3536958694458008,
-0.8914077877998352,
-0.6866303086280823,
1.4485516548156738,
0.12264030426740646,
0.46191030740737915,
... |
func (s SecretWatchableSet) Watch(resouceVersion string) (watch.Interface, error) {
// Get the list options so we can create the watch
watchOptions := api.ListOptions{
ResourceVersion: resouceVersion,
}
// Create a watcher to be notified of Namespace events
// TODO: Limit namespaces to only namespaces with labe... | [
0.3824005424976349,
-0.2029104232788086,
0.30292290449142456,
0.2046343982219696,
-0.20957264304161072,
0.025968531146645546,
-0.3710700273513794,
-0.3200088143348694,
0.365998774766922,
0.1471223384141922,
-0.6996243596076965,
0.652927041053772,
-0.46401065587997437,
-0.10528586059808731,... |
func (s SecretWatchableSet) Get() ([]WatchableResource, string, error) {
// Query the initial list of Namespaces
// TODO: Limit namespaces to only namespaces with label
k8sSecrets, err := s.KubeClient.Core().Secrets(api.NamespaceAll).List(api.ListOptions{})
if err != nil {
return nil, "", err
}
// Filter out t... | [
-0.4188578724861145,
-0.19784322381019592,
0.35408324003219604,
0.07021275907754898,
-0.10775550454854965,
-0.6165302991867065,
-1.2309999465942383,
-0.23400747776031494,
-0.13980209827423096,
1.2053073644638062,
-0.41711556911468506,
0.8658116459846497,
0.10491229593753815,
0.275389760732... |
func (s SecretWatchableSet) ConvertToModel(in interface{}) WatchableResource {
k8Secret := in.(*api.Secret)
secret := &Secret{
Namespace: k8Secret.Namespace,
Fields: k8Secret.Data,
}
if routingKey, ok := k8Secret.Data[s.Config.APIKeySecretDataField]; ok {
secret.RoutingKey = &routingKey
}
// Pre calcul... | [
0.18669794499874115,
0.032914794981479645,
0.5143535137176514,
0.0735214501619339,
-0.4351039230823517,
-0.2609097361564636,
-0.4880416989326477,
-0.23153775930404663,
0.45156458020210266,
0.8410170674324036,
-0.9301799535751343,
-0.13542655110359192,
0.6806127429008484,
-0.089082859456539... |
func (s SecretWatchableSet) Watchable(in interface{}) bool {
k8Secret := in.(*api.Secret)
if k8Secret.Name != s.Config.APIKeySecret {
return false
}
return true
} | [
-0.4573994278907776,
0.2881210148334503,
0.4655030071735382,
0.8940415382385254,
-0.6298795938491821,
0.21670390665531158,
-0.5136111378669739,
-0.258604496717453,
-0.25696709752082825,
0.7192093133926392,
-0.6507636308670044,
-0.01492845918983221,
-0.5779424905776978,
0.2564248740673065,
... |
func (s SecretWatchableSet) CacheAdd(cache *Cache, item WatchableResource) {
secret := item.(*Secret)
cache.Secrets[item.ID()] = secret
} | [
0.1883975863456726,
-0.2032354325056076,
0.31020909547805786,
0.7436885833740234,
-0.22837062180042267,
0.18333379924297333,
-0.9861729741096497,
-0.027929559350013733,
0.38878726959228516,
0.40311065316200256,
-0.6364647746086121,
0.8233228325843811,
0.572521984577179,
0.01121331471949815... |
func (s SecretWatchableSet) CacheRemove(cache *Cache, id string) {
delete(cache.Secrets, id)
} | [
-0.4630075693130493,
0.6323650479316711,
0.19074098765850067,
0.4563736319541931,
-1.0603859424591064,
-0.47710907459259033,
-0.754465639591217,
0.49713975191116333,
0.2874208986759186,
0.8063665628433228,
-0.712903618812561,
0.5849451422691345,
-0.5895183086395264,
0.39341261982917786,
... |
func (s SecretWatchableSet) CacheCompare(cache *Cache, newItem WatchableResource) bool {
item, ok := cache.Secrets[newItem.ID()]
if !ok {
return false
}
return item.Hash() == newItem.Hash()
} | [
-0.3635464310646057,
-0.5525954365730286,
0.3766155540943146,
1.223365306854248,
-0.7664453387260437,
-0.008563647978007793,
-1.0993870496749878,
-0.9323409795761108,
-0.03680994361639023,
0.9428048133850098,
-0.325623095035553,
0.25091031193733215,
-0.3561711013317108,
0.3314725160598755,... |
func (s SecretWatchableSet) IDFromObject(in interface{}) string {
secret := in.(*api.Secret)
return secret.Namespace
} | [
-0.15779845416545868,
-0.3713674545288086,
0.3745725154876709,
0.7278156280517578,
-0.5073889493942261,
0.3204433023929596,
-0.23287396132946014,
-1.3373607397079468,
0.7083817720413208,
-0.26707524061203003,
-0.6578293442726135,
0.5704318881034851,
-0.3645687699317932,
-0.1290657073259353... |
func NewArtistDAO(c *mgo.Session) *ArtistDAO {
return &ArtistDAO{c}
} | [
0.7134239077568054,
-0.5483468770980835,
0.22633378207683563,
-0.500897228717804,
-1.619205355644226,
-0.2900775969028473,
0.6539511680603027,
1.0889290571212769,
0.45277783274650574,
-0.15583311021327972,
-0.7044442296028137,
1.0574029684066772,
0.3843933343887329,
0.18453475832939148,
... |
func (dao ArtistDAO) getCollection() *mgo.Collection {
return dao.conn.DB("bookfire").C("artists")
} | [
-0.028999604284763336,
-0.10793720185756683,
0.17253945767879486,
0.08249372988939285,
0.757107138633728,
0.14655078947544098,
0.19547781348228455,
0.7140530347824097,
-0.5472537279129028,
-0.6329556703567505,
-0.04980170354247093,
0.31699949502944946,
-0.1458209604024887,
0.85731726884841... |
func (dao ArtistDAO) Create(a Artist) error {
return dao.getCollection().Insert(a)
} | [
-0.3567811846733093,
0.5911895632743835,
0.2030799686908722,
-0.13290590047836304,
0.17010995745658875,
0.7897263169288635,
0.38826796412467957,
0.6206704378128052,
0.0016170546878129244,
-0.27892643213272095,
-0.7548645734786987,
-0.6035017967224121,
-0.5014161467552185,
0.831664621829986... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.