Search in sources :

Example 1 with GameUI

use of org.drools.games.wumpus.view.GameUI in project drools by kiegroup.

the class WumpusWorldMain method init.

public void init(final KieContainer kc, boolean exitOnClose) {
    final KieSession serverKsession = kc.newKieSession("WumpusMainKS");
    final KieSession clientKsession = kc.newKieSession("WumpusClientKS");
    serverKsession.getChannels().put("sensors", new Channel() {

        public void send(Object object) {
            clientKsession.insert(object);
            clientKsession.fireAllRules();
        }
    });
    clientKsession.getChannels().put("commands", new Channel() {

        public void send(Object object) {
            serverKsession.insert(object);
            serverKsession.fireAllRules();
        }
    });
    WumpusWorldConfiguration wumpusWorldConfiguration = new WumpusWorldConfiguration();
    wumpusWorldConfiguration.setExitOnClose(exitOnClose);
    serverKsession.setGlobal("wumpusWorldConfiguration", wumpusWorldConfiguration);
    serverKsession.setGlobal("randomInteger", new java.util.Random());
    GameUI gameUI = new GameUI(serverKsession, wumpusWorldConfiguration);
    serverKsession.insert(gameUI);
    serverKsession.insert(gameUI.getGameView());
    new Thread(new Runnable() {

        public void run() {
            serverKsession.fireUntilHalt();
        }
    }).start();
    new Thread(new Runnable() {

        public void run() {
            clientKsession.fireUntilHalt();
        }
    }).start();
}
Also used : GameUI(org.drools.games.wumpus.view.GameUI) Channel(org.kie.api.runtime.Channel) KieSession(org.kie.api.runtime.KieSession)

Aggregations

GameUI (org.drools.games.wumpus.view.GameUI)1 Channel (org.kie.api.runtime.Channel)1 KieSession (org.kie.api.runtime.KieSession)1