Making games in R- Nara and eventloop Game Changers

[This article was first published on Data Science Tutorials, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The post Making games in R- Nara and eventloop Game Changers appeared first on Data Science Tutorials

Making games in R- Nara and eventloop Game Changers, It’s possible that you are aware of the existence of the R programming language.

This is a fairly understandable language that is mostly utilized by data scientists as well as more conventional statisticians.

The majority of the charts you see on our website were created using R.

Data Science Challenges in R Programming Language (

R is now able to render graphics very quickly thanks to the introduction of a new package called Nara

Though don’t expect it to produce graphics at a pace of thousands of frames per second, Nara can easily make vector graphics at a rate of above 30 frames per second in contrast to libraries like ggplot2, which take several seconds to generate.

Two examples of what the package can achieve have been made available by the creator: a version of Pacman that is not playable and a port of Another World to R.


What specifically does “Nara” bring to the table that R hasn’t already backed up?

An off-screen rendering buffer is Nara. To avoid memory allocations, it makes use of in-place operations (which are typically slow in R).

All dimensions are rounded to integer values before rendering, and the emphasis is on producing discrete pixels (without anti-aliasing).

A Side-by-Side Boxplot in R: How to Do It – Data Science Tutorials

The issue with graphics operations in R is that common data structures don’t match up well with those employed by the graphics hardware.

For instance, a matrix in R is structured from columns to rows, whereas graphics devices often require matrices to be ordered from row to column.

Another difficulty is that R normally uses hexadecimal numbers to encode color. Again, graphics hardware prefers to store RGB values in various values.

Drawing on a screen moves considerably more slowly than it should because of all these conversions between R and graphics hardware. Herein is Nara’s role.

The nativeRaster datatype, which is used by Nara, is an integer matrix with each value representing the RGBA color values of a single pixel. The data is encoded in four channels (RGBA) with eight bits each.

How to Implement the Sklearn Predict Approach? (

It is faster because this data format allows for a more direct route to render pixels on the screen.

Another World.

Adding to the World Having quick graphics hardware is not enough to run another world in R. A complete port in the R language is what we’re referring to.

It is possible to leverage shortcuts and program some functions in C for increased speed. To enable real-time input in-game, the port also needed the additional package eventloop.

 This was another necessary building piece for creating a game because R is not normally used for that kind of interaction. Not to mention sound support as well.

How to Use Mutate function in R – Data Science Tutorials

R was not intended to be used in this manner, so seeing it used in this way is very impressive. Is there really a purpose, though?

Making games in R?

This is a game-changer because real-time graphics with R were essentially unachievable until now.

Of course, you won’t be able to create your next AAA title or even a visually appealing indie title using it, but moving forward, this could prove to be an intriguing choice for prototyping or testing concepts.

Since R is not the quickest language available for this kind of work and doesn’t integrate with many system libraries, controller input, or even adequate GPU acceleration, I don’t think we will get beyond game prototypes anytime soon.

Furthermore, the distribution of binaries is a serious issue that has to be resolved because there is currently no good way to package an R program into an executable.

Best online course for R programming – Data Science Tutorials

However, given they are ported, this does allow emulators to run within R. When it comes to game prototypes, the incorporation of statistical and machine learning technologies within games is another encouraging development.

It would be simple to implement sophisticated regression or classification models in the setting of a game even though other languages lack such built-in features.

You may see an action game that uses PCA to analyze your behavior patterns before presenting you with particular foes designed to take advantage of your found vulnerabilities.

The post Making games in R- Nara and eventloop Game Changers appeared first on Data Science Tutorials

To leave a comment for the author, please follow the link and comment on their blog: Data Science Tutorials. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)