예제 #1
0
        public virtual void searchRivers(global::game.Game game, global::game.Site site, int punterId, int i, global::haxe.IMap <int, int> distances, global::Array <object> nextSites)
        {
            unchecked {
                object river = ((global::haxe.IMap <int, object>)(site.rivers)).iterator();
                while (global::haxe.lang.Runtime.toBool(global::haxe.lang.Runtime.callField(river, "hasNext", 407283053, null)))
                {
                    global::game.River river1 = ((global::game.River)(global::haxe.lang.Runtime.callField(river, "next", 1224901875, null)));
                    int another = (((river1.a == site.id)) ? (river1.b) : (river1.a));
                    if (!(distances.exists(another)))
                    {
                        if ((river1.owner == punterId))
                        {
                            distances.@set(another, i);
                            this.searchRivers(game, ((global::game.Site)((((global::haxe.IMap <int, object>)(game.sites)).@get(another)).@value)), punterId, i, distances, nextSites);
                        }
                        else
                        {
                            {
                                int v = (i + 1);
                                distances.@set(another, v);
                            }

                            nextSites.push(((global::game.Site)((((global::haxe.IMap <int, object>)(game.sites)).@get(another)).@value)));
                        }
                    }
                }
            }
        }
예제 #2
0
파일: Punter.cs 프로젝트: hasipon/icfpc2017
        public override object __hx_setField(string field, int hash, object @value, bool handleProperties)
        {
            unchecked {
                switch (hash)
                {
                case 999785710:
                {
                    this.accessableSites = ((global::haxe.IMap <int, object>)(global::haxe.IMap__Statics_.__hx_cast <int, object>(((global::haxe.IMap)(@value)))));
                    return(@value);
                }


                case 23515:
                {
                    this.id = ((int)(global::haxe.lang.Runtime.toInt(@value)));
                    return(@value);
                }


                case 1147073522:
                {
                    this.game = ((global::game.Game)(@value));
                    return(@value);
                }


                default:
                {
                    return(base.__hx_setField(field, hash, @value, handleProperties));
                }
                }
            }
        }
예제 #3
0
 public static void __hx_ctor_game_River(global::game.River __hx_this, global::game.Game game1, int id, int a, int b)
 {
     __hx_this.id    = id;
     __hx_this.game  = game1;
     __hx_this.a     = a;
     __hx_this.b     = b;
     __hx_this.owner = global::game._PunterId.PunterId_Impl_.NotFound;
 }
예제 #4
0
파일: Site.cs 프로젝트: hasipon/icfpc2017
 public static void __hx_ctor_game_Site(global::game.Site __hx_this, global::game.Game game1, int id, double x, double y)
 {
     __hx_this.x      = x;
     __hx_this.y      = y;
     __hx_this.id     = id;
     __hx_this.game   = game1;
     __hx_this.isMine = false;
     __hx_this.rivers = new global::haxe.ds.IntMap <object>();
 }
예제 #5
0
파일: Site.cs 프로젝트: hasipon/icfpc2017
        public override object __hx_setField(string field, int hash, object @value, bool handleProperties)
        {
            unchecked {
                switch (hash)
                {
                case 121:
                {
                    this.y = ((double)(global::haxe.lang.Runtime.toDouble(@value)));
                    return(@value);
                }


                case 120:
                {
                    this.x = ((double)(global::haxe.lang.Runtime.toDouble(@value)));
                    return(@value);
                }


                case 1477328871:
                {
                    this.rivers = ((global::haxe.IMap <int, object>)(global::haxe.IMap__Statics_.__hx_cast <int, object>(((global::haxe.IMap)(@value)))));
                    return(@value);
                }


                case 1707283357:
                {
                    this.isMine = global::haxe.lang.Runtime.toBool(@value);
                    return(@value);
                }


                case 23515:
                {
                    this.id = ((int)(global::haxe.lang.Runtime.toInt(@value)));
                    return(@value);
                }


                case 1147073522:
                {
                    this.game = ((global::game.Game)(@value));
                    return(@value);
                }


                default:
                {
                    return(base.__hx_setField(field, hash, @value, handleProperties));
                }
                }
            }
        }
예제 #6
0
 public static void __hx_ctor_game_Game(global::game.Game __hx_this)
 {
     __hx_this.sites           = new global::haxe.ds.IntMap <object>();
     __hx_this.mines           = new global::haxe.ds.IntMap <object>();
     __hx_this.rivers          = new global::haxe.ds.IntMap <object>();
     __hx_this.punters         = new global::haxe.ds.IntMap <object>();
     __hx_this.scoreDictionary = new global::haxe.ds.IntMap <object>();
     __hx_this.mineCount       = 0;
     __hx_this.siteCount       = 0;
     __hx_this.riverCount      = 0;
     __hx_this.maxScore        = 0;
     __hx_this.punterCount     = 0;
     __hx_this.moves           = new global::Array <object>(new object[] {});
 }
