I had to get in touch with Mathworks viz a viz a problem concerning the passing of a Java object to various workers of the parallel computing toolbox of Matlab. I got the following answer from the support. I am sure someone is going to encounter the same problem and might need help. Please peruse.
Hello Muhammad Adil,
I am Preethi and I am writing in reference to your Technical Support Case #03167864 regarding ‘Struct contents reference from a non-struct array object.’.
I understand that you are seeing an error when trying to call a function of a serialized Java Object in parfor loop
One of the possible reasons would be that the Java class is added in the dynamic java classpath. The workers are not able to access the dynamic java classpath since it is specific to that session of MATLAB, and all the workers run on different MATLAB processes. Use one of the following two workarounds to make this work:
This will make sure that all MATLAB processes will have access to the same java class path.
2) The “javaaddpath” function to add entries to the dynamic Java class path can be executed on all the workers using the “pctRunOnAll” command as follows:
>pctRunOnAll javaaddpath(‘path’) %Replace ‘path’ with the appropriate path
Please make sure that the parallel pool is running before running this command.
I believe this will help in resolving the issue you are facing. I am thus marking this case as closed for now. If the issue persists, please feel free to reply to this email and I will be happy to reopen the case and help you further.
Please preserve the Reference ID in further correspondence on this query. This allows our systems to automatically associate your reply to the appropriate Case.
Sincerely,
Preethi Ayyamperumal
MathWorks Technical Support
I am facing a problem of implementing a board game. In this, a smart agent is expected to raise havoc on the board while exploring it. I was thinking that if the agent was implemented as an object, it would make life a lot easier from the point of view of implementing the game.
Both Matlab and Octave allow object-oriented scripting. An object can have its own fields and methods. The way it can be accomplished is slightly different for each of these languages. In Matlab, you can create a class and define its methods in the same file that you used to create the class. In Octave, you have to create a folder for a class. You put all the methods for that class in that folder as m-files.
I am currently reading about ways to develop board games in Matlab. I will be really pleased to be able to develop other kinds of games as well. Here on this page, I am just throwing the links and articles that I find useful. To begin with here is a nice thread on quora. More link as follows:
Worked with a partner to create a Lunar Lander game using MATLAB. The object of the game is to successfully land the ship onto one of the platforms without crashing into any obstacles or running out of fuel. The force of gravity constantly acts on the lander, requiring use of the ships thrust to maneuver.
Yet another game in Matlab: Risk. For those of you who are familiar.
Given two positive integer inputs, a (attacker army units) and d (defender army units) return the probablity of victory (from 0.000 to 1.000) to +- 0.02 accuracy. The rules are given below for those unfamiliar with the game. In the board game RISK battles are determined by the conflict of armies, namely the attacking army and the defending army.
Here is a nice article about the implementation of minesweeper in Matlab. It could be really useful for understanding how to develop a game board in Matlab.
The motivation for this project came from an old desire to create a game that actually works. MatLab has provided a new outlet to attempt to reach this goal. I choose minesweeper because it presented an obvious opprotunity to use matrices for which MatLab is designed.
Ability to draw voxels (cubes, cuboids) could be of some value, as it was showcased on a gaming site and is available through Mathworks.
File exchange, MATLAB Answers, newsgroup access, Links, and Blogs for the MATLAB & Simulink user community
This tutorial on youtube about creating GUIs in Matlab with GUIDE could be useful. Review this as you listen to a nice song. Create a simple game in matlab gui Part1
This is a nice tutorial and contains links and videos for famous games implemented in Matlab.
I have recently been looking into how to make very advanced and beautiful GUIs in Matlab. The issue with this is that in Matlab, GUIs seem to be somehow limited compared to other languages. Historically, Matlab was supposed to be a numerical plate-form to quickly put together new ideas for computation.
Following is somebody’s website who has implemented numerous board games in Matlab. This can be really good to understand board development in Matlab.
This page contains my library of MATLAB m-files for a simple game and everything else that I make just for fun. All of these m-files are free and you may use or modify them as you like. To download the m-files, simply click the link on each m-file name and a pop-up window will appear, allowing…
I also wanted to list a few games that are implemented specifically in Octave, as many people do not have access to Matlab or they don’t like it. Here is an implementation of tic-tac-toe in Octave. This could be nice to understand how graphics are rendered in Octave.
The Game of Life is a simple cellular automaton invented by mathematician John Conway. The Game of Life consists of a two dimensional grid of cells. Each cell can be “live” or “dead”, often represented mathematically by 1 and 0.
This sounds like a really nice book that was written with the intention of teaching game programming with Matlab.
Matrices, Vectors, and 3D Math provides a resource to learn standard topics in Linear Algebra and
Here is a nice tanks game called Staker that is showcased on Mathworks. It is written in Matlab. It could be helpful in understanding how Matlab renders graphics.
Description Staker is a 3-D artillery warfare game that was inspired by Tank Wars and Scorched Earth, BASIC games I played many years ago. This is just a beta version, so it doesn’t have everything in it that I would like. For instance, there is only one type of terrain to battle on.
Here is another nice tanks game that uses graphics.
Chess Master is a fully-functional chess graphical user interface (GUI) for MATLAB. Features: 1. Easily connect to any UCI-compatible external chess engine. I recommend Stockfish (see below for *easy* installation instructions!) 2. Read/write games in PGN format3. Board editor GUI to easily create/explore custom positions4. Move list GUI to navigate through games5.
This is a very nice piece of code that shows you how to draw cellular automata in Matlab/Octave.
Let’s say that you have a set of images that you want to tile using imshow() and subplot() in a MATLAB figure. By default, both functions add a padded space around the images to separate them, as this example shows: Result: However, what if you want to tile the images without any space between them?
The second edition of the book, Artificial Intelligence for Games, by Ian Millington and John Funge can be found here.
Artificial Intelligence for Games [Ian Millington, John Funge] on Amazon.com. *FREE* shipping on qualifying offers. Creating robust artificial intelligence is one of the greatest challenges for game developers, yet the commercial success of a game is often dependent upon the quality of the AI. In this book
This post contains links to resources that can be useful for connecting to a HTTP server through Matlab. The links posted below particularly correspond to the urlread() function of Matlab.
collapse all Download the HTML for the page on the MATLAB ® Central File Exchange that lists submissions related to urlread. fullURL = [‘http://www.mathworks.com/matlabcentral/fileexchange’ … ‘?term=urlread’]; str = urlread(fullURL); urlread reads from the specified URL and downloads the HTML content to the string str.
Here is a link to its variant, urlread2(), which adds extra functionality to the original urlread(). urlread2 makes extensive use of Java’s apis for http client-server connections. The java source files can also be downloaded from the following link for urlread2.
Version 1.1 Replacement for urlread. Example functions in the urlread2 file show how to make equivalent calls as are made in urlread. Helper functions can be written (some provided) to provide additional functionality without always needing to modify the urlread2 code.
Here is documentation that describes the functionality of urlread2().
I would like to welcome guest blogger Jim Hokanson. Today, Jim will explain some of the limitations that at one time or another many of us have encountered with Matlab’s built-in urlread function. More importantly, Jim has spent a lot of time in creating an expanded-capabilities Matlab function, which he explains below.
TORCS (The Open Racing Car Simulator) is possibly the most well known simulator for simulating racing cars. It is written in C++. It is a 3D car racing simulator. It is also used by the simulated car racing competition, hosted annually by GECCO.
This is CBBOC’s inaugural year. It’s designed to provide the GECCO community with detailed performance comparisons of a wide variety of meta-heuristics and hyper-heuristics on combinatorial problems, where the real-world problems which induce combinatorial problems have been categorized into those with no training time (good fit for out-of-the-box algorithms such as the Parameter-less Population Pyramid), those with short training time (good fit for typical evolutionary algorithms), and those with long training time (good fit for hyper-heuristics).
The TORCS simulator also has an interface for Matlab and Simulink. This means that controllers can be developed for TORCS using Matlab. Using Matlab simply means that the whole hassle of interfacing with TORCS should become a lot easier. The source code is present at GitHub.
TORCS, The Open Racing Car Simulator, is a car racing simulation, which allows you to drive in races against opponents simulated by the computer. You can also develop your own computer-controlled driver (also called a robot) in C or C++. TORCS is GPL (version 2 or later).
The following video shows how TORCS works on a user’s desktop.