Ejemplo n.º 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)));
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public virtual global::Array <object> getLivingRivers()
        {
            global::Array <object> _g = new global::Array <object>(new object[] {});

            {
                object river = ((object)(new global::haxe.ds._IntMap.IntMapValueIterator <object>(((global::haxe.ds.IntMap <object>)(global::haxe.ds.IntMap <object> .__hx_cast <object>(((global::haxe.ds.IntMap)(((global::haxe.IMap <int, object>)(this.rivers))))))))));
                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)));
                    if ((river1.owner == global::game._PunterId.PunterId_Impl_.NotFound))
                    {
                        _g.push(river1);
                    }
                }
            }

            return(_g);
        }
Ejemplo n.º 5
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;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
 public virtual void claim(object move)
 {
     global::game.River river = ((global::game.River)((((global::haxe.IMap <int, object>)(((global::game.Site)((((global::haxe.IMap <int, object>)(this.sites)).@get(((int)(global::haxe.lang.Runtime.getField_f(move, "source", 842117339, true))))).@value)).rivers)).@get(((int)(global::haxe.lang.Runtime.getField_f(move, "target", 116192081, true))))).@value));
     river.owner = ((int)(global::haxe.lang.Runtime.getField_f(move, "punter", 1860705976, true)));
 }
Ejemplo n.º 7
0
 public virtual void undoClaim(object move)
 {
     global::game.River river = ((global::game.River)((((global::haxe.IMap <int, object>)(((global::game.Site)((((global::haxe.IMap <int, object>)(this.sites)).@get(((int)(global::haxe.lang.Runtime.getField_f(move, "source", 842117339, true))))).@value)).rivers)).@get(((int)(global::haxe.lang.Runtime.getField_f(move, "target", 116192081, true))))).@value));
     river.owner = global::game._PunterId.PunterId_Impl_.NotFound;
 }