예제 #7
0
        public virtual double evalFor(global::game.Game game, int punterId)
        {
            unchecked {
                double @value = 0.0;
                {
                    object mine = ((global::haxe.IMap <int, object>)(game.mines)).iterator();
                    while (global::haxe.lang.Runtime.toBool(global::haxe.lang.Runtime.callField(mine, "hasNext", 407283053, null)))
                    {
                        global::game.Site            mine1        = ((global::game.Site)(global::haxe.lang.Runtime.callField(mine, "next", 1224901875, null)));
                        global::Array <object>       currentSites = new global::Array <object>(new object[] {});
                        global::haxe.IMap <int, int> distances    = new global::haxe.ds.IntMap <int>();
                        this.searchRivers(game, mine1, punterId, 0, distances, currentSites);
                        {
                            int _g1 = 1;
                            int _g  = (global::eval.Evaluter.MAX_DISTANCE + 1);
                            while ((_g1 < _g))
                            {
                                int i = _g1++;
                                global::Array <object> nextSites = new global::Array <object>(new object[] {});
                                {
                                    int _g2 = 0;
                                    while ((_g2 < currentSites.length))
                                    {
                                        global::game.Site site = ((global::game.Site)(currentSites[_g2]));
                                        ++_g2;
                                        this.searchRivers(game, site, punterId, i, distances, nextSites);
                                    }
                                }

                                currentSites = nextSites;
                            }
                        }

                        {
                            object siteId = distances.keys();
                            while (global::haxe.lang.Runtime.toBool(global::haxe.lang.Runtime.callField(siteId, "hasNext", 407283053, null)))
                            {
                                int siteId1 = ((int)(global::haxe.lang.Runtime.toInt(global::haxe.lang.Runtime.callField(siteId, "next", 1224901875, null))));
                                global::haxe.lang.Null <int> distance = ((global::haxe.lang.Null <int>)(distances.@get(siteId1)));
                                global::haxe.lang.Null <int> score    = ((global::haxe.IMap <int, int>)(global::haxe.IMap__Statics_.__hx_cast <int, int>(((global::haxe.IMap)((((global::haxe.IMap <int, object>)(game.scoreDictionary)).@get(mine1.id)).@value))))).@get(siteId1);
                                double aditional = (this.table[(distance).@value] * (score).@value);
                                @value += aditional;
                            }
                        }
                    }
                }

                return(@value);
            }
        }
예제 #8
0
        public override object __hx_setField(string field, int hash, object @value, bool handleProperties)
        {
            unchecked {
                switch (hash)
                {
                case 947296307:
                {
                    this.owner = ((int)(global::haxe.lang.Runtime.toInt(@value)));
                    return(@value);
                }


                case 98:
                {
                    this.b = ((int)(global::haxe.lang.Runtime.toInt(@value)));
                    return(@value);
                }


                case 97:
                {
                    this.a = ((int)(global::haxe.lang.Runtime.toInt(@value)));
                    return(@value);
                }


                case 1147073522:
                {
                    this.game = ((global::game.Game)(@value));
                    return(@value);
                }


                case 23515:
                {
                    this.id = ((int)(global::haxe.lang.Runtime.toInt(@value)));
                    return(@value);
                }


                default:
                {
                    return(base.__hx_setField(field, hash, @value, handleProperties));
                }
                }
            }
        }
예제 #9
0
        public virtual global::eval.EvalutionResult eval(global::game.Game game1)
        {
            global::Array <double> _g = new global::Array <double>(new double[] {});
            {
                int _g2 = 0;
                int _g1 = game1.punterCount;
                while ((_g2 < _g1))
                {
                    int i = _g2++;
                    _g.push(this.evalFor(game1, global::game._PunterId.PunterId_Impl_._new(i)));
                }
            }

            global::Array <double> values = _g;

            return(new global::eval.EvalutionResult(((global::Array <double>)(values))));
        }
