Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 28 Jun 2000
Offline Last Active Yesterday, 01:47 PM

#5273052 AI trouble sdl 1.2

Posted by Wyrframe on 28 January 2016 - 02:59 PM

What you need is a simple, generic pathfinder which you can feed each ghost. The pathfinder gets fed a ghost's current position, current direction of travel, and the position of its "target". That target is very clearly defined in each ghost's Scatter and Chase states; specific map coordinates, or locations relative to PacMan (including +0,+0 relative to PacMan).


The pathfinder has to respect the ghost's movement rules; they never reverse their direction, they only turn left, turn right, or carry on straight.


You only need to query the pathfinder for a given ghost when they reach a decision point. Once they're on a lane headed towards the next intersection, they can't change their mind anyways, so just let them carry on straight until they can choose to turn again.


Post some of your current ghost AI code, and we may be able to give you specific, pointed examples of how to improve what you're doing already.

#5272998 AI trouble sdl 1.2

Posted by Wyrframe on 28 January 2016 - 09:49 AM


#5272023 Risks Of Using Computer As Webhost?

Posted by Wyrframe on 20 January 2016 - 09:57 AM

While we're making suggestions of configure-it-yourself server hosting (as opposed to HTTP-only hosting services), OVH (based in France and in Canada, near Montréal, just inches north of the US border) offer services such as this. A large variety of O/S available. They give you a 100 Mbit internet connection and no transfer limits. Does not come with DNS hosting (for that, I suggest No-Ip), but is pretty hard to beat. Especially if you're in the States, considering the CAD$ current exchange rate.


Bear in mind their VPS SSD line does not guarantee uptime or SLA, as they reserve the right to "pause" the VM without notice, in order to move it between physical hosts whenever they need to reorganize their datacenter. You have to go up to their VPS Cloud line of products to get a four-nines SLA (<= 52 hours of downtime per year).

#5271564 Box2D in LibGDX - Throwing body based on swipe angle.

Posted by Wyrframe on 17 January 2016 - 11:17 AM

Well, you're applying a constant vertical force of 30, and a lateral force of (mouse.x - [ball center]), in an attempt to fling the ball towards the mouse. A few questions:

* Does `mouse`, wherever it is, get updated before the fling() method is called? If not, this method will not have the expected results.


* Is `mouse` in world-space coordinates, or screen-space? If the latter, this method will not have the expected results.


* Why aren't you normalizing and then scaling the vector (velocityX,velocityY), since those are exactly the data you're trying to calculate based on `mouse`? See GestureListener.fling(float,float,int).

#5271302 Play my software through a browser

Posted by Wyrframe on 15 January 2016 - 11:21 AM

You're going to need to find a local expert. Perhaps someone in the company you just bought. There is no turnkey solution, and even if someone's willing to help you with something this complex for free, you're going to get what you pay for.

#5269640 Thread communication without mutexs

Posted by Wyrframe on 06 January 2016 - 10:08 AM

The "quit" and "done" variables not being behind synchronization controls is just fine, so long as they are separate locations in memory (don't be clever and try to make them parts of a bitfield). Do declare them as 'volatile', however, to make sure that the threads actually read the relevant part of memory each time they access those variables.


I'm assuming the worker thread is provided a location to write its results (or provided a location to write a pointer to the results), and the main thread picks it up from there. So long as the main thread doesn't attempt to read that until the "done" flag is set (by the worker), that should be fine. But this is still data being shared; you're just protecting it with a protocol, instead of a locking structure.


Here once lay some out-of-date hogwash. Ignore it.

#5269055 Raytracer is not working

Posted by Wyrframe on 03 January 2016 - 02:31 PM

That random function will take a cube of uniformly distributed points, which are then projected onto the surface of a sphere by normalizing their vectors. It should be no surprise it doesn't produce a uniform sphere. :)


To get spherically-uniform points, as described here, and assuming your uniform(double low, double high, Random rng) function is correct...

Vector3D getRandomVectorInSphere(Random rng, Vector3D v){
	double lon = uniform(0.0, Math.PI * 2.0, rng);
	double z   = uniform(-1.0, +1.0, rng);
	double lat = Math.acos(z);

	double x = Math.cos(lon) * Math.sin(lat);
	double y = Math.sin(lon) * Math.sin(lat);

	return new Vector3D(x,y,z);

To get a uniform hemisphere in +Z from a uniform sphere, let the Z coordinate be abs(z) instead. However, that's an axis- and origin-aligned hemisphere. I infer from the fact you're passing in a vector V to your getRandomVectorInHemisphere() function, V is the normal or reflection vector you want the hemisphere aligned to?


In that case, what you want to do is either generate your hemisphere by combining vector products in i,j,k-space instead of X,Y,Z, or use your normal vector to generate a rotation matrix which you can then apply to the random-hemisphere vector. Let me know if researching either of those doesn't lead you to anything useful.

#5268871 Raytracer is not working

Posted by Wyrframe on 02 January 2016 - 02:17 PM

Try an orthographic projection over (-1,-1,z) through (+1,+1,z), instead of a perspective projection. The snippet below should change your existing ray calculations to that effect. That should produce an image with a circle in the center. If it doesn't... your sphere intersection or your intersection-to-rendering pipeline probably isn't working right.

Vector3D direction = new Vector3D(rayX, rayY, -1).normalize();
Vector3D position  = new Vector3D(direction.x, direction.y, +1);
Ray r = new Ray(position, direction);

#5268256 Raytracer is not working

Posted by Wyrframe on 28 December 2015 - 10:02 PM

Fiddling with your equations a bit, I see the problem. Let's break it down a bit.

// For W=H=250, pixelX/Y will be 0 to 249 inclusive, and that's why the +0.5; to center each
// ray on a pixel, instead of casting through the top-left corner of each pixel.
double pixelX, pixelY; // In the range [0,w/h), respectively.
double w, h, fov;      // Also inputs; FOV is in Radians (for 45°, that's PI*0.25).

// Calculate common terms.
double aspect = w / h;
double fovFactor = TAN(fov*0.5);

// Turn each [0,w/h) pixel coordinate into a [-1,+1] proportional term,
// which will pass through the middle of each cell in a WxH axis-centered
// square grid of cells, at any given fixed distance from the camera.
double rayX = (2.0 * (pixelX+0.5) / w) - 1.0;
double rayY = (2.0 * (pixelY+0.5) / h) - 1.0;

// Turn each proportional term into a ray component, correcting for the
// desired FOV and the actual aspect ratio of the grid.
rayX *= fovFactor * aspect;
rayY *= fovFactor;  // If you must use pixelY=0 as the bottom of your screen, negate rayY here.

// This generated vector is in camera space, so make sure to either transform your scene
// into camera space, or transform the ray into scene space, before you cast it!
Vector3D direction = new Vector3D(rayX, rayY, -1).normalize();

#5268212 Raytracer is not working

Posted by Wyrframe on 28 December 2015 - 12:01 PM

What's the range that `x` and `y` sweep?


The 2*(x-0.5) construct turns x values from 0..1 into -1..+1... but here you appear to be doing 2*(x+0.5) which will turn an `x` in -1..0 into a value in the -1..+1 range.

#5266665 Proposal: "Tasks" in the Epoch programming language

Posted by Wyrframe on 16 December 2015 - 10:16 AM

The usual distinction is that duck typing cares purely about names, whereas structural typing purely cares about types.

I know we're all a little off-topic here, but... have you got any literature for that? I've never heard of that as being the distinction, never mind being true on either count... and at a glance, that definition of structurally equivalent sounds like it would only make sense if the only language-supported structure is the tuple (where the position is the name).


Back on the topic, however... Apoch;

entrypoint :
    task avg = Averager()
    avg => DataPoint(42)
    avg => DataPoint(666)
    print(avg => GetAverage())

In light of the discussion of types, then... I don't understand this example. How is the 'task' type annotated to be aware of the actual functions callable on an instance of Averager, unless `task` is kinda like `auto`, or unless you're erasing the type so that future calls on 'avg' must be purely dynamic runtime dispatch?

#5266049 Android Game C++ SFML or Android Studios Or C# Monogame ?

Posted by Wyrframe on 12 December 2015 - 12:46 PM

At your experience level, I think you should begin with something a bit more within your grasp. It may sound condescending to say "if this if your first Android project, it should be Pong"... but most browser-based games are actually pretty complex things. You should either start with a simpler Android project, or a simpler multiplayer game project.


On the plus side, there's a lot of people who got to these wants before you. Here is a list of open-source browser-based game projects you can study:



That's not going to help you with finding a good toolchain and library to use for Android development, but it should help dip your toes into the scale of the thing you're asking about.

#5265776 Redis Scaling with Monster AOE

Posted by Wyrframe on 10 December 2015 - 04:21 PM

Looking more into Redis pub/sub... I think I follow you. You're not using it for persistence, you're using it for inter-process communication between NodeJS processes. That sounds reasonable, so long as you don't mind the low per-node scalability that using Node as your server runtime is going to offer compared to a native-compiled runtime (C/++ for example).


With your memory limit and Node's single-threaded model in mind... I'd personally set up several separate daemons. One class of daemons would be client I/O groups. You spawn one or more NodeJS processes whose job is to accept connections from up to N clients each, parse client commands, and feed those commands out as Redis publishes. These listen for published information relevant to their player and serialize it out to the client. The second class of daemons would be processor queues. You spawn a bunch of these and delegate to them any incoming input events (from client I/O daemons) and world-change events (from other processor daemons). These would classify and validate each event, take appropriate action against the game world datamodel, and then publish any new events that need responding to for those changes.


The separation of these layers makes you initially strongly dependent on serialize/deserialize, and on Redis performance for dealing with the event transfer, but having those three layers separated (client I/O, event transfer, processing) means you can bugfix, update, and even wholesale replace each of the three layers separately. You can start re-implementing your processor daemons in a faster language without even touching the client or I/O layer. They could all live on separate servers without any code modification. If serialization becomes a big problem, you can replace the event transfer mechanism with your own shared memory arrangement to move data directly from I/O processes to processing processes.

#5265746 Redis Scaling with Monster AOE

Posted by Wyrframe on 10 December 2015 - 10:04 AM

From what I can tell with 3 minutes of reading, Redis Publish/Subscribe is a means to let DB clients listen for change sets published on certain channels. This is a feature you might use in your game-server's imlementation to keep on top of changes to the world which are relevant (i.e. needs sending to) connected clients; it is not something you should ever expose to the game client.


Independent of your server database, your server needs to send information to your cilents such as:

 * Mob X of description D is Relevant (includes all info like type, skin, position, AI state, current target) - indicates a mob has entered the client's data frustrum

 * Mob X is Irrelevant - indicates a mob is gone, whether it moved out of range, the client moved out of range, its lootable body has dissolved, etc

 * Mob X Updated to D - new information about the mob. Generally, include all the high-priority fields like position, AI state, current target... and then generally include all fields that have changed in the past couple seconds, regardless of whether they've changed since the last Mob-Update packet sent to this particular client. Keeping precise monitor-change lists can get really expensive.

 * And chat-channel messages, response messages (as in responses to queries, such as "what's on Lootable Mob X I can take?"), cutscene or dialog or conversation messages, etc.


So, you need to figure out how to encode each message, how to gather that information from the server data and relay it to clients, and how to fill in the gaps at the client's end so it looks like a smooth, cohesive experience.


Generally, individual mobs never actually hit the disk server side; each server keeps the mobs within its frustrum in memory only. So, yes, they'd be created, updated, monitored, live, and die in memory structures, but not in a clusterable database like Redis. If the server is shut down, all clients are thrown out anyways; you can re-spawn the mobs when the server comes back up. Obviously unique mobs which never respawn, especially ones which need to be in only one place at a time, are an exception.

#5264121 Best route to take for automatically going through a program

Posted by Wyrframe on 29 November 2015 - 11:10 AM

SikuliX is a scriptable system that lets you automate desktop interaction using image-recognition and OCR, so you can cope with unpredictable positions of windows and GUI elements.




It's ideal for automating simple GUI processes when AutoHotKey doesn't suffice.