Beispiel #1
0
        public static Limb TransitionTo (Limb from, Analyzer.Node.Limb to, float cur_second) {
            if (!IsArcValid(from, to)) {
                throw new ArgumentException();
            }

            if (to == null) {
                throw new ArgumentException();
                /*Limb nxt = new Limb();
                for (int i = 0; i < Limb.PART_COUNT; ++i) {
                    Part part = PartHelper.TransitionTo(from[i], null, cur_second);
                    nxt[i] = part;
                }
                nxt.sanityCheck();
                return nxt;*/
            } else {
                Limb nxt = new Limb();
                for (int i = 0; i < Limb.PART_COUNT; ++i) {
                    Part part = PartHelper.TransitionTo(from[i], to[i], cur_second);
                    nxt[i] = part;
                }
                if (to[Analyzer.Node.Limb.INDEX_EXTRA] == null) {
                    nxt.extra = nxt.sub;
                }
                bool has_main = to.main != null;
                bool has_sub = to.sub != null;
                bool has_extra = to.extra != null;
                Fail fail = new Fail(nxt);
                if (has_main) {
                    if (has_sub) {
                        if (has_extra) {
                            //main+sub+extra
                            if (fail.main_sub) {
                                throw new ArgumentException();
                            }
                            if (fail.main_extra) {
                                throw new ArgumentException();
                            }
                            if (fail.sub_extra) {
                                throw new ArgumentException();
                            }
                        } else {
                            //main+sub
                            if (fail.main_sub) {
                                throw new ArgumentException();
                            }
                            if (fail.main_extra) {
                                nxt.extra = nxt.sub;
                                fail = new Fail(nxt);
                            }
                            if (fail.sub_extra) {
                                nxt.extra = nxt.sub;
                                fail = new Fail(nxt);
                            }
                        }
                    } else if (has_extra) {
                        //main+extra
                        if (fail.main_sub) {
                            nxt.sub = nxt.extra;
                            fail = new Fail(nxt);
                        }
                        if (fail.main_extra) {
                            throw new ArgumentException();
                        }
                        if (fail.sub_extra) {
                            nxt.sub = nxt.extra;
                            fail = new Fail(nxt);
                        }
                    } else {
                        //main
                        if (fail.main_sub) {
                            Panel n = Panel.CalculateBestBracketable(nxt.main.panel, nxt.sub.panel);
                            Part src = nxt.sub;
                            nxt.sub = new Part(
                                Movement.Unknown,
                                n,
                                src.cur_second,
                                cur_second,
                                src.cur_moved_second == cur_second ?
                                    src.prv_moved_second : src.cur_moved_second
                            );
                            fail = new Fail(nxt);
                        }
                        if (fail.main_extra) {
                            nxt.extra = nxt.sub;
                            fail = new Fail(nxt);
                        }
                        if (fail.sub_extra) {
                            throw new ArgumentException();
                        }
                    }
                } else if (has_sub) {
                    if (has_extra) {
                        //sub+extra
                        if (fail.main_sub) {
                            Panel n = Panel.CalculateBestBracketable(nxt.sub.panel, nxt.main.panel);
                            Part src = nxt.main;
                            nxt.main = new Part(
                                Movement.Unknown,
                                n,
                                src.cur_second,
                                cur_second,
                                src.cur_moved_second == cur_second ?
                                    src.prv_moved_second : src.cur_moved_second
                            );
                            fail = new Fail(nxt);
                        }
                        if (fail.main_extra) {
                            Panel n = Panel.CalculateBestBracketable(nxt.extra.panel, nxt.main.panel);
                            Part src = nxt.main;
                            nxt.main = new Part(
                                Movement.Unknown,
                                n,
                                src.cur_second,
                                cur_second,
                                src.cur_moved_second == cur_second ?
                                    src.prv_moved_second : src.cur_moved_second
                            );
                            fail = new Fail(nxt);
                        }
                        if (fail.sub_extra) {
                            throw new ArgumentException();
                        }
                    } else {
                        //sub
                        if (fail.main_sub) {
                            Panel n = Panel.CalculateBestBracketable(nxt.sub.panel, nxt.main.panel);
                            Part src = nxt.main;
                            nxt.main = new Part(
                                Movement.Unknown,
                                n,
                                src.cur_second,
                                cur_second,
                                src.cur_moved_second == cur_second ?
                                    src.prv_moved_second : src.cur_moved_second
                            );
                            fail = new Fail(nxt);
                        }
                        if (fail.main_extra) {
                            throw new ArgumentException();
                        }
                        if (fail.sub_extra) {
                            nxt.extra = nxt.sub;
                            fail = new Fail(nxt);
                        }
                    }
                } else if (has_extra) {
                    //extra
                    if (fail.main_sub) {
                        throw new ArgumentException();
                    }
                    if (fail.main_extra) {
                        Panel n = Panel.CalculateBestBracketable(nxt.extra.panel, nxt.main.panel);
                        Part src = nxt.main;
                        nxt.main = new Part(
                            Movement.Unknown,
                            n,
                            src.cur_second,
                            cur_second,
                            src.cur_moved_second == cur_second ?
                                src.prv_moved_second : src.cur_moved_second
                        );
                        fail = new Fail(nxt);
                    }
                    if (fail.sub_extra) {
                        nxt.sub = nxt.extra;
                        fail = new Fail(nxt);
                    }
                } else {
                    //NOTHING
                    if (fail.main_sub) {
                        throw new ArgumentException();
                    }
                    if (fail.main_extra) {
                        throw new ArgumentException();
                    }
                    if (fail.sub_extra) {
                        throw new ArgumentException();
                    }
                }
                if (fail.main_sub || fail.main_extra || fail.sub_extra) {
                    throw new ArgumentException();
                }
                nxt.sanityCheck();
                return nxt;
            }
        }
Beispiel #2
0
        public static Limb TransitionToV3 (Limb from, Analyzer.Node.Limb to, float cur_second) {
            if (!IsArcValid(from, to)) {
                throw new ArgumentException();
            }

            if (to == null) {
                throw new ArgumentException();
            } else {
                Limb nxt = new Limb();
                for (int i = 0; i < Limb.PART_COUNT; ++i) {
                    Part from_part = from[i];
                    Analyzer.Node.Part to_part = to[i];
                    Part part;
                    if (to_part == null) {
                        if (from_part.IsUnknown()) {
                            part = Part.ToUnknown(from_part, cur_second);
                        } else {
                            part = Part.ToPassiveDown(from_part, cur_second);
                        }
                    } else {
                        if (PartHelper.IsArcValid(from_part, to_part)) {
                            part = PartHelper.TransitionTo(from_part, to_part, cur_second);
                        } else {
                            throw new ArgumentException();
                        }
                    }
                    nxt[i] = part;
                }
                FixInvalidBracket(nxt);
                nxt.sanityCheck();
                return nxt;
            }
        }
Beispiel #3
0
 private static void AddIfValid (List<Limb> list, Limb item) {
     Fail fail = new Fail(item);
     if (fail.main_sub || fail.main_extra || fail.sub_extra) {
         return;
     }
     item.sanityCheck();
     list.Add(item);
 }