예제 #10
0
        public virtual object getMove(global::game.Game game, int punter)
        {
            global::Array <object> livingRivers = game.getLivingRivers();
            global::Array <object> moves        = new global::Array <object>(new object[] {});
            {
                int _g = 0;
                while ((_g < livingRivers.length))
                {
                    global::game.River river = ((global::game.River)(livingRivers[_g]));
                    ++_g;
                    object __temp_stmt3 = null;
                    {
                        object __temp_odecl1 = new global::haxe.lang.DynamicObject(new int[] {}, new object[] {}, new int[] { 116192081, 842117339, 1860705976 }, new double[] { ((double)(river.b)), ((double)(river.a)), ((double)(punter)) });
                        __temp_stmt3 = new global::haxe.lang.DynamicObject(new int[] { 1213755260 }, new object[] { __temp_odecl1 }, new int[] {}, new double[] {});
                    }

                    moves.push(new global::search.MoveAndScore(((object)(__temp_stmt3))));
                }
            }

            object __temp_stmt4 = null;

            {
                object __temp_odecl2 = new global::haxe.lang.DynamicObject(new int[] {}, new object[] {}, new int[] { 1860705976 }, new double[] { ((double)(punter)) });
                __temp_stmt4 = new global::haxe.lang.DynamicObject(new int[] { 1246880977 }, new object[] { __temp_odecl2 }, new int[] {}, new double[] {});
            }

            moves.push(new global::search.MoveAndScore(((object)(__temp_stmt4))));
            {
                int _g1 = 0;
                while ((_g1 < moves.length))
                {
                    global::search.MoveAndScore move = ((global::search.MoveAndScore)(moves[_g1]));
                    ++_g1;
                    game.addMove(move.move);
                    move.score = this.evaluter.eval(game);
                    game.undoMove();
                }
            }

            int id = punter;

            moves.sort(new global::search.BeamSearcher_getMove_45__Fun(id));
            return(((global::search.MoveAndScore)(moves[0])).move);
        }
예제 #11
0
 public static void __hx_ctor__BattleMain(global::BattleMain __hx_this, string mapPath)
 {
     unchecked {
         global::haxe.Log.trace.__hx_invoke2_o(default(double), mapPath, default(double), new global::haxe.lang.DynamicObject(new int[] { 302979532, 1547539107, 1648581351 }, new object[] { "new", "BattleMain", "BattleMain.hx" }, new int[] { 1981972957 }, new double[] { ((double)(29)) }));
         global::game.Game           game1    = new global::game.Game();
         object                      map      = new global::haxe.format.JsonParser(((string)(global::sys.io.File.getContent(mapPath)))).parseRec();
         global::eval.Evaluter       evaluter = new global::eval.Evaluter(((global::Array <double>)(global::eval.Evaluter.MS_TABLE)));
         global::search.BeamSearcher sercher  = new global::search.BeamSearcher(0.1, evaluter);
         game1.setupMap(map);
         game1.setupPunters(global::BattleMain.PUNTERS);
         {
             int _g1 = 0;
             int _g  = game1.riverCount;
             while ((_g1 < _g))
             {
                 int    i      = _g1++;
                 int    punter = global::game._PunterId.PunterId_Impl_._new((i % global::BattleMain.PUNTERS));
                 object move   = sercher.getMove(game1, punter);
                 game1.addMove(move);
                 global::haxe.Log.trace.__hx_invoke2_o(default(double), global::haxe.lang.Runtime.concat("move", global::haxe.lang.Runtime.toString(i)), default(double), new global::haxe.lang.DynamicObject(new int[] { 302979532, 1547539107, 1648581351 }, new object[] { "new", "BattleMain", "BattleMain.hx" }, new int[] { 1981972957 }, new double[] { ((double)(42)) }));
             }
         }
     }
 }
예제 #12
0
 public River(global::game.Game game1, int id, int a, int b)
 {
     global::game.River.__hx_ctor_game_River(this, game1, id, a, b);
 }
예제 #13
0
파일: Site.cs 프로젝트: hasipon/icfpc2017
 public Site(global::game.Game game1, int id, double x, double y)
 {
     global::game.Site.__hx_ctor_game_Site(this, game1, id, x, y);
 }
예제 #14
0
파일: Punter.cs 프로젝트: hasipon/icfpc2017
 public Punter(global::game.Game game1, int id)
 {
     global::game.Punter.__hx_ctor_game_Punter(this, game1, id);
 }
예제 #15
0
파일: Punter.cs 프로젝트: hasipon/icfpc2017
 public static void __hx_ctor_game_Punter(global::game.Punter __hx_this, global::game.Game game1, int id)
 {
     __hx_this.game            = game1;
     __hx_this.id              = id;
     __hx_this.accessableSites = new global::haxe.ds.IntMap <object>();
 }