diff --git a/README.md b/README.md index fcf3e34..a03c806 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ # Naledi ya Africa -**Naledi ya Africa** (*Star of Africa* in seTswana) is a survival game set in +Naledi ya Africa (*Star of Africa* in seTswana) is a survival game set in Africa. It offers networked multiplayer with an ncurses user interface. ---- - ## Running To compile Naledi ya Africa, you need a Common Lisp implementation (SBCL is diff --git a/README.md b/README.md index fcf3e34..a03c806 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ # Naledi ya Africa -**Naledi ya Africa** (*Star of Africa* in seTswana) is a survival game set in +Naledi ya Africa (*Star of Africa* in seTswana) is a survival game set in Africa. It offers networked multiplayer with an ncurses user interface. ---- - ## Running To compile Naledi ya Africa, you need a Common Lisp implementation (SBCL is diff --git a/animals.lisp b/animals.lisp index 3e0cabd..0406c30 100644 --- a/animals.lisp +++ b/animals.lisp @@ -8,6 +8,19 @@ ;;;; (c) 2018 Daniel Vedder, MIT license ;;;; +(defmethod random-move ((a animal)) + (do* ((dir (random-elt *directions*) (random-elt *directions*)) + (next-patch (patch-in-dir (.x a) (.y a) dir) + (patch-in-dir (.x a) (.y a) dir)) + (ttl 10 (1- ttl))) + ((zerop ttl) NIL) + (when (and next-patch (null (patch-occupant next-patch))) + (setf (patch-occupant (coord (.x a) (.y a))) NIL) + (setf (.x a) (first (patch-pos next-patch)) + (.y a) (second (patch-pos next-patch))) + (setf (patch-occupant next-patch) a) + (return-from random-move)))) + ;;XXX bird species? ;;XXX water species? ;;XXX small mammals -> hills diff --git a/README.md b/README.md index fcf3e34..a03c806 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ # Naledi ya Africa -**Naledi ya Africa** (*Star of Africa* in seTswana) is a survival game set in +Naledi ya Africa (*Star of Africa* in seTswana) is a survival game set in Africa. It offers networked multiplayer with an ncurses user interface. ---- - ## Running To compile Naledi ya Africa, you need a Common Lisp implementation (SBCL is diff --git a/animals.lisp b/animals.lisp index 3e0cabd..0406c30 100644 --- a/animals.lisp +++ b/animals.lisp @@ -8,6 +8,19 @@ ;;;; (c) 2018 Daniel Vedder, MIT license ;;;; +(defmethod random-move ((a animal)) + (do* ((dir (random-elt *directions*) (random-elt *directions*)) + (next-patch (patch-in-dir (.x a) (.y a) dir) + (patch-in-dir (.x a) (.y a) dir)) + (ttl 10 (1- ttl))) + ((zerop ttl) NIL) + (when (and next-patch (null (patch-occupant next-patch))) + (setf (patch-occupant (coord (.x a) (.y a))) NIL) + (setf (.x a) (first (patch-pos next-patch)) + (.y a) (second (patch-pos next-patch))) + (setf (patch-occupant next-patch) a) + (return-from random-move)))) + ;;XXX bird species? ;;XXX water species? ;;XXX small mammals -> hills diff --git a/biomes.lisp b/biomes.lisp index 491bf48..74181d8 100644 --- a/biomes.lisp +++ b/biomes.lisp @@ -24,7 +24,7 @@ :ground "leaf litter and small shrubs" :char #\. :col ':green :features '((miombo 10) (acacia 15) - (warthog 400) (impala 800) + (warthog 500) (impala 800) (elephant 1000) (leopard 3200))) ;TODO (new-biome stream diff --git a/README.md b/README.md index fcf3e34..a03c806 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ # Naledi ya Africa -**Naledi ya Africa** (*Star of Africa* in seTswana) is a survival game set in +Naledi ya Africa (*Star of Africa* in seTswana) is a survival game set in Africa. It offers networked multiplayer with an ncurses user interface. ---- - ## Running To compile Naledi ya Africa, you need a Common Lisp implementation (SBCL is diff --git a/animals.lisp b/animals.lisp index 3e0cabd..0406c30 100644 --- a/animals.lisp +++ b/animals.lisp @@ -8,6 +8,19 @@ ;;;; (c) 2018 Daniel Vedder, MIT license ;;;; +(defmethod random-move ((a animal)) + (do* ((dir (random-elt *directions*) (random-elt *directions*)) + (next-patch (patch-in-dir (.x a) (.y a) dir) + (patch-in-dir (.x a) (.y a) dir)) + (ttl 10 (1- ttl))) + ((zerop ttl) NIL) + (when (and next-patch (null (patch-occupant next-patch))) + (setf (patch-occupant (coord (.x a) (.y a))) NIL) + (setf (.x a) (first (patch-pos next-patch)) + (.y a) (second (patch-pos next-patch))) + (setf (patch-occupant next-patch) a) + (return-from random-move)))) + ;;XXX bird species? ;;XXX water species? ;;XXX small mammals -> hills diff --git a/biomes.lisp b/biomes.lisp index 491bf48..74181d8 100644 --- a/biomes.lisp +++ b/biomes.lisp @@ -24,7 +24,7 @@ :ground "leaf litter and small shrubs" :char #\. :col ':green :features '((miombo 10) (acacia 15) - (warthog 400) (impala 800) + (warthog 500) (impala 800) (elephant 1000) (leopard 3200))) ;TODO (new-biome stream diff --git a/classes.lisp b/classes.lisp index 2a694eb..5d590b4 100644 --- a/classes.lisp +++ b/classes.lisp @@ -15,6 +15,8 @@ (weight :accessor .weight :initarg :weight :initform 0) (movable :reader movablep :initarg :movable :initform T) ;;XXX not sure yet how I'm going to use the actions + (update :accessor .update :initarg :update + :initform #'(lambda () NIL)) (action :accessor .action :initarg :action :initform #'(lambda () NIL)))) @@ -32,6 +34,8 @@ ;; A landscape feature such as a rock, a tree, or an animal. ((symbol-char :reader .char :initarg :char :initform NIL) (symbol-color :reader .color :initarg :color :initform NIL) + (x-pos :accessor .x :initarg :x :initform 0) + (y-pos :accessor .y :initarg :y :initform 0) ;;XXX is there a way of setting a superclass variable for all ;; subclass instances? (movable :reader movablep :initarg :movable :initform NIL))) @@ -60,6 +64,7 @@ (aggression :accessor .aggression :initarg :aggression :initform 0) (group-size :reader .group-size :initarg :group-size :initform 1) (habitat :reader .habitat :initarg :habitat :initform '()) + (update :accessor .update :initarg :update :initform #'random-move) (destroy-with :reader destructors :initarg :destroy-with :initform '(weapon)))) diff --git a/README.md b/README.md index fcf3e34..a03c806 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ # Naledi ya Africa -**Naledi ya Africa** (*Star of Africa* in seTswana) is a survival game set in +Naledi ya Africa (*Star of Africa* in seTswana) is a survival game set in Africa. It offers networked multiplayer with an ncurses user interface. ---- - ## Running To compile Naledi ya Africa, you need a Common Lisp implementation (SBCL is diff --git a/animals.lisp b/animals.lisp index 3e0cabd..0406c30 100644 --- a/animals.lisp +++ b/animals.lisp @@ -8,6 +8,19 @@ ;;;; (c) 2018 Daniel Vedder, MIT license ;;;; +(defmethod random-move ((a animal)) + (do* ((dir (random-elt *directions*) (random-elt *directions*)) + (next-patch (patch-in-dir (.x a) (.y a) dir) + (patch-in-dir (.x a) (.y a) dir)) + (ttl 10 (1- ttl))) + ((zerop ttl) NIL) + (when (and next-patch (null (patch-occupant next-patch))) + (setf (patch-occupant (coord (.x a) (.y a))) NIL) + (setf (.x a) (first (patch-pos next-patch)) + (.y a) (second (patch-pos next-patch))) + (setf (patch-occupant next-patch) a) + (return-from random-move)))) + ;;XXX bird species? ;;XXX water species? ;;XXX small mammals -> hills diff --git a/biomes.lisp b/biomes.lisp index 491bf48..74181d8 100644 --- a/biomes.lisp +++ b/biomes.lisp @@ -24,7 +24,7 @@ :ground "leaf litter and small shrubs" :char #\. :col ':green :features '((miombo 10) (acacia 15) - (warthog 400) (impala 800) + (warthog 500) (impala 800) (elephant 1000) (leopard 3200))) ;TODO (new-biome stream diff --git a/classes.lisp b/classes.lisp index 2a694eb..5d590b4 100644 --- a/classes.lisp +++ b/classes.lisp @@ -15,6 +15,8 @@ (weight :accessor .weight :initarg :weight :initform 0) (movable :reader movablep :initarg :movable :initform T) ;;XXX not sure yet how I'm going to use the actions + (update :accessor .update :initarg :update + :initform #'(lambda () NIL)) (action :accessor .action :initarg :action :initform #'(lambda () NIL)))) @@ -32,6 +34,8 @@ ;; A landscape feature such as a rock, a tree, or an animal. ((symbol-char :reader .char :initarg :char :initform NIL) (symbol-color :reader .color :initarg :color :initform NIL) + (x-pos :accessor .x :initarg :x :initform 0) + (y-pos :accessor .y :initarg :y :initform 0) ;;XXX is there a way of setting a superclass variable for all ;; subclass instances? (movable :reader movablep :initarg :movable :initform NIL))) @@ -60,6 +64,7 @@ (aggression :accessor .aggression :initarg :aggression :initform 0) (group-size :reader .group-size :initarg :group-size :initform 1) (habitat :reader .habitat :initarg :habitat :initform '()) + (update :accessor .update :initarg :update :initform #'random-move) (destroy-with :reader destructors :initarg :destroy-with :initform '(weapon)))) diff --git a/naledi.lisp b/naledi.lisp index d5e5977..7166bf4 100644 --- a/naledi.lisp +++ b/naledi.lisp @@ -156,6 +156,7 @@ (defun message-window () "Return a dialog window with the last game messages." + ;;TODO complete (make-instance 'dialog-window :input-blocking t :items (mapcar @@ -179,5 +180,5 @@ ;; Initialize the random state (which would otherwise not be very random...) (setf *random-state* (make-random-state t)) -(create-world 200) +(create-world 250) (start-game) diff --git a/README.md b/README.md index fcf3e34..a03c806 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ # Naledi ya Africa -**Naledi ya Africa** (*Star of Africa* in seTswana) is a survival game set in +Naledi ya Africa (*Star of Africa* in seTswana) is a survival game set in Africa. It offers networked multiplayer with an ncurses user interface. ---- - ## Running To compile Naledi ya Africa, you need a Common Lisp implementation (SBCL is diff --git a/animals.lisp b/animals.lisp index 3e0cabd..0406c30 100644 --- a/animals.lisp +++ b/animals.lisp @@ -8,6 +8,19 @@ ;;;; (c) 2018 Daniel Vedder, MIT license ;;;; +(defmethod random-move ((a animal)) + (do* ((dir (random-elt *directions*) (random-elt *directions*)) + (next-patch (patch-in-dir (.x a) (.y a) dir) + (patch-in-dir (.x a) (.y a) dir)) + (ttl 10 (1- ttl))) + ((zerop ttl) NIL) + (when (and next-patch (null (patch-occupant next-patch))) + (setf (patch-occupant (coord (.x a) (.y a))) NIL) + (setf (.x a) (first (patch-pos next-patch)) + (.y a) (second (patch-pos next-patch))) + (setf (patch-occupant next-patch) a) + (return-from random-move)))) + ;;XXX bird species? ;;XXX water species? ;;XXX small mammals -> hills diff --git a/biomes.lisp b/biomes.lisp index 491bf48..74181d8 100644 --- a/biomes.lisp +++ b/biomes.lisp @@ -24,7 +24,7 @@ :ground "leaf litter and small shrubs" :char #\. :col ':green :features '((miombo 10) (acacia 15) - (warthog 400) (impala 800) + (warthog 500) (impala 800) (elephant 1000) (leopard 3200))) ;TODO (new-biome stream diff --git a/classes.lisp b/classes.lisp index 2a694eb..5d590b4 100644 --- a/classes.lisp +++ b/classes.lisp @@ -15,6 +15,8 @@ (weight :accessor .weight :initarg :weight :initform 0) (movable :reader movablep :initarg :movable :initform T) ;;XXX not sure yet how I'm going to use the actions + (update :accessor .update :initarg :update + :initform #'(lambda () NIL)) (action :accessor .action :initarg :action :initform #'(lambda () NIL)))) @@ -32,6 +34,8 @@ ;; A landscape feature such as a rock, a tree, or an animal. ((symbol-char :reader .char :initarg :char :initform NIL) (symbol-color :reader .color :initarg :color :initform NIL) + (x-pos :accessor .x :initarg :x :initform 0) + (y-pos :accessor .y :initarg :y :initform 0) ;;XXX is there a way of setting a superclass variable for all ;; subclass instances? (movable :reader movablep :initarg :movable :initform NIL))) @@ -60,6 +64,7 @@ (aggression :accessor .aggression :initarg :aggression :initform 0) (group-size :reader .group-size :initarg :group-size :initform 1) (habitat :reader .habitat :initarg :habitat :initform '()) + (update :accessor .update :initarg :update :initform #'random-move) (destroy-with :reader destructors :initarg :destroy-with :initform '(weapon)))) diff --git a/naledi.lisp b/naledi.lisp index d5e5977..7166bf4 100644 --- a/naledi.lisp +++ b/naledi.lisp @@ -156,6 +156,7 @@ (defun message-window () "Return a dialog window with the last game messages." + ;;TODO complete (make-instance 'dialog-window :input-blocking t :items (mapcar @@ -179,5 +180,5 @@ ;; Initialize the random state (which would otherwise not be very random...) (setf *random-state* (make-random-state t)) -(create-world 200) +(create-world 250) (start-game) diff --git a/world.lisp b/world.lisp index 1a7dae9..fca163b 100644 --- a/world.lisp +++ b/world.lisp @@ -116,6 +116,7 @@ (let ((flist (biome-features (patch-biome patch)))) (dolist (f flist NIL) (when (chancep (second f)) + ;;FIXME I need to get an actual item and set its position (return-from get-patch-feature (get-item-type (first f))))))) (defun generate-biomes (size-factor) @@ -155,7 +156,7 @@ (defun create-world (size) (set-world (init-matrix size)) ;;XXX magic numbers - (generate-herds (generate-biomes 10)) + (generate-biomes 10) (dotimes (s (round (/ (expt size 2) 2000))) (generate-stream (random size) (random size))))