public static void InsertVReward(string state, string stra, bool win)
        {
            BlackTD0DataContext blackTD0 = new BlackTD0DataContext();
            int sno = blackTD0.STATEs.Where(p => p.MSTATE == state).Single().SNO;
            int ano = blackTD0.ASTRATEGies.Where(p => p.STRATEGY == stra).Single().ANO;
            int times;
            if (win) times = 1;
            else times = 0;
            double vs = blackTD0.VSTATEs.Where(p => p.SNO == sno).Single().VALUE;

            if (!blackTD0.VREWARDs.Any(p => p.SNO == sno && p.ANO == ano))
            {
                VREWARD tmps = new VREWARD();
                tmps.SNO = sno;
                tmps.ANO = ano;
                tmps.TIMES = times;
                tmps.TOTAL = 1;
                tmps.REWARD = times;
                blackTD0.VREWARDs.InsertOnSubmit(tmps);
                blackTD0.SubmitChanges();
            }
            else
            {
                VREWARD tmps = blackTD0.VREWARDs.Where(p => p.SNO == sno && p.ANO == ano).Single();
                tmps.TIMES += times;
                tmps.TOTAL++;
                tmps.REWARD = vs * Convert.ToDouble(times) / tmps.TOTAL;
                blackTD0.SubmitChanges();
            }
        }
        public static double SelectReward(string state, string strategy, bool isKing)
        {
            double reward;
            BlackTD0DataContext blackTD0 = new BlackTD0DataContext();
            var tmp = from c in blackTD0.STATEs
                      from o in blackTD0.ASTRATEGies
                      from e in blackTD0.VREWARDs
                      where c.SNO == e.SNO && o.ANO == e.ANO && c.MSTATE == state && o.STRATEGY == strategy
                      select e.REWARD;

            if (tmp.Count() <= 0)
            {
                VREWARD tmps = new VREWARD();
                tmps.SNO = blackTD0.STATEs.Where(p => p.MSTATE == state).Single().SNO;
                tmps.ANO = blackTD0.ASTRATEGies.Where(p => p.STRATEGY == strategy).Single().ANO;
                tmps.TIMES = 0;
                if (isKing) tmps.REWARD = 100.0;
                else tmps.REWARD = 1.0;
                blackTD0.VREWARDs.InsertOnSubmit(tmps);
                blackTD0.SubmitChanges();
                reward = tmps.REWARD;
            }
            else reward = tmp.Single();
            return reward;
        }
 int SelectWinTimes(string state, string strategy)
 {
     int times;
     BlackTD0DataContext blackTD0 = new BlackTD0DataContext();
     var tmp = from c in blackTD0.STATEs
               from o in blackTD0.ASTRATEGies
               from e in blackTD0.VREWARDs
               where c.SNO == e.SNO && o.ANO == e.ANO && c.MSTATE == state && o.STRATEGY == strategy
               select e.TIMES;
     if (tmp.Count() <= 0)
     {
         VREWARD tmps = new VREWARD();
         tmps.SNO = blackTD0.STATEs.Where(p => p.MSTATE == state).Single().SNO;
         tmps.ANO = blackTD0.ASTRATEGies.Where(p => p.STRATEGY == strategy).Single().ANO;
         tmps.TIMES = 0;
         tmps.REWARD = 1.0;
         blackTD0.VREWARDs.InsertOnSubmit(tmps);
         blackTD0.SubmitChanges();
         times = 0;
     }
     else times = tmp.Single();
     return times;
 }
		private void detach_VREWARDs(VREWARD entity)
		{
			this.SendPropertyChanging();
			entity.STATE = null;
		}
		private void attach_VREWARDs(VREWARD entity)
		{
			this.SendPropertyChanging();
			entity.STATE = this;
		}
 partial void DeleteVREWARD(VREWARD instance);
 partial void UpdateVREWARD(VREWARD instance);
 partial void InsertVREWARD(VREWARD instance);