Exemple #1
0
func parseKifu(b string) string {
	b = tryFixSgf(b)
	c, err := sgf.ParseSgf(b)
	if err != nil {
		return "ERR"
	} else {
		node := c.GameTrees[0].Nodes[0]
		f := func(pName string) string {
			for _, prop := range node.Properties {
				if pName == prop.Ident {
					return strings.Join(prop.Values, ",")
				}
			}
			return "NOWRNODE"
		}
		value := f("WR")
		if value == "NOWRNODE" {
			log.Println("NOWRNODE WRBB ", value)
			return "NOWRNODE"
		}
		if value != "" {
			log.Println("WROK WRBB ", value)
			return "WROK"
		} else {
			log.Println("WRNULL WRBB ", value)
			return "WRNULL"
		}
	}
}
Exemple #2
0
func parseKifu(b string) {
	b = tryFixSgf(b)
	log.Println("b ", b)
	c, err := sgf.ParseSgf(b)

	if err != nil {
		log.Println("ERR ", err)
	}
	node := c.GameTrees[0].Nodes[0]
	f := func(pName string) string {
		for _, prop := range node.Properties {
			if pName == prop.Ident {
				return strings.Join(prop.Values, ",")
			}
		}
		return ""
	}
	log.Println("dt ", f("DT"))
	log.Println("HA ", f("HA"))
	log.Println("BR ", f("BR"))
	log.Println("WR ", f("WR"))
	log.Println("PB ", f("PB"))
	log.Println("PW ", f("PW"))
	log.Println("RE ", f("RE"))
	log.Println("KM ", f("KM"))
	log.Println("c.GameTrees[0].Nodes ", c.GameTrees[0].Nodes[1])

	log.Println("Hands ", len(c.GameTrees[0].Nodes)-1)
	log.Println("====================")
}
Exemple #3
0
//在命令行执行
func parseSgf(file string) {

	b, err := ioutil.ReadFile(file)

	rInNop := transform.NewReader(bytes.NewReader(b), encoding.Nop.NewDecoder())
	b, _ = ioutil.ReadAll(rInNop)
	NopB := string(b)

	b1 := tryFixSgf(NopB)
	c, err := sgf.ParseSgf(b1)
	if err != nil {
		log.Println("ERR")
	}
	node := c.GameTrees[0].Nodes[0]
	f := func(pName string) string {
		for _, prop := range node.Properties {
			if pName == prop.Ident {
				return strings.Join(prop.Values, ",")
			}
		}
		return ""
	}
	log.Println("dt ", f("DT"))
	log.Println("HA ", f("HA"))
	log.Println("BR ", f("BR"))
	log.Println("WR ", f("WR"))
	log.Println("PB ", f("PB"))
	log.Println("PW ", f("PW"))
	log.Println("RE ", f("RE"))
	log.Println("KM ", f("KM"))
	log.Println("====================")
}
Exemple #4
0
func parseKifu(b string) string {
	b = tryFixSgf(b)
	_, err := sgf.ParseSgf(b)
	if err != nil {
		return "ERR"
	} else {
		return "OK"
	}
}
Exemple #5
0
func parseKifu(b string) string {
	b = tryFixSgf(b)
	c, err := sgf.ParseSgf(b)
	if err != nil {
		return ""
	}

	node := c.GameTrees[0].Nodes[0]
	f := func(pName string) string {
		for _, prop := range node.Properties {
			if pName == prop.Ident {
				return strings.Join(prop.Values, ",")
			}
		}
		return ""
	}

	return f("CA")
}
Exemple #6
0
func parseKifu(b string) string {
	b = tryFixSgf(b)
	if strings.Contains(b, "com.microsoft.sqlserver.jdbc.SQLServerException") {
		return "SGFContentERR"
	}
	c, err := sgf.ParseSgf(b)
	if err != nil {
		log.Println("b ", b)
		log.Println("err ", err)
		return "ERR"
	} else {
		node := c.GameTrees[0].Nodes[0]
		f := func(pName string) string {
			for _, prop := range node.Properties {
				if pName == prop.Ident {
					return strings.Join(prop.Values, ",")
				}
			}
			return ""
		}
		dtvalue := f("DT")
		pbvalue := f("PB")
		pwvalue := f("PW")
		brvalue := f("BR")
		wrvalue := f("WR")
		revalue := f("RE")

		//		log.Println(parseSgfPro(dtvalue) == "OK")
		//		log.Println(parseSgfPro(pbvalue) == "OK")
		//		log.Println(parseSgfPro(pwvalue) == "OK")
		//		log.Println(parseSgfPro(brvalue) == "OK")
		//		log.Println(parseSgfPro(wrvalue) == "OK")
		//		log.Println(parseSgfPro(revalue) == "OK")

		if parseSgfPro(dtvalue) == "OK" && parseSgfPro(pbvalue) == "OK" && parseSgfPro(pwvalue) == "OK" && parseSgfPro(brvalue) == "OK" && parseSgfPro(wrvalue) == "OK" && parseSgfPro(revalue) == "OK" {
			return "OK"
		} else {
			return "ERR"
		}
	}
}
func parseKifu(b string) (string, string) {
	b = tryFixSgf(b)
	c, err := sgf.ParseSgf(b)
	if err != nil {
		return "", ""
	}

	node := c.GameTrees[0].Nodes[0]
	f := func(pName string) string {
		for _, prop := range node.Properties {
			if pName == prop.Ident {
				return strings.Join(prop.Values, ",")
			}
		}
		return ""
	}
	valuePB := f("PB")
	valuePW := f("PW")

	return valuePB, valuePW
}
Exemple #8
0
func parseKifu(b string) string {
	b = tryFixSgf(b)
	c, err := sgf.ParseSgf(b)
	if err != nil {
		log.Println("ERR")
	}
	node := c.GameTrees[0].Nodes[0]
	f := func(pName string) string {
		for _, prop := range node.Properties {
			if pName == prop.Ident {
				return strings.Join(prop.Values, ",")
			}
		}
		return ""
	}
	value := f("CA")
	if value != "" {
		return value
	} else {
		return ""
	}
}
Exemple #9
0
func parseKifu(b string) string {
	b = tryFixSgf(b)
	c, err := sgf.ParseSgf(b)
	if err != nil {
		return "ERR"
	} else {
		node := c.GameTrees[0].Nodes[0]
		f := func(pName string) string {
			for _, prop := range node.Properties {
				if pName == prop.Ident {
					return strings.Join(prop.Values, ",")
				}
			}
			return "NOOKNODE"
		}
		//		dtOK := false
		//		pbOK := false
		//		pwOK := false
		//		brOK := false
		//		wrOK := false
		//		reOK := false

		dtvalue := f("DT")
		pbvalue := f("PB")
		pwvalue := f("PW")
		brvalue := f("BR")
		wrvalue := f("WR")
		revalue := f("RE")

		if parseSgfPro(dtvalue) == "OK" && parseSgfPro(pbvalue) == "OK" && parseSgfPro(pwvalue) == "OK" && parseSgfPro(brvalue) == "OK" && parseSgfPro(wrvalue) == "OK" && parseSgfPro(revalue) == "OK" {
			return "OK"
		} else {
			return "ERR"
		}
	}
}
func parseKifu(b string) string {
	b = tryFixSgf(b)
	if strings.Contains(b, "com.microsoft.sqlserver.jdbc.SQLServerException") {
		return "SGFContentERR"
	}
	c, err := sgf.ParseSgf(b)
	if err != nil {
		log.Println("b ", b)
		log.Println("err ", err)
		return "ERR"
	} else {
		node := c.GameTrees[0].Nodes[0]
		f := func(pName string) string {
			for _, prop := range node.Properties {
				if pName == prop.Ident {
					return strings.Join(prop.Values, ",")
				}
			}
			return ""
		}
		dtvalue := f("DT")
		pbvalue := f("PB")
		pwvalue := f("PW")
		brvalue := f("BR")
		wrvalue := f("WR")
		revalue := f("RE")

		//		log.Println(parseSgfPro(dtvalue) == "OK")
		//		log.Println(parseSgfPro(pbvalue) == "OK")
		//		log.Println(parseSgfPro(pwvalue) == "OK")
		//		log.Println(parseSgfPro(brvalue) == "OK")
		//		log.Println(parseSgfPro(wrvalue) == "OK")
		//		log.Println(parseSgfPro(revalue) == "OK")

		dt := parseSgfProByDT(dtvalue) == "OK"
		pb := parseSgfPro(pbvalue) == "OK"
		pw := parseSgfPro(pwvalue) == "OK"
		br := parseSgfPro(brvalue) == "OK"
		wr := parseSgfPro(wrvalue) == "OK"
		re := parseSgfPro(revalue) == "OK"
		if dt && pb && pw && br && wr && re {
			return "OK"
		} else {
			err := ""
			if !dt {
				err += "DT_"
			}
			if !pb {
				err += "PB_"
			}
			if !pw {
				err += "PW_"
			}
			if !br {
				err += "BR_"
			}
			if !wr {
				err += "WR_"
			}
			if !re {
				err += "RE_"
			}
			return err
		}
	}
}