I’m learning AI, what game could I implement to put it to practice?

I have taken an AI course, and the teacher asked us to implement a game that makes use of one of the AI algorithms. Here is where I need a bit of help:

  • I don’t know to what kind of games each algorithm is applied
  • if you could just give an example of a game or game type and the algorithm it uses, I would appreciate it

I don’t need any coding help, I can manage that (my language of choice is Java). I only need a little help on selecting an algorithm.


In adjunct to Ben’s answer, a good combo is alpha-beta pruning along with a game like connect 4. The heuristic for something like tic-tac-toe is too simple, and for chess, too complex. But connect 4 or a similiar “middle of the road” game can be an excellent place to see how the heuristic makes a big difference in both efficiency and quality, and it’s also complex enough to even get some “niche” heuristics that can win some scenarios over other, generally better heuristics. The rules of connect 4 in particular are simple enough that it’s very easy to come up with your own successful heuristics to see these things in action.

Another common AI to play with is A* for pathfinding, such as unit travel in an RTS or sandbox environment.


Setting “checked” for a checkbox with jQuery

I’d like to do something like this to tick a checkbox using jQuery:




Does such a thing exist?


Modern jQuery

Use .prop():

$('.myCheckbox').prop('checked', true);
$('.myCheckbox').prop('checked', false);


If you’re working with just one element, you can always just access the underlying HTMLInputElement and modify its .checked property:

$('.myCheckbox')[0].checked = true;
$('.myCheckbox')[0].checked = false;

The benefit to using the .prop() and .attr() methods instead of this is that they will operate on all matched elements.

jQuery 1.5.x and below

The .prop() method is not available, so you need to use .attr().

$('.myCheckbox').attr('checked', true);
$('.myCheckbox').attr('checked', false);

Note that this is the approach used by jQuery’s unit tests prior to version 1.6 and is preferable to using $('.myCheckbox').removeAttr('checked'); since the latter will, if the box was initially checked, change the behaviour of a call to .reset() on any form that contains it – a subtle but probably unwelcome behaviour change.

For more context, some incomplete discussion of the changes to the handling of the checked attribute/property in the transition from 1.5.x to 1.6 can be found in the version 1.6 release notes and the Attributes vs. Properties section of the .prop() documentation.


How to wire Interdependent beans in Spring?

I want to declare two beans and instantiate them using Spring dependency injection?

<bean id="sessionFactory" class="SessionFactoryImpl">
 <property name="entityInterceptor" ref="entityInterceptor"/>

<bean id="entityInterceptor" class="EntityInterceptorImpl">
 <property name="sessionFactory" ref="sessionFactory"/>

But Spring throws an exception saying “FactoryBean which is currently in creation returned null from getObject”

Why is inter-dependent bean wiring not working here? Should i specify defferred property binding anywhere?


Unfortunately the way container initialization works in Spring, a bean can only be injected in another bean once it is fully initialized. In your case you have a circular dependency that prevents either bean to be initialized because they depend on each other. To get around this you can implement BeanFactoryAware in one of the beans and obtain the reference to the other bean using beanFactory.getBean(“beanName”).


Seedable JavaScript random number generator

The JavaScript Math.random() function returns a random value between 0 and 1, automatically seeded based on the current time (similar to Java I believe). However, I don’t think there’s any way to set you own seed for it.

How can I make a random number generator that I can provide my own seed value for, so that I can have it produce a repeatable sequence of (pseudo)random numbers?


One option is which is a seedable RC4-based Math.random() drop-in replacement with nice properties.


How do I generate RTF from Java?

I work on a web-based tool where we offer customized prints.

Currently we build an XML structure with Java, feed it to the XMLmind XSL-FO Converter along with customized XSL-FO, which then produces an RTF document.

This works fine on simple layouts, but there’s some problem areas where I’d like greater control, or where I can’t do what I want at all. F.ex: tables in header, footers (e.g., page numbers), columns, having a separate column setup or different page number info on the first page, etc.

Do any of you know of better alternatives, either to XMLmind or to the way we get from data to RTF, i.e., Java-> XML, XML+XSL-> RTF? (The only practical limitation for us is the JVM.)


If you could afford spending some money, you could use Aspose.Words, a professional library for creating Word and RTF documents for Java and .NET.

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..