Beispiel #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)));
                        }
                    }
                }
            }
        }
Beispiel #2
0
 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>();
 }
Beispiel #3
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);
            }
        }
Beispiel #4
0
        public virtual void setupMap(object map)
        {
            unchecked {
                {
                    int _g = 0;
                    global::Array <object> _g1 = ((global::Array <object>)(global::Array <object> .__hx_cast <object>(((global::Array)(global::haxe.lang.Runtime.getField(map, "sites", 2094299916, true))))));
                    while ((_g < _g1.length))
                    {
                        object data = _g1[_g];
                        ++_g;
                        global::game.Site site = new global::game.Site(this, ((int)(global::haxe.lang.Runtime.getField_f(data, "id", 23515, true))), ((!(global::haxe.lang.Null <object> .ofDynamic <double>(global::haxe.lang.Runtime.getField(data, "x", 120, true)).hasValue)) ? (global::Math.rand.NextDouble()) : (((double)(global::haxe.lang.Runtime.toDouble(global::haxe.lang.Runtime.getField(data, "x", 120, true)))))), ((!(global::haxe.lang.Null <object> .ofDynamic <double>(global::haxe.lang.Runtime.getField(data, "y", 121, true)).hasValue)) ? (global::Math.rand.NextDouble()) : (((double)(global::haxe.lang.Runtime.toDouble(global::haxe.lang.Runtime.getField(data, "y", 121, true)))))));
                        ((global::haxe.IMap <int, object>)(this.sites)).@set(site.id, site);
                    }
                }

                {
                    int _g2 = 0;
                    global::Array <int> _g11 = ((global::Array <int>)(global::Array <object> .__hx_cast <int>(((global::Array)(global::haxe.lang.Runtime.getField(map, "mines", 141062784, true))))));
                    while ((_g2 < _g11.length))
                    {
                        int siteId = _g11[_g2];
                        ++_g2;
                        global::game.Site site1 = ((global::game.Site)((((global::haxe.IMap <int, object>)(this.sites)).@get(siteId)).@value));
                        site1.isMine = true;
                        ((global::haxe.IMap <int, object>)(this.mines)).@set(siteId, site1);
                    }
                }

                int i = 0;
                {
                    int _g3 = 0;
                    global::Array <object> _g12 = ((global::Array <object>)(global::Array <object> .__hx_cast <object>(((global::Array)(global::haxe.lang.Runtime.getField(map, "rivers", 1477328871, true))))));
                    while ((_g3 < _g12.length))
                    {
                        object data1 = _g12[_g3];
                        ++_g3;
                        int id = global::game._RiverId.RiverId_Impl_._new(i);
                        global::game.River river = new global::game.River(this, id, ((int)(global::haxe.lang.Runtime.getField_f(data1, "source", 842117339, true))), ((int)(global::haxe.lang.Runtime.getField_f(data1, "target", 116192081, true))));
                        ((global::haxe.ds.IntMap <object>)(global::haxe.ds.IntMap <object> .__hx_cast <object>(((global::haxe.ds.IntMap)(((global::haxe.IMap <int, object>)(this.rivers))))))).@set(id, river);
                        ((global::haxe.IMap <int, object>)(((global::game.Site)((((global::haxe.IMap <int, object>)(this.sites)).@get(river.a)).@value)).rivers)).@set((((river.a == river.a)) ? (river.b) : (river.a)), river);
                        ((global::haxe.IMap <int, object>)(((global::game.Site)((((global::haxe.IMap <int, object>)(this.sites)).@get(river.b)).@value)).rivers)).@set((((river.a == river.b)) ? (river.b) : (river.a)), river);
                        ++i;
                    }
                }

                this.mineCount  = ((global::Array <int>)(global::Array <object> .__hx_cast <int>(((global::Array)(global::haxe.lang.Runtime.getField(map, "mines", 141062784, true)))))).length;
                this.siteCount  = ((global::Array <object>)(global::Array <object> .__hx_cast <object>(((global::Array)(global::haxe.lang.Runtime.getField(map, "sites", 2094299916, true)))))).length;
                this.riverCount = ((global::Array <object>)(global::Array <object> .__hx_cast <object>(((global::Array)(global::haxe.lang.Runtime.getField(map, "rivers", 1477328871, true)))))).length;
                this.maxScore   = 0;
                {
                    object mine = ((global::haxe.IMap <int, object>)(this.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::haxe.IMap <int, int> localScores = new global::haxe.ds.IntMap <int>();
                        ((global::haxe.IMap <int, object>)(this.scoreDictionary)).@set(mine1.id, localScores);
                        global::Array <object>       currentSites = new global::Array <object>(new object[] { mine1 });
                        global::haxe.IMap <int, int> distances    = new global::haxe.ds.IntMap <int>();
                        distances.@set(mine1.id, 0);
                        {
                            int _g13 = 0;
                            int _g4  = this.siteCount;
                            while ((_g13 < _g4))
                            {
                                int i1 = _g13++;
                                global::Array <object> nextSites = new global::Array <object>(new object[] {});
                                {
                                    int _g21 = 0;
                                    while ((_g21 < currentSites.length))
                                    {
                                        global::game.Site site2 = ((global::game.Site)(currentSites[_g21]));
                                        ++_g21;
                                        {
                                            object river1 = ((global::haxe.IMap <int, object>)(site2.rivers)).iterator();
                                            while (global::haxe.lang.Runtime.toBool(global::haxe.lang.Runtime.callField(river1, "hasNext", 407283053, null)))
                                            {
                                                global::game.River river2 = ((global::game.River)(global::haxe.lang.Runtime.callField(river1, "next", 1224901875, null)));
                                                int another = (((river2.a == site2.id)) ? (river2.b) : (river2.a));
                                                if (!(distances.exists(another)))
                                                {
                                                    {
                                                        int v = (i1 + 1);
                                                        distances.@set(another, v);
                                                    }

                                                    nextSites.push(((global::game.Site)((((global::haxe.IMap <int, object>)(this.sites)).@get(another)).@value)));
                                                }
                                            }
                                        }
                                    }
                                }

                                currentSites = nextSites;
                            }
                        }

                        {
                            object siteId1 = distances.keys();
                            while (global::haxe.lang.Runtime.toBool(global::haxe.lang.Runtime.callField(siteId1, "hasNext", 407283053, null)))
                            {
                                int siteId2 = ((int)(global::haxe.lang.Runtime.toInt(global::haxe.lang.Runtime.callField(siteId1, "next", 1224901875, null))));
                                global::haxe.lang.Null <int> distance = ((global::haxe.lang.Null <int>)(distances.@get(siteId2)));
                                int score = ((distance).@value * (distance).@value);
                                localScores.@set(siteId2, score);
                                this.maxScore += score;
                            }
                        }
                    }
                }
            }
        }