开发者

Game Development & Artificial Intelligence With PHP

开发者 https://www.devze.com 2022-12-13 08:05 出处:网络
A friend of mine told me that it is possible to even create games with PHP. Is that really possible? Can we implement artificial intelligenc开发者_如何学JAVAe using PHP?

A friend of mine told me that it is possible to even create games with PHP.

Is that really possible?

Can we implement artificial intelligenc开发者_如何学JAVAe using PHP?

Looking for your ideas.

Thanks


Yes, PHP is Turing complete, so in theory you can create any kind of application you desire. It doesn't mean you should, though, and there are far more suitable tools out there.


While it is possible to implement Artificial Intelligence and Games in PHP it's not optimal to do so. PHP is designed for effective Server Side web programming and as such isn't the most optimal platform to be developing Artificial Intelligence and Games on.

That said, it also depends on how you define AI, if you mean games that have AI again, it's possible but not optimal.

Programming languages are a way to express a concept, different languages are better at expressing different types of concepts. For PHP it's very good at expressing online server side scripting concepts, however it is less suited to expressing concepts like Video Games compared to more general languages such as C, C++, Java, C#, etc... (There are far more, this is just a shortlist)

If you really want online games you should consider Java which has excellent web integration while providing a better medium for creating games.


I know there was a marked solution, but here's some more links that will be very useful.

http://ann.thwien.de/index.php/Main_Page

http://neuralmesh.com

http://www.tremani.nl/open-source/neural-network

There actually has been more work with AI using PHP than most people realize and it is quite possible. The neuralmesh.com site spoke about a Connect 4 game and how the computer got smarter the more games it played (though they don't provide any kind of live demo of that game, they do have a demo of their system which looks very finished off and nice).

I'm not going to say that PHP is the most efficient language to be doing this in...I would suspect C++ or Java to be much better alternatives if you aren't exactly on board with jumping into PROLOG or LISP, but there's also FANN which is a library for neural networks and has bindings for various languages (including PHP, but it doesn't seem to work with PHP 5.3 and appears to no longer be maintained, but I'm sure it's still great for other languages).

However...I am going to say that it's not a dumb idea to create AI using PHP or some sort of simplistic neural network. The reason being is that the internet really accounts for a lot of our computer usage these days. In fact, most people probably wouldn't have much need for a computer that didn't connect to the internet. So when you realize that and realize that PHP is one of the most popular and easiest to learn and free and all the other benefits....It's a pretty common "go to" language.

It's funny that people like to say how "slow" PHP is, but we've already taken care of that issue. Computers today are much much faster and we can network them. Also, people still think of PHP 4 when they say it's slow. They don't even know about PHP 5.3 or the new features and speed increases. Imagine a distributed database for your neural network in "the cloud." Think of how much of a benefit that is for holding data and even processing it (even if it's less efficient, hardware is cheap). Now think about how fast you can set that up using PHP compared to some other language. Some other language where you'd either pray to find all the libraries needed to even connect to the internet, let alone actually getting the data and then displaying data to the user in such a convenient way as a web browser.

What if you don't want the end user to download and install anything?

Anyway, you get the idea, I'm not going to go on with it...But it's definitely not absurd to think about something like this for PHP.

Again, this also depends on what you're going to do with your "AI" if it's to play a simple Connect 4 game...or Battleship...or chess. Then you train it for a bit (the long processor intensive part) and then you're (mostly) done. So it doesn't really matter what language you're using.


I think php is good for creating browser games because php is meant to run at a server and generating output pages (xml, html, etc.)
If you like to create something else then a game where the logic runs on a webserver it would be more clever and more easy to chose a language that was designed to such things.


A lot has changed in the 6 years since the OP asked this question.

PHP has become much more performant with HHVM and PHP7, and is slowly spreading out from running the back-end of websites to running applications in general.

Ultimately you can create a game or an AI in any programming language, but PHP is becoming a better choice - that doesn't necessarily mean you should use it. If you don't use PHP-GTK (and that project isn't quite production ready) you'll still need to write a front-end in something else, traditionally with PHP that would be HTML and JavaScript. With HTML5, WEBGL and canvas that is a more and more promising possibility, especially for creating multi-player games.

If you build a game in PHP you're certainly embarking on an adventure - there aren't a lot of PHP games out there (with the exception of MUD style text adventures) so be prepared to solve a lot of problems yourself.


Vanthia

PHPRPG/Ph'@ntasy/Ph'@ntom

Legend of the Green Dragon

These are just a few of the PHP games out there. Oh, and I made a project called Magbor (a little in-browser multiplayer game) which is heavy on PHP and JavaScript. So yes, you can see that it is possible.

0

精彩评论

暂无评论...
验证码 换一张
取